简体   繁体   English

SCIP 的数值问题:相同的问题,不同的最优值

[英]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?应该修改哪些参数来克服这个数值困难?

What I tried我试过的

I've tried the following things and the problem persisted:我尝试了以下方法,但问题仍然存在:

  1. Turning presolving off with model.setPresolve(SCIP_PARAMSETTING.OFF) .使用model.setPresolve(SCIP_PARAMSETTING.OFF)关闭预求解。
  2. Setting 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]

Description of the models型号说明

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.

相关问题 odeint函数中的数值问题取决于初始值 - Numerical issue in odeint function depending on the initial values 在同一图上对分类和数值进行虚拟化 - vizualize categorical and numerical values on the same plot 缩放python中不同组的数值 - scale numerical values for different groups in python 为什么政策迭代和价值迭代方法对于最优价值和最优政策给出不同的结果? - why are policy-iteration and value-iteration methods giving different results for optimal values and optimal policy? 是否可以在文件中添加两行相同的文本,只是数值不同 - Is it possible to add 2 lines of same text just different numerical value in File 使用不同参数值多次运行 python 脚本的最佳方式 - Optimal way to run a python script multiple time with different argument values 将不同列中的列值拆分为 1 或 0 的最佳方法(一种热编码) - optimal way to split values of a column in different columns as 1 or 0 (one hot encoding) 使用熊猫数据框中的不同参考行比较数值 - Compare numerical values using different reference rows in pandas data frame 难以从两个具有相同 class 的 div 中提取数值 - Difficulty Scraping Numerical Values from two divs with the same class 计算问题的最优解 - Optimal Solution for a computation problem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM