检测纸浆模型中的预求解状态

问题描述 投票:0回答:1

您好,我正在使用纸浆 CBC 运行一个模型,并且模型中几乎没有约束,如果模型输入错误,这些约束可能会使模型不可行。

我可以看到,当我的模型运行时,如果模型不可行,我可以在终端中看到输出,上面写着

presolve detects 1 infeasibility
。在这条线之后,我的模型开始求解,毫不奇怪地给出了我的解决方案不可行的输出。

我的问题是,如果 presolve 说我的模型不可行,我该如何停止我的程序?有什么方法可以检测到这一点,因为我不想花时间求解预求解认为不可行的模型。

问题背景:

我的模型中有一个硬约束,这可能使我的模型在某些情况下不可行,我希望我的程序(而不是 OR 模型)检测到这种不可行性并使该约束变得软。

实现此目的的一种方法是让我的完整程序运行,然后检测

result_status
,但模型可能需要相当长的时间才能运行,考虑到我必须使用Soft Constraint再次运行,我不想花时间。我在想如果预求解模型不可行,有什么方法可以检测并停止我的模型。

删除了一些行的 LP 文件:

Welcome to the CBC MILP Solver 
Version: 2.10.3 
Build Date: Dec 15 2019 

command line - "PATH" max sec 3000 ratio 1e-05 timeMode elapsed branch printingOptions all solution "PATH"\f5c13890167e459ea27741f1c5d52d5c-pulp.sol (default strategy 1)
At line 2 NAME          MODEL
At line 3 ROWS
At line 95389 COLUMNS
At line 611896 RHS
At line 707281 BOUNDS
At line 707282 ENDATA
Problem MODEL has 95384 rows, 175589 columns and 341444 elements
Coin0008I MODEL read with 0 errors
seconds was changed from 1e+100 to 3000
ratioGap was changed from 0 to 1e-05
Option for timeMode changed from cpu to elapsed
Presolve determined that the problem was infeasible with tolerance of 1e-08
Analysis indicates model infeasible or unbounded
1 infeasibilities
Analysis indicates model infeasible or unbounded
Perturbing problem by 0.001% of 5262.5816 - largest nonzero change 0.0052725434 ( 9.7117787%) - largest zero change 0.0026361607
0  Obj -0 Primal inf 7.4173266e+08 (10627) Dual inf 1.383116e+10 (56881)
0  Obj -0 Primal inf 7.4173266e+08 (10627) Dual inf 6.2882648e+14 (66006)

Primal infeasible - objective value -6.0887206e+12
PrimalInfeasible objective -6.088720618e+12 - 108021 iterations time 88.622

Result - Linear relaxation infeasible

Enumerated nodes:           0
Total iterations:           0
Time (CPU seconds):         89.03
Time (Wallclock Seconds):   89.03

Option for printingOptions changed from normal to all
Total time (CPU seconds):       89.91   (Wallclock seconds):       89.91
python optimization pulp coin-or-cbc
1个回答
0
投票

为什么不通过高惩罚来使问题具有弹性?

model.extend(
     pp.LpConstraint(
         e =VARIABLE,
         sense = pp.LpConstraintLE,
         rhs=MAX_VALUE_ACCEPTABLE
         name=f"permissive_elastic"
     ).makeElasticSubProblem(
         penalty=1000
         proportionFreeBoundList=[1,0]
     )

这样,模型将尽其所能将变量保持在其最大可接受值以下,以避免因高惩罚而降低目标值。只有当该条件不可行时,才会放宽条件并允许更高的值。

© www.soinside.com 2019 - 2024. All rights reserved.