Excel solver with if, xor statements

Viewed 80

I'm trying to solve an optimisation problem in Excel. One of the constraints is as follows:

if A = 1 then B XOR C = 1

Put differently, if A is selected, then either B or C (but not both) must also be selected.

How can I phrase this as a constraint that Solver will accept?

Thank you!

2 Answers

I have just created the following formula, but I doubt that solver will be able to handle it:

=IF(AND(A1=1,XOR(B1=1,C1=1)),TRUE,FALSE)

As far as I know, solver uses numerical approximation methods (like Newton/Raphson method), which are not applicable for this case.

Then I would put in cell D1 the following:

=B1+C1

And the constraint is that D1=A1

So either B1 can be 1 or C1 can be 1 but both cannot be 1 as the sum will be 2. Of course, if A1 is 0 then the sum of b1 and c1 will also be 0.

This type of thing works well, but you may have other constraints to control B1 relative to C1.

Related