【问题标题】:update RHS on a constraint in scip using python使用python更新scip中约束的RHS
【发布时间】:2017-06-01 13:28:01
【问题描述】:

有没有什么好的解决方案来更新约束的 rhs?最好我想做类似的事情:

    import pyscipopt as scp
    Mod=scp.Model()
    x=Mod.addVar(ub=3,name="x")
    y=Mod.addVar(ub=4,name="y")
    c=Mod.addCons(x+y<=2,"C1")
    Mod.setObjective(0.5*x+0.3*y, "maximize")
    Mod.optimize()
    print(Mod.getObjVal())
    c.updateRHS(4) # This function does not exist..
    Mod.optimize()
    print(Mod.getObjVal())

【问题讨论】:

  • 我刚刚在相应的 GitHub 项目中为此创建了一个新问题:github.com/SCIP-Interfaces/PySCIPOpt/issues/64
  • 我想对于这种情况,你会做更多,例如,保持上一次迭代的最佳解决方案(因为你放松了你的约束)
  • 谢谢马特!鉴于您的拉取请求解决了我的问题,我可以将您的回答标记为已接受。

标签: python-3.5 scip


【解决方案1】:

此问题已在最新版本的 PySCIPOpt 中得到修复(请参阅 https://github.com/SCIP-Interfaces/PySCIPOpt/pull/70

这些方法称为chgLhs()chgRhs()。请记住,它们目前仅适用于线性和二次约束。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多