简体   繁体   English

CPLEX找到最佳的LP解决方案,但不返回基本错误

[英]CPLEX finds optimal LP solution but returns no basis error

I am solving a series of LP problems using the CPLEX Python API. 我正在使用CPLEX Python API解决一系列LP问题。 Since many of the problems are essentially the same, save a hand full of parameters. 由于许多问题本质上是相同的,因此请保存大量参数。 I want to use a warm start with the solution of the previous problem for most of them, by calling the function cpx.start.set_start(col_status, row_status, col_primal, row_primal, col_dual, row_dual) where cpx = cplex.Cplex() . 我想通过调用函数cpx.start.set_start(col_status, row_status, col_primal, row_primal, col_dual, row_dual)其中大多数解决方案使用热启动,其中cpx = cplex.Cplex()

This function is documented here . 此功能在此处记录 Two of the arguments, col_status and row_status , are obtained by calling cpx.solution.basis.get_col_basis() and cpx.solution.basis.get_row_basis() . 通过调用cpx.solution.basis.get_col_basis()cpx.solution.basis.get_row_basis()获得两个参数col_statusrow_status

However, despite cpx.solution.status[cpx.solution.get_status()] returning optimal and being able to obtain both cpx.solution.get_values() and cpx.solution.get_dual_values() ... 但是,尽管cpx.solution.status[cpx.solution.get_status()]返回optimal ,并且能够同时获得cpx.solution.get_values()cpx.solution.get_dual_values() ……

Calling cpx.solution.basis.get_basis() returns CPLEX Error 1262: No basis exists. 调用cpx.solution.basis.get_basis()返回CPLEX Error 1262: No basis exists.

Now, according to this post one can call the warm start function with empty lists for the column and row basis statuses, as follows. 现在,根据这篇文章,可以使用空的列和行基础状态列表来调用热启动功能,如下所示。

lastsolution = cpx.solution.get_values()
cpx.start.set_start(col_status=[], row_status=[], 
                    col_primal=lastsolution, row_primal=[],
                    col_dual=[], row_dual=[])

However, this actually results in making a few more CPLEX iterations. 但是,这实际上导致进行了更多的CPLEX迭代。 Why more is unclear, but the overall goal is to have significantly less, obviously. 为什么还不清楚,但是总体目标显然是要少得多。

Version Info Python 2.7.12 CPLEX 12.6.3 版本信息Python 2.7.12 CPLEX 12.6.3

I'm not sure why you're getting the CPXERR_NO_BASIS . 我不确定为什么会收到CPXERR_NO_BASIS See my comment. 看到我的评论。

You may have better luck if you provide the values for row_primal , col_dual , and row_dual too. 如果您也提供row_primalcol_dualrow_dual的值,则可能会更好。 For example: 例如:

cpx2.start.set_start(col_status=[],
                     row_status=[],
                     col_primal=cpx.solution.get_values(),
                     row_primal=cpx.solution.get_linear_slacks(),
                     col_dual=cpx.solution.get_reduced_costs(),
                     row_dual=cpx.solution.get_dual_values())

I was able to reproduce the behavior you describe using the afiro.mps model that comes with the CPLEX examples (number of deterministic ticks actually increased when specifying col_primal alone). 我能够使用CPLEX示例附带的afiro.mps模型重现您描述的行为(当单独指定col_primal时,确定性标记的数量实际上增加了)。 However, when doing the above, it did help (number of det ticks improved and iterations went to 0). 但是,当执行上述操作时,它确实有帮助(改进了单位滴答声的数量,并且迭代次数变为0)。

Finally, I don't believe that there is any guarantee that using set_start will always help (it may even be a bad idea in some cases). 最后,我不认为可以肯定使用set_start总是有帮助的(在某些情况下甚至是个坏主意)。 I don't have a reference for this. 我对此没有参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM