文章目录
- 求解参数设置
- 模型保存
- 模型冲突校验
- pyomo冲突校验
- cplex冲突校验
- docplex冲突校验
- CPLEX 安装包下载
pyomo使用 cplex求解,进行冲突校验
求解参数设置
options = {"timelimit" : 60*60, # 设置求解时间,超过设置时间,求解停止'threads' : 16, # 加速求解,设置并行计算'mipgap' : 1e-3, # 设置求解误差
}
模型保存
model.write(name, format='lp', io_options={'symbolic_solver_labels': True})
symbolic_solver_labels 用于设置保存的模型变量名称为原始变量名称
模型冲突校验
pyomo冲突校验
pyomo/contrib/iis.py(write_iis)
对中文的支持不是很友好,变量名不含中文可以放心使用,含中文建议使用cplex或者docplex
write_iis的用法
Write an irreducible infeasible set for a Pyomo MILP or LPusing the specified commercial solver.Arguments---------pyomo_model:A Pyomo Block or ConcreteModeliis_file_name:strA file name to write the IIS to, e.g., infeasible_model.ilpsolver:strSpecify the solver to use, one of "cplex", "gurobi", or "xpress".If None, the tool will use the first solver available.logger:logging.LoggerA logger for messages. Uses pyomo.contrib.iis logger by default.Returns-------iis_file_name:strThe file containing the IIS.
cplex冲突校验
Writes the conflict to a file.See :cpxapi:`CPXclpwrite` in the Callable Library ReferenceManual.Example usage:>>> import cplex>>> c = cplex.Cplex()>>> out = c.set_results_stream(None)>>> c.read("infeasible.lp")>>> c.conflict.refine(c.conflict.all_constraints())>>> c.conflict.write("conflict.clp")
docplex冲突校验
mdl = read_model("infeasible.lp")
mdl.cplex.conflict.refine(mdl.cplex.conflict.all_constraints())
mdl.cplex.conflict.write("conflict.clp")
CPLEX 安装包下载
可适配python3.7,3.8 ,3.9,3.10
下载地址