如何修复由PuLP启动的subprocess.wait()中的错误代码9

2024-04-29 03:16:36 发布

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

我试图解决一个优化问题,不同的数据集被用作输入。对于大多数的设置,我的程序利用纸浆库与硬币或CBC解算器工作得很好。但对于一个特定的数据集,它崩溃了。引发的错误如下: https://github.com/coin-or/pulp/blob/746f35cd23711b01237c83850ef1dabb0889da83/pulp/solvers.py#L1445

然后,我从subprocess python模块中打印了cbc.wait()的returncode,它是-9,对应于: ^unix中的{}

那也没什么用,是吗

然后我看了一下这个数据集与其他数据集的区别。 在结构上它们似乎是一样的(稀疏,没有Nan)。为了澄清问题,利用数据集的低秩近似来设置优化问题中的不等式约束

我还将解算器输出更改为true,以便从中扣除问题。但它似乎正常工作,然后抛出上述错误

command line - cbc /tmp/e2a9e3cf978546a3bd5d4074c9bf99cb-pulp.mps threads 30 sec 36000 branch printingOptions all solution /tmp/e2a9e3cf978546a3bd5d4074c9bf99cb-pulp.sol (default strategy 1)
At line 2 NAME          MODEL
At line 3 ROWS
At line 297 COLUMNS
At line 43807 RHS
At line 44100 BOUNDS
At line 44398 ENDATA
Problem MODEL has 292 rows, 149 columns and 43212 elements
Coin0008I MODEL read with 0 errors
threads was changed from 0 to 30
seconds was changed from 1e+100 to 36000
Continuous objective value is 0 - 0.06 seconds
Cgl0004I processed model has 290 rows, 148 columns (147 integer (0 of which binary)) and 42920 elements
Cbc0031I 3 added rows had average density of 148
Cbc0013I At root node, 3 cuts changed objective from 0 to 0.0042535435 in 100 passes
Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 3.386 seconds - new frequency is -100
Cbc0014I Cut generator 1 (Gomory) - 1461 row cuts average 148.0 elements, 0 column cuts (0 active)  in 3.320 seconds - new frequency is -100
Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.022 seconds - new frequency is -100
Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.001 seconds - new frequency is -100
Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.380 seconds - new frequency is -100
Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.093 seconds - new frequency is -100
Cbc0010I After 0 nodes, 1 on tree, 1e+50 best solution, best possible 0.0042535435 (14.64 seconds)
Cbc0012I Integer solution of 1.0374824 found by rounding after 3265 iterations and 1 nodes (15.94 seconds)
Cbc0012I Integer solution of 1.0374824 found by heuristic after 3264 iterations and 0 nodes (15.94 seconds)
Cbc0012I Integer solution of 1.0218801 found by rounding after 14797 iterations and 346 nodes (147.81 seconds)
Cbc0012I Integer solution of 1.0218801 found by heuristic after 15786 iterations and 375 nodes (147.81 seconds)

Traceback (most recent call last):
  File "main.py", line 273, in <module>
  File "main.py", line 219, in main_for_cleaned_and_aggregated_data

  File "main.py", line 88, in run_all_milp_variants
    solution = milp_solver.get_or_create(data=data, output_dir=save_dir)
  File "/home/ubuntu/milp/milp_solver.py", line 202, in get_or_create
    milp_result = __run(data=data, reg_param=reg_param, type=type, output_dir=output_dir)
  File "/home/ubuntu/milp/milp_solver.py", line 111, in __run
    prob.solve(pp.solvers.COIN_CMD(threads=30, maxSeconds=36000, msg=1))
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pulp/pulp.py", line 1671, in solve
    status = solver.actualSolve(self, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pulp/solvers.py", line 1367, in actualSolve
    return self.solve_CBC(lp, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pulp/solvers.py", line 1430, in solve_CBC
    self.path)
pulp.solvers.PulpSolverError: Pulp: Error while trying to execute cbc

如果有人知道这里发生了什么,请详细说明。我的代码挖掘之旅即将结束,我在子处理任务方面的经验有限


Tags: andofinpyislineelementsat