[英]CPLEX obtain reduced costs of a MIP?
I am solving a MIP problem using CPLEX.我正在使用 CPLEX 解决 MIP 问题。 After solving it, I want to get the reduced costs.
解决之后,我想降低成本。 I am aware of the fact that reduced costs don't exist for the MIP, so I did the following:
我知道 MIP 不存在降低成本的事实,因此我执行了以下操作:
int type = CPXgetprobtype(env, lp);
if(CPXchgprobtype(env, lp, CPXPROB_FIXEDMILP)) abort();
if(CPXlpopt(env,lp)) abort();
int blabla; double blublu;
if(CPXsolution (env, lp, &blabla , &blublu , x, pi, slack, dj)) abort();
for (int i = 0; i < CPXgetnumcols(env,lp); i++) {
printf("v%d = %f, ", i,dj[i]);
if ((i+1) % 10 == 0) printf("\n");
}
if(CPXchgprobtype(env, lp, type)) abort();
When I print the array dj, it's all 0's.当我打印数组 dj 时,它都是 0。 I also tried using
CPXgetdj
instead of CPXsolution
, with the same result.我还尝试使用
CPXgetdj
而不是CPXsolution
,结果相同。
After reading this I believe what I am doing is correct.阅读本文后,我相信我所做的是正确的。 Yet it does not seem to work.
然而它似乎不起作用。 My problems have 20000 variables, and I have tried with a bunch of them and it always says 0...
我的问题有 20000 个变量,我尝试了很多变量,但它总是说 0 ...
I have a small time limit, so it does not prove optimality (but it does find an integer solution), I'm not sure if this matter.我有一个很小的时间限制,所以它不能证明是最优的(但它确实找到了一个整数解),我不确定这是否重要。
Thanks谢谢
Consider a general linear problem P where all variables are fixed at the value of the integer optimal solution of a given integer problem I .考虑一个一般线性问题P ,其中所有变量都固定为给定整数问题I的整数最优解的值。 Let P be
让P成为
where the overlined bj is the value of xj in the optimal integer solution.其中上划线的 bj 是最优整数解中 xj 的值。 The dual problem D of P is
P 的对偶问题D是
The optimal solution of D of cost z( D ) = z( P ) = z( I ) could be found setting可以找到代价 z( D ) = z( P ) = z( I ) 的D的最优解
thus the reduced costs are因此降低的成本是
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.