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

Python 如何修复由PuLP启动的subprocess.wait()中的错误代码9,python,linear-programming,pulp,mixed-integer-programming,Python,Linear Programming,Pulp,Mixed Integer Programming,我试图解决一个优化问题,其中使用不同的数据集作为输入。对于大多数集合,我的程序使用带有coin或CBC解算器的纸浆库工作得很好。但对于一个特定的数据集,它崩溃了。引发的错误如下: 然后,我从子流程python模块中打印了cbc.wait()的返回代码,该模块为-9,对应于: unix中的EBADF 9/*错误文件号*/ 那没什么帮助,是吗 然后我看了一下这个数据集与其他数据集的不同之处。 从结构上看,它们似乎是一样的。(稀疏,没有Nan)。为了澄清,数据集的低秩近似用于设置优化问题中的不等式约

我试图解决一个优化问题,其中使用不同的数据集作为输入。对于大多数集合,我的程序使用带有coin或CBC解算器的纸浆库工作得很好。但对于一个特定的数据集,它崩溃了。引发的错误如下:

然后,我从子流程python模块中打印了cbc.wait()的返回代码,该模块为-9,对应于: unix中的EBADF 9/*错误文件号*/

那没什么帮助,是吗

然后我看了一下这个数据集与其他数据集的不同之处。 从结构上看,它们似乎是一样的。(稀疏,没有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

命令行-cbc/tmp/e2a9e3cf978546a3bd5d407c9bf99cb-pill.mps线程30秒36000分支打印选项所有解决方案/tmp/e2a9e3cf978546a3bd5d407c9bf99cb-pill.sol(默认策略1)
在第2行命名模型
第3行
在第297行的列中
在43807号线RHS
第44100行边界处
在第44398行ENDATA
问题模型有292行、149列和43212个元素
Coin0008I型号读取时出现0个错误
线程已从0更改为30
秒数从1e+100更改为36000
连续目标值为0-0.06秒
Cgl0004I处理过的模型有290行、148列(147个整数(其中0个是二进制的))和42920个元素
Cbc0031I 3添加行的平均密度为148
根节点处的Cbc0013I,在100次传递中,3次切割将目标从0更改为0.0042535435
Cbc0014I切割生成器0(探测)-0行切割平均0.0个元素,0列切割(0活动)在3.386秒内-新频率为-100
Cbc0014I切割生成器1(Gomory)-1461行切割平均148.0个元素,0列切割(0活动)在3.320秒内-新频率为-100
Cbc0014I切割生成器2(背包)-0行切割平均0.0个元素,0列切割(0活动)在0.022秒内-新频率为-100
Cbc0014I剪切生成器3(Clique)-0行剪切平均0.0个元素,0列剪切(0活动)在0.001秒内-新频率为-100
Cbc0014I切割生成器4(混合集成2)-0行切割平均0.0个元素,0列切割(0活动)在0.380秒内-新频率为-100
Cbc0014I切割生成器5(FlowCover)-0行切割平均0.0个元素,0列切割(0活动)在0.093秒内-新频率为-100
Cbc0010I 0个节点后,1个在树上,1e+50最佳解决方案,最佳可能0.0042535435(14.64秒)
在3265次迭代和1个节点(15.94秒)后通过舍入找到1.0374824的Cbc0012I整数解
Cbc0012I在3264次迭代和0个节点(15.94秒)后通过启发式找到1.0374824的整数解
在14797次迭代和346个节点(147.81秒)后通过舍入找到1.0218801的Cbc0012I整数解
在15786次迭代和375个节点(147.81秒)后,通过启发式找到1.0218801的Cbc0012I整数解
回溯(最近一次呼叫最后一次):
文件“main.py”,第273行,在
文件“main.py”,第219行,位于main_中,用于清理_和聚合_数据
文件“main.py”,第88行,在run_all_milp_变量中
解决方案=milp\U解算器。获取或创建(数据=数据,输出\u目录=保存\u目录)
文件“/home/ubuntu/milp/milp_solver.py”,第202行,在get_或_create中
milp_结果=__运行(数据=数据,注册表参数=注册表参数,类型=类型,输出目录=输出目录)
文件“/home/ubuntu/milp/milp_solver.py”,第111行,运行
问题求解(pp.solvers.COIN_CMD(线程=30,最大秒数=36000,消息=1))
文件“/home/ubuntu/.local/lib/python3.6/site packages/pulp/pulp.py”,第1671行,在solve中
状态=解算器。实际解算器(自身,**kwargs)
文件“/home/ubuntu/.local/lib/python3.6/site packages/pulp/solvers.py”,第1367行,在actualSolve中
返回自我解决方案\u CBC(lp,**kwargs)
solve_CBC中的文件“/home/ubuntu/.local/lib/python3.6/site packages/pulp/solvers.py”,第1430行
self.path)
纸浆解算器纸浆解算器错误:纸浆:尝试执行cbc时出错

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

我怀疑CBC崩溃(或死亡)。首先,我会尝试使用1个线程运行。30个线程可能太多了。我将尝试更低的线程数。知道CBC崩溃的原因吗?不知道。你可以通过让CBC写出一个核心文件来了解更多。