How to warm-start pyomo with cplex?

匿名 (未验证) 提交于 2019-12-03 08:57:35

问题:

I am currently using cplex with pyomo from the command line using

pyomo -solver=cplex model.py data.dat

the results are saved in the file results.json. How can I start cplex again using the previous results as a starting solution?

回答1:

If you want to do more advanced things like loading a warmstart it is better to start using Pyomo by writing your own Python scripts. In your case, this might look like:

from pyomo.environ import *  # import the module that contains your model import model  # load the data instance = model.model.create_instance('data.dat')  # create a solver cplex = SolverFactory("cplex")  # solve the first time (tee=True prints the cplex output) status = cplex.solve(instance, tee=True) assert str(status.solver.termination_condition) == 'optimal'  # solve the model a second time and create a warmstart file for cplex status = cplex.solve(instance, warmstart=True, tee=True) 

See the scripting section of the online Pyomo docs for more on this.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!