Gurobi Python回调:我在检索解决方案数据时遇到麻烦:LP松弛,左节点等

时间:2018-08-08 07:39:17

标签: python callback gurobi

我有一个使用Gurobi用Python编码的MILP模型。

当代码终止时(通常有时间限制),我想使用gurobi回调保存一些解决方案数据。我主要要保存“ LP松弛目标”和“左节点”。我这样使用它:

这是最后几行:

[testenv]  
 # settings related to "default" testenv - includes deps, commands

[testenv2]  
 # settings related to testenv2 - includes deps, commands

[testenv:py27-testenv2]  
deps = {[testenv2]deps}
commands = {[testenv2]commands}

[testenv:py35-testenv2]  
deps = {[testenv2]deps}
commands = {[testenv2]commands}

但是我有以下错误:

model.optimize()
MyproblemLeftNodes = model.cbGet(GRB.Callback.MIP_NODLFT)

此外,如果我将其用作:

'NoneType' object has no attribute '_cbdata'

我将拥有常数3005。

现在,我正在使用这个:

MyproblemLeftNodes = GRB.Callback.MIP_NODLFT

但我仍然不知道将其放置在何处。优化模型之后还是在模型内?都无法使用我当前的编码,响应:

            def mycallback(myModel, where):
            if where == GRB.Callback.MIP:
                LPRelax = model.cbGet(GRB.Callback.MIP_OBJBST)

            return LPRelax

有人可以帮助我如何正确使用回调吗?

0 个答案:

没有答案