sam
sam

Reputation: 41

Dual of a constraint

I am trying to find the dual values of a constraint for the code enclosed herewith. I have only mentioned the constraint whose dual I want to find. How do I find the dual of the constraint6 as mentioned in the code?

int NbJobs=10;
int NbMachines=2;

range Job=1..NbJobs;
range Machine= 1..NbMachines;

int JobProcessTime[Job]=...;
int JobReadyTime[Job]=...;
int JobSize[Job]=...;
int JobDueDate[Job]=...;
int MachineCapacity[Machine]=...;

float E=99999;
float e=.000001;
float Dual1[Job]=...;
tuple Batches{
    key int id;
    int BatchSetup[Job];
    float BatchReadyTime;
    float BatchProcessTime;
}
{Batches} BatchConfig=...;

dvar boolean NbTardy[Job];
dvar boolean BatchSelected[BatchConfig][Machine];
dvar float+ BatchCompletionTime[BatchConfig][Machine];
dvar float+ JobCompletionTime[Job];

minimize sum(j in Job) NbTardy[j];
subject to {
    forall (j in Job, b in BatchConfig, m in Machine) Constraint6: JobCompletionTime[j]>= BatchCompletionTime[b][m]- E*(1-b.BatchSetup[j]*BatchSelected[b][m]);
}

Upvotes: 0

Views: 362

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10062

Since your model is a MIP, you cannot get that dual value directly.

See technote http://www-01.ibm.com/support/docview.wss?uid=swg21399941

At https://www.ibm.com/developerworks/community/forums/html/topic?id=978e90f6-8fc5-4be7-a306-df9bdb4a4754&ps=25 I posted an example:

dvar int x in 0..10;
dvar float y in 0..10;

minimize x+y;
subject to {
  ctx :   
    x >= 1/2;
  cty:
    y>=1/2;
}

main {
  var status = 0;
  thisOplModel.generate();
  if (cplex.solve()) {
    writeln("Integer Model");   
    writeln("OBJECTIVE: ",cplex.getObjValue());   
    writeln("dual CTX:",thisOplModel.ctx.dual);
    writeln("dual CTY:",thisOplModel.cty.dual);
  }
  var xvalue=thisOplModel.x.solutionValue;

  thisOplModel.convertAllIntVars();
  thisOplModel.x.UB=xvalue;
  thisOplModel.x.LB=xvalue;
  if (cplex.solve()) {
    writeln("Relaxed Model");   
    writeln("OBJECTIVE: ",cplex.getObjValue());  
    writeln("dual CTX:",thisOplModel.ctx.dual);
    writeln("dual CTY:",thisOplModel.cty.dual);
  }

} 

that gives

Integer Model
OBJECTIVE: 1.5
dual CTX:undefined
dual CTY:undefined
Relaxed Model
OBJECTIVE: 1.5
dual CTX:0
dual CTY:1

Upvotes: 2

Related Questions