0
votes

I have made a functional mathematical model but I need to get the dual solution as well. I have tried some ways but have not found a way that works for my model.

Here is one of the constraints that I would like to get the dual solution for:

 for(int j=1; j <=Data.FlightCount; j++) { 
              IloLinearNumExpr lhs = cplex.linearNumExpr(); 
              for(int n=1; n <= p; n++) {
                lhs.addTerm(m[n][j], x[n]);        
              }   

              IloRange con = cplex.addEq(lhs, 1);
              con.setName("yourConstraintName(" + j + ")");      
            }

I have tried to do the following to get the dual but i thought that the "con" should go into the dual command but that is not working, any suggestions?

double[] D = cplex.getDuals(con);

Is it maybe possible to get the reduced cost directly, that is without calculating it from the dual myself?

1
It would be helpful to include in the question what "not working" means. - Ali

1 Answers

0
votes

con should be defined as: IloRange[] con;

cSupply[j] = cplex.addEq(lhs, 1);

plus if the model is infeasible, it have no dual, can only get some ray