【问题标题】:How to warm-start pyomo with cplex?如何用 cplex 热启动 pyomo?
【发布时间】:2017-07-08 21:45:10
【问题描述】:

我目前正在使用

从命令行使用 cplex 和 pyomo

pyomo -solver=cplex model.py data.dat

结果保存在文件results.json 中。 如何使用以前的结果作为起始解决方案再次启动 cplex?

【问题讨论】:

    标签: cplex pyomo


    【解决方案1】:

    如果您想做更高级的事情,例如加载热启动,最好通过编写自己的 Python 脚本来开始使用 Pyomo。在您的情况下,这可能如下所示:

    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)
    

    有关更多信息,请参阅在线 Pyomo 文档的 scripting 部分。

    【讨论】:

      猜你喜欢
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 2021-08-07
      • 1970-01-01
      • 2021-01-27
      • 2017-09-18
      • 2021-06-13
      相关资源
      最近更新 更多