pyomo使用cplex求解,进行冲突校验

本文介绍了如何在Pyomo中设置求解参数、模型保存策略,并讨论了CPLEX在冲突校验方面的使用方法,包括pyomo/contrib/iis.py、cplex的conflict.write以及docplex的冲突处理。还提供了CPLEX的安装包下载链接。
摘要由CSDN通过智能技术生成


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 LP
    using the specified commercial solver.
  Arguments
    ---------
        pyomo_model:
            A Pyomo Block or ConcreteModel
        iis_file_name:str
            A file name to write the IIS to, e.g., infeasible_model.ilp
        solver:str
            Specify the solver to use, one of "cplex", "gurobi", or "xpress".
            If None, the tool will use the first solver available.
        logger:logging.Logger
            A logger for messages. Uses pyomo.contrib.iis logger by default.

    Returns
    -------
        iis_file_name:str
            The file containing the IIS.

cplex冲突校验

Writes the conflict to a file.

    See :cpxapi:`CPXclpwrite` in the Callable Library Reference
    Manual.

    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
下载地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hengley

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值