Как исправить код ошибки 9 в subprocess.wait (), запущенном PuLP - PullRequest
0 голосов
/ 04 ноября 2019

Я пытаюсь решить проблему оптимизации, когда разные наборы данных используются в качестве входных данных. Для большинства наборов моя программа, использующая библиотеку PuLP с монетным или CBC-решателем, работает просто отлично. Но для одного набора данных, в частности, происходит сбой. Возникла следующая ошибка: https://github.com/coin-or/pulp/blob/746f35cd23711b01237c83850ef1dabb0889da83/pulp/solvers.py#L1445

Затем я напечатал код возврата из cbc.wait () из модуля python подпроцесса, который был равен -9, что соответствует: EBADF 9 /* Bad file number */ в unix.

Ну, это было не так уж и полезно, не так ли?

Затем я взглянул на то, что отличается для этого набора данных по сравнению с другими. Конструктивно они кажутся одинаковыми. (редко, нет Нэн). Для пояснения используется низкоранговая аппроксимация набора данных, чтобы установить ограничения неравенства в задаче оптимизации.

Я также изменил вывод решателей на 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

Если кто-то знает, что здесь происходит, уточните. Я нахожусь в конце своего пути по копанию кода с моим ограниченным опытом в задачах дополнительной обработки.

...