我正在进行CPLEX 12.5 v / s CPLEX 12.8的性能比较。我正在使用CPLEX Python(v2.7.15)API来读取<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main-content">
<section id="jumbotron">
<div class="container">
<!-- SOME CONTENT !-->
</div>
</section>
<section id="about">
<div class="container">
<!-- SOME CONTENT !-->
</div>
</section>
<section id="projects">
<div class="container">
<!-- SOME CONTENT !-->
</div>
</section>
<section id="contacts">
<div class="container">
<!-- SOME CONTENT !-->
</div>
</section>
</div>
个文件。我首先对大约32个.sav
文件进行了试运行,其中以下是总解决时间(以秒为单位)的摘要:
.sav
32个CPLEX 12.5: mean = 252.4; median = 127.0; standard deviation = 360.0
CPLEX 12.8: mean = 256.7; median = 129.5; standard deviation = 351.8
文件中只有4个文件CPLEX 12.8花费的时间少于CPLEX 12.5。对于这4个文件,CPLEX 12.8平均减少了4.2秒,而其余28个文件平均花费了5.5秒。正如您在下面的代码中看到的,我只更改了四个参数设置:.sav
以在1小时停止运行时间,timelim_cb.timelimit = 3600
将工作内存设置为64 MB,c.parameters.workmem.set(64)
为压缩并将节点文件存储到磁盘,并c.parameters.mip.strategy.file.set(3)
更改工作目录。
我希望CPLEX 12.8花费更少的时间来解决,但这并没有发生。如果有人可以指出我应该探索哪些额外的参数/设置/想法以便找到我得到的结果的解释,那将是非常有帮助的。我知道CPLEX 12.5的默认c.parameters.workdir.set(r'C:\Users\username\folder')
参数设置为128 MB,CPLEX 12.8的默认workmem
参数设置为2048 MB。我为此设置为64 MB,因为之前对于CPLEX 12.5,我收到了错误:Warning: MIP starts not constructed because of out-of-memory status. Consider decreasing WorkMem parameter value to reduce memory usage. CPLEX Error 1001: Out of memory.
我的笔记本电脑的功能包括:Windows 10,Intel Core i7-6600U @ 2.60GHz,8 GB RAM,64位。
代码:
import cplex
import sys
from cplex.callbacks import MIPInfoCallback
class TimeLimitCallback(MIPInfoCallback):
def __call__(self):
if not self.aborted and self.has_incumbent():
gap = 100.0 * self.get_MIP_relative_gap()
timeused = self.get_time() - self.starttime
if timeused > self.timelimit:
print("Good enough solution at", timeused, "sec., gap =",
gap, "%, quitting.")
self.aborted = True
self.abort()
def solveCplex(filename):
c = cplex.Cplex(filename)
timelim_cb = c.register_callback(TimeLimitCallback)
timelim_cb.starttime = c.get_time()
timelim_cb.timelimit = 3600
timelim_cb.aborted = False
c.parameters.workmem.set(64)
c.parameters.mip.strategy.file.set(3)
c.parameters.workdir.set(r'C:\Users\username\folder')
start_time = timelim_cb.starttime
c.solve()
end_time = c.get_time()
print '\n'+'printing solutions'+'\n'
obj_val = c.solution.get_objective_value()
best_obj_val = c.solution.MIP.get_best_objective()
abs_gap = best_obj_val - obj_val
rel_gap = 100 * c.solution.MIP.get_mip_relative_gap()
sol_time = end_time - start_time
return [obj_val, abs_gap, rel_gap, sol_time]
solveCplex('filename.sav')