You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法从SCIP求解器获取对偶值问题求助

SCIP求解LP问题时约束对偶值全为0的问题

我正在使用SCIP求解LP问题,需要获取每个约束的对偶值,已经关闭了所有预求解设置,但调用model.getDualsolLinear(i)获取对偶值时,返回结果始终为0。

示例LP文件

\   Problem name     : RMP
\   Variables        : 3 (0 binary, 0 integer, 0 implicit integer, 3 continuous)
\   Constraints      : 3
Minimize
 Obj: +2 x_0_0 +3 x_0_1 +1 x_0_2
Subject to
 c1: +1 x_0_0 = +7
 c2: +1 x_0_1 = +2
 c3: +1 x_0_2 = +1
Bounds
End

预期约束c1、c2、c3的对偶变量值分别为2、3、1,但实际得到的都是0。

Python求解代码

from pyscipopt import Model

model = Model()
model.readParams("simplescipproblem/settings.set")
model.readProblem(filename="rmp.lp")
model.optimize()
obj = model.getObjVal()
print(f"obj: {obj}")
prices = []
print(f"Cons: {model.getConss()}")
for i in model.getConss():
    prices.append(model.getDualsolLinear(i))
print(f"prices: {prices}")

SCIP配置文件(settings.set)

# SCIP version 9.2.1

# maximal number of presolving rounds (-1: unlimited, 0: off)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/maxrounds = 0

# maximal number of restarts (-1: unlimited)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/maxrestarts = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/nonlinear/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/linear/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/and/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/bounddisjunction/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/cardinality/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/conjunction/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/cumulative/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/disjunction/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/indicator/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/knapsack/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/linking/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/logicor/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/or/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/orbisack/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/orbitope/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/pseudoboolean/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/setppc/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/SOS1/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/SOS2/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/superindicator/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/symresack/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/varbound/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/xor/maxprerounds = 0

# maximal number of presolving rounds the constraint handler participates in (-1: no limit)
# [type: int, advanced: TRUE, range: [-1,2147483647], default: -1]
constraints/components/maxprerounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/milp/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/trivial/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/inttobinary/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/gateextraction/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/dualcomp/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/domcol/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/implics/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/sparsify/maxrounds = 0

# maximal number of presolving rounds the presolver participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
presolving/dualsparsify/maxrounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/rootredcost/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/dualfix/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/genvbounds/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/vbounds/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/pseudoobj/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/redcost/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/probing/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/symmetry/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/obbt/maxprerounds = 0

# maximal number of presolving rounds the propagator participates in (-1: no limit)
# [type: int, advanced: FALSE, range: [-1,2147483647], default: -1]
propagating/nlobbt/maxprerounds = 0

propagating/maxrounds = 0
propagating/maxroundsroot = 0

环境信息

  • 操作系统:MacOS15.3.1(Linux环境下结果一致)
  • SCIP版本:9.2.1
  • pyscipopt版本:5.3.0

恳请各位提供帮助,谢谢!

内容的提问来源于stack exchange,提问作者jeff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 06:19:51