[英]Numerical issue with SCIP: same problem, different optimal values
I'm having the following numerical issue while using SCIP solver as a callable library via PySCIPOpt
:通过
PySCIPOpt
使用 SCIP 求解器作为可调用库时,我遇到了以下数值问题:
two equivalent and almost identical models for the same problem yield different optimal values and optimal solutions, with optimal values having a relative difference of order 1e-6
同一问题的两个等效且几乎相同的模型产生不同的最优值和最优解,最优值具有 1e-6 阶的相对差异
An independent piece of software verified that the solutions yielded by both models are feasible for the original problem and that their true values agree with the optimal values reported by SCIP for each model .一个独立的软件验证了两个模型产生的解决方案对于原始问题是可行的,并且它们的真实值与 SCIP 报告的每个 model 的最佳值一致。 Until the appearance of this instance a bunch of instances of the same problem had been solved, with both models always agreeing on their optimal solutions and values.
在这个实例出现之前,已经解决了相同问题的一堆实例,两个模型总是就它们的最优解和值达成一致。
Is it possible to modify the numerical precision of SCIP for comparing the values of primal solutions among them and against dual bounds?是否可以修改 SCIP 的数值精度以比较它们之间的原始解决方案的值以及对偶边界的值? Which parameters should be modified to overcome this numerical difficulty?
应该修改哪些参数来克服这个数值困难?
I've tried the following things and the problem persisted:我尝试了以下方法,但问题仍然存在:
model.setPresolve(SCIP_PARAMSETTING.OFF)
.model.setPresolve(SCIP_PARAMSETTING.OFF)
关闭预求解。model.setParam('numerics/feastol', epsilon)
with different values of epsilon
.epsilon
值设置model.setParam('numerics/feastol', epsilon)
。 Since feasible sets and objective functions agree (see description below), I've checked that the actual coefficients of the objective functions agree by calling model.getObjective()
and comparing coefficients for equality for each variable appearing in the objective function.由于可行集和目标函数一致(见下文描述),我通过调用
model.getObjective()
并比较目标 function 中出现的每个变量的相等系数来检查目标函数的实际系数是否一致。
The only thing that seemed to help was to add some noise (multiplying by numbers of the form 1+eps
with small eps
) to the coefficients in the objective function of the model yielding the worst solution.唯一似乎有帮助的是在 model 的目标 function 的系数中添加一些噪声(乘以
1+eps
和小eps
形式的数字),从而产生最差的解决方案。 This makes SCIP to yield the same (and the better) solution for both models if eps
is within certain range.如果
eps
在一定范围内,这使得 SCIP 为两个模型产生相同(并且更好)的解决方案。
Just in case, this is what I get with scip -v
in the terminal:以防万一,这是我在终端中使用
scip -v
得到的:
SCIP version 6.0.2 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: SoPlex 4.0.2] [GitHash: e639a0059d]
SCIP 版本 6.0.2 [精度:8 字节] [内存:块] [模式:优化] [LP 求解器:SoPlex 4.0.2] [GitHash:e639a0059d]
Model (I) has approximately 30K binary variables, say X[i]
for i
in some index set I
. Model (I) 有大约 30K 二进制变量,例如
X[i]
for i
in some index set I
。 It's feasible and not a hard MIP.这是可行的,而不是硬 MIP。
Model (II) is has the same variables of model (I) plus ~100 continuous variables, say Y[j]
for j
in some index set J
. Model (II) 具有与 model (I) 相同的变量加上 ~100 个连续变量,例如
Y[j]
for j
in some index set J
。 Also model (II) has some constraints like this X[i_1] + X[i_2] +... + X[i_n] <= Y[j]
. model (II) 也有一些约束,例如
X[i_1] + X[i_2] +... + X[i_n] <= Y[j]
。
Both objective functions agree and depend only on X[i]
variables, the sense is minimization.两个目标函数一致并且仅依赖于
X[i]
变量,意思是最小化。 Note that variables Y[j]
are essentially free in model (II), since they are continuous and they do not appear in the objective function.请注意,变量
Y[j]
在 model (II) 中基本上是自由的,因为它们是连续的并且它们不会出现在目标 function 中。 Obviously, there is no point in including the Y[j]
variables, but the optimal values shouldn't be different.显然,包含
Y[j]
变量没有意义,但最佳值不应该不同。
Model (II) is the one yielding the better (ie smaller) value. Model (II) 是产生更好(即更小)值的那个。
sorry for the late answer.抱歉回复晚了。 So, in general, it can definitely happen that any MIP solver reports different optimal solutions for formulations that are slightly perturbed (even if they are mathematically the same), due to the use of floating-point arithmetic.
因此,一般来说,由于使用了浮点运算,任何 MIP 求解器肯定会为稍微扰动的公式(即使它们在数学上相同)报告不同的最优解。
Your problem does seem a bit weird though.不过,您的问题确实有点奇怪。 You say the Y-variables are free, ie they do not have any variable bounds attached to them?
您说 Y 变量是免费的,即它们没有附加任何变量边界? If this is the case, I would be very surprised if they don't get presolved away.
如果是这种情况,如果他们没有被预先解决,我会感到非常惊讶。
If you are still interested in this problem, could you provide your instance files to me and I will look at them?如果您仍然对这个问题感兴趣,能否将您的实例文件提供给我,我会查看它们?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.