在Benders分解算法中,如何将主问题的当前解转化为子问题的约束条件?

2024-06-12 20:57:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Benders分解,目前我正在使用bendersatsp.py文件,以便使这段代码适应我自己的MIP问题。 这种情况是,在我的例子中,主问题的解决方案参与子问题的一些约束,与这个bendersatsp.py文件不同。这意味着,对于主程序的每个当前解决方案,我必须修改这些约束的系数。你知道吗

那么,为了使用主问题的当前解向量到子问题中,我能/必须写些什么呢?你知道吗

目前,我已经将这个约束块写入了separate函数,但是最优目标值是不正确的。 为什么这不是个好办法?你知道吗

提前谢谢!你知道吗


Tags: 文件函数代码py情况解决方案向量例子
1条回答
网友
1楼 · 发布于 2024-06-12 20:57:32

BendersLazyConsCallback中,self.get_values方法:

Returns the solution values at the current node.

In the case that the node LP is unbounded, this method returns a vector that corresponds to an unbounded direction, scaled so that at least one of its elements has magnitude cplex.infinity. Thus, often the vector can be used directly, for example to separate a lazy constraint. However, due to the presence of large values in the vector care must be taken to avoid potential numerical errors. If in doubt, rescale the vector, and use it as an unbounded ray rather than a primal vector.

解向量被传递到workerLP.separate,并用于修改workerLP目标的线性系数。相反,听起来您希望以某种方式修改workerLP的约束。你知道吗

而不是打电话:

cpx.objective.set_linear(zip(thevars, thecoefs))

您应该在Cplex.linear_constraints接口中调用方法。你知道吗

相关问题 更多 >