Excel 求解器不遵守二元约束

发布于 2024-08-02 17:56:30 字数 178 浏览 5 评论 0原文

我在 Excel 中创建了一个模型以与 Solver 结合使用。它大部分有效。唯一的问题是 Solver 并没有真正正确地将约束为二元的单元格处理。当找到解决方案后,一些数字实际上是 0.9999996、1.0000000003、0.0000017 等等。

我在 Mac OS X 上使用 Excel 2004。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

注定孤独终老 2024-08-09 17:56:30

如果二进制值远离 0 或 1,您可能需要转到“求解器”窗口中的选项并检查“忽略整数约束”框是否已选中。

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".

二货你真萌 2024-08-09 17:56:30

由于计算机的有限精度和优化算法的性质,求解器内置了公差。我会尝试选择“求解器参数”对话框上的“选项”按钮,然后增加精度(例如从默认值 0.000001 到 0.00000001) 。我不确定这是否有效,但值得一试。

我的公司制作了一个与 Excel 连接的商业级求解器,称为 What'sBest。如果以上方法不行的话可以考虑一下。您可以在 www.lindo.com 上找到更多信息

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

挖个坑埋了你 2024-08-09 17:56:30

如果求解器无法在允许的时间范围或迭代次数内找到解决方案(或者如果没有可能的正确答案),它将不会返回二进制答案。

一种可能的解决方法是设置一些单元格(可能是那些带有您正在计算的单元格中的最小值),使用约束 <=1>=0 而不是二进制。您提供的图片没有显示,所以我不太确定您想要什么。

(对于未设置为二进制的单元格,设置一个具有和积的单元格可能会有所帮助;请参见下文。)

例如,如果您尝试求解总计 22(无解),您可以从:

9   1
9   1
9   1
6   1
3   1

如果将第二列中的所有值设置为二进制,则最终会得到:

9   0.5625
9   0.5625
9   0.5625
6   0.708333333
3   0.854166667

如果将前 3 个设置为二进制,最后两个设置为 <=1 & >=0,您最终得到:

9   0
9   1
9   1
6   0.333333333
3   0.666666667

最后两行的和积 = 4,然后您可以使用它手动将最后两行之一设置为 1,另一个设置为 0,具体取决于是否您想要的答案略低于或高于目标。

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.

节枝 2024-08-09 17:56:30

我遇到了类似的问题,可以通过转到求解器选项然后检查“使用自动缩放”来解决它。我不确定这是否能解决您的问题,但值得一试。

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.

吃兔兔 2024-08-09 17:56:30

可能不是您的问题,但请注意,选项中有一个Ignore Integer Constraints 复选框,在 Excel Solver 中默认处于选中状态。至少我的 Excel 2011 for Mac 副本是这样。

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.

冰葑 2024-08-09 17:56:30

我遇到了同样的事情,取消选中忽略整数约束框为我解决了这个问题。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文