Python中文
首页
教程
问答
标签
搜索
登录
注册
CPLEX PythonAPI性能开销?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<h2>更新</h2> <p>这个问题已经在<a href="https://www.or-exchange.org/questions/7565/cplex-python-api-performance-overhead" rel="nofollow">OR exchange</a>上得到了彻底的讨论和更新,我在那里交叉发布了它。在</p> <h2>原始问题</h2> <p>当我从命令行运行CPLEX 12.5.0.0时:</p> <pre><code>cplex -f my_instance.lp </code></pre> <p>在19056.99滴答中找到了一个最佳整数解。在</p> <p>但是通过Python API,在同一个实例上:</p> ^{pr2}$ <p>现在所需的时间为97407.10滴答(慢了5倍多)。在</p> <p>在这两种情况下,模式是并行的,确定性的,最多2个线程。我想知道这种性能低下是否是由于某些Python线程开销造成的,我尝试:</p> <pre><code>problem = cplex.Cplex("my_instance.lp") problem.parameters.threads.set(1) problem.solve() </code></pre> <p>需要46513.04个周期(即使用一个核心比使用两个核心快两倍!)。在</p> <p>作为CPLEX和LP的新手,我发现这些结果相当混乱。有没有办法提高Python API性能,或者我应该切换到一些更成熟的API(即java或C++)吗?在</p> <h2>附件</h2> <p>以下是2线程决议的全部细节,首先是(共同)序言:</p> <pre><code>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) </code></pre> <p>来自命令行的结果:</p> <pre><code>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) </code></pre> <p>Python API的结果:</p> <pre><code>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) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>与此相关,我注意到python API在调用变量.add线性的_约束.添加. 似乎从CPXLgetcolindex调用的strcmp占用了大部分配置文件,也许字符串id是通过数组的线性搜索来处理的?在C++中,问题的产生是瞬时的。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在Excel中读取公式并将其转换为Python中的计算?
1 回答
如何在excel中读取嵌入的excel,并将嵌入文件中的信息存储在主excel文件中?
1 回答
如何在Excel中返回未知列长度的非空顶行列值?
8 回答
如何在excel中选择数据列?
4 回答
如何在Excel中通过脚本自动为一列中的所有单元格创建公共别名
6 回答
如何在excel中高效格式化范围AttributeError:“tuple”对象没有属性“fill”
10 回答
如何在excel单元格中编写python函数
9 回答
如何在excel单元格中自动执行此python代码?
7 回答
如何在excel工作表中创建具有相应值的新列
4 回答
如何在Excel工作表中复制条件为单元格颜色的python数据框?
6 回答
如何在Excel工作表中循环
10 回答
如何在excel工作表中打印嵌套词典?
5 回答
如何在excel工作表中绘制所有类的继承树?
2 回答
如何在Excel工作表中自动调整列宽?
3 回答
如何在excel工作表中追加并进一步处理
1 回答
如何在excel工作表之间进行更改?
9 回答
如何在excel或csv上获取selenium数据?
1 回答
如何在Excel或Python中将正确的值赋给正确的列
10 回答
如何在excel或python中提取单词周围的文本?
9 回答
如何在excel或python中转换来自Jira的3w 1d 4h的fromat数据?
2 回答