2

I am solving a MIP problem using CPLEX. 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:

     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. I also tried using CPXgetdj instead of CPXsolution, with the same result.

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...

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

excalibur1491
  • 1,201
  • 2
  • 14
  • 29
  • Do you get the same behavior if you try with the interactive as described [here](http://www-01.ibm.com/support/docview.wss?uid=swg21400009)? – rkersh Oct 11 '16 at 00:06
  • Thanks for the tip. I just tried. When "write solution" of the MIP, there is no dual information about constraints nor reduced costs values for variables. Then I type "change problem fix", solve again, save solution again and this time all the constraints have a dual value (non 0) but all the variables have a reduced cost of 0. So I guess my C code was not wrong? How come the reduced costs are 0? Seems very odd. Also, what information does the dual of a constraint give me? (I'm new to optimization...) Thanks! – excalibur1491 Oct 11 '16 at 01:28
  • Can it matter the fact that all my equations are equations, and no inequations? – excalibur1491 Oct 11 '16 at 01:29

1 Answers1

1

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. Let P be

enter image description here

where the overlined bj is the value of xj in the optimal integer solution. The dual problem D of P is

enter image description here

The optimal solution of D of cost z(D) = z(P) = z(I) could be found setting

enter image description here

thus the reduced costs are

enter image description here

acco93
  • 128
  • 2
  • 11