업데이트
이 질문은 crossposted했던 OR exchange에서 철저히 토론되고 업데이트되었습니다.CPLEX Python API 성능 오버 헤드?
원래의 질문에
내가 명령 줄에서 CPLEX 12.5.0.0 실행하면 : 최적 정수 솔루션은 19056.99 틱에서 발견된다
cplex -f my_instance.lp
합니다. 바로 그 인스턴스
그러나 파이썬 API를 통해
:import cplex
problem = cplex.Cplex("my_instance.lp")
problem.solve()
필요한 시간은 지금 (5 회 이상 느린) 97407.10 틱에 달한다.
두 경우 모두 모드는 병렬적이고 결정적이며 최대 2 개의 스레드입니다. 이 성능 저하가 일부 파이썬 스레드 오버 헤드 때문 궁금, 나는 시도 :
problem = cplex.Cplex("my_instance.lp")
problem.parameters.threads.set(1)
problem.solve()
필수 46513.04 틱 (즉, 하나 개의 코어를 사용하여 두 배 빠른 두를 사용하는 것보다이었다!).
일반적으로 CPLEX 및 LP에 익숙하지 않아이 결과가 매우 혼란 스럽습니다. Python API 성능을 개선 할 수있는 방법이 있습니까? 아니면 좀 더 성숙한 API (예 : Java 또는 C++)로 전환해야합니까? 명령 줄에서
Tried aggregator 3 times.
MIP Presolve eliminated 2648 rows and 612 columns.
MIP Presolve modified 62 coefficients.
Aggregator did 13 substitutions.
Reduced MIP has 4229 rows, 1078 columns, and 13150 nonzeros.
Reduced MIP has 1071 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.06 sec. (18.79 ticks)
Probing fixed 24 vars, tightened 0 bounds.
Probing time = 0.08 sec. (18.12 ticks)
Tried aggregator 1 time.
MIP Presolve eliminated 87 rows and 26 columns.
MIP Presolve modified 153 coefficients.
Reduced MIP has 4142 rows, 1052 columns, and 12916 nonzeros.
Reduced MIP has 1045 binaries, 7 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.05 sec. (11.67 ticks)
Probing time = 0.01 sec. (1.06 ticks)
Clique table members: 4199.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 2 threads.
Root relaxation solution time = 0.20 sec. (91.45 ticks)
결과 :
GUB cover cuts applied: 1
Clique cuts applied: 3
Cover cuts applied: 2
Implied bound cuts applied: 38
Zero-half cuts applied: 7
Gomory fractional cuts applied: 2
Root node processing (before b&c):
Real time = 5.27 sec. (2345.14 ticks)
Parallel b&c, 2 threads:
Real time = 35.15 sec. (16626.69 ticks)
Sync time (average) = 0.00 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 40.41 sec. (18971.82 ticks)
결과
부록 여기
는 2 스레드 '해상도의 자세한 먼저 (공통) 프리앰블은 Python API에서 :
Clique cuts applied: 33
Cover cuts applied: 1
Implied bound cuts applied: 4
Zero-half cuts applied: 10
Gomory fractional cuts applied: 4
Root node processing (before b&c):
Real time = 6.42 sec. (2345.36 ticks)
Parallel b&c, 2 threads:
Real time = 222.28 sec. (95061.73 ticks)
Sync time (average) = 0.01 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 228.70 sec. (97407.10 ticks)
"답변"은 최근에 삭제되어 독자를 최신 토론으로 리디렉션하는 데 사용되었습니다. 나는 결과적으로 내 게시물을 링크로 업데이트했다. 그것이 살아남을 수 있기를 바라 라 ;-) – Aristide