Excel Solver not obeying binary constraint
Asked Answered
D

6

5

I created a model in Excel to use in conjunction with Solver. It mostly works. The only problem is that Solver is not really treating the cells constrained as binary properly. When it's done finding a solution, some of the numbers are actually 0.9999996, 1.0000000003, 0.0000017, and so on.

I am using Excel 2004 on Mac OS X. Any ideas?

Detonate answered 25/8, 2009 at 7:11 Comment(0)
T
3

Due to the finite precision of computers and the nature of the optimization algorithms, the solver has tolerances built in. I would try selecting the Options button on the Solver Parameters dialogue box and then increase the Precision (say from the default of 0.000001 to 0.00000001). I am not sure if this will work, but it is worth a try.

My company makes a commercial grade solver hooked to Excel called What’sBest. If the above does not work you could consider it. You can find more info at www.lindo.com

Territorial answered 25/8, 2009 at 15:27 Comment(1)
Actually, the default precision was at 5. I changed it to 0, and it seems to have worked. Strange I have to fiddle with precision if the variables are supposed to be binary! :S Thanks!Detonate
V
14

If the binary values are far from 0 or 1, you might have to go to options in the Solver window and check if the box "Ignore integer constraints is checked".

Vientiane answered 1/2, 2011 at 0:0 Comment(0)
T
3

Due to the finite precision of computers and the nature of the optimization algorithms, the solver has tolerances built in. I would try selecting the Options button on the Solver Parameters dialogue box and then increase the Precision (say from the default of 0.000001 to 0.00000001). I am not sure if this will work, but it is worth a try.

My company makes a commercial grade solver hooked to Excel called What’sBest. If the above does not work you could consider it. You can find more info at www.lindo.com

Territorial answered 25/8, 2009 at 15:27 Comment(1)
Actually, the default precision was at 5. I changed it to 0, and it seems to have worked. Strange I have to fiddle with precision if the variables are supposed to be binary! :S Thanks!Detonate
A
3

If solver is unable to find a solution within the time frame or number of iterations allowed (or if there is no correct answer possible) it will not return binary answers.

One possible work-around, depending on the type of problem you are trying to solve and how exact an answer you need, is to set a few cells (probably the ones with the smallest values in the cells you are calculating for) with the contstraints <=1 and >=0 rather than binary. The image you provided is not showing up, so I'm not exactly sure what you were after.

(It may be helpful to set up a cell with a sumproduct for the cells not set as binary; see below.)

As an example, if you are trying to solve for a total of 22 (which has no solution), you start with:

9   1
9   1
9   1
6   1
3   1

If you set all the values in the second column as binary, you will end up with:

9   0.5625
9   0.5625
9   0.5625
6   0.708333333
3   0.854166667

If you set the first 3 as binary, and the last two as <=1 & >=0, you end up with:

9   0
9   1
9   1
6   0.333333333
3   0.666666667

The sumproduct for the last two rows = 4, which you could then use to manually set one of the last two as 1 and the other 0, depending on whether you want an answer slightly below or above the target.

Antechamber answered 10/8, 2012 at 17:11 Comment(0)
V
3

I had similar issue and could resolve it by going to solver options and then checking "Use Automatic scaling". I am not sure this will fix your issue or not but worth a try.

Variable answered 19/11, 2012 at 14:27 Comment(0)
F
1

Likely not your problem, but be aware there is an Ignore Integer Constraints checkbox in Options that is checked by default in Excel Solver. At least that's the case in my copy of Excel 2011 for Mac.

Flowage answered 10/2, 2012 at 18:8 Comment(0)
I
0

I ran into the same thing and unchecking the Ignore Integer Constraints box solved this problem for me.

Isfahan answered 17/8, 2020 at 15:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.