sam
sam

Reputation: 41

I want to find the dual of a constraint in cplex

what is the way to find the dual for a constraint which is given below:

    forall(t in tree, p in Pattern, m in Machine) Constraint1:
    TreeCutTime[t]>=BatchCutTime[p][m] - 1000(1- 
    p.BatchSetup[t]*BatchSelected[p][m])

where, 
Range of t = 1..10
Range of m = 1..2
Pattern = <1 [1 0 0 0 0 0 0 0 0 0], 5,5> and so on
BatchSelected= [1 0 0 0 0 0 0 0 0 0] and so on.

Upvotes: 0

Views: 373

Answers (2)

Alex Fleischer
Alex Fleischer

Reputation: 10062

with 3D you only need to index:

dvar float+ Gas[1..2][1..2][1..2];
dvar float+ Chloride[1..2][1..2][1..2];

dvar float obj;
maximize
 obj; 
subject to {
ctObj:obj==sum(i,j,k in 1..2 )(40 * Gas[i,j,k])  + sum(i,j,k in 1..2 ) (50 * Chloride[i,j,k]);

  forall(i,j,k in 1..2) ctMaxTotal:     
    Gas[i,j,k] + Chloride[i,j,k] <= 50;
  forall(i,j,k in 1..2 )ctMaxTotal2:    
    3 * Gas[i,j,k] + 4 * Chloride[i,j,k] <= 180;
  forall(i,j,k in 1..2 ) ctMaxChloride:  
    Chloride[i,j,k] <= 40;
}

execute
{
writeln("Chloride=",Chloride);
writeln("Gas=",Gas);
writeln("dual=",ctMaxTotal[1][2][1].dual);
}

Upvotes: -1

Alex Fleischer
Alex Fleischer

Reputation: 10062

let me give you a small example out of the volsay example that is in the OPL directory.

dvar float+ Gas;
dvar float+ Chloride;


maximize
  40 * Gas + 50 * Chloride;
subject to {
  ctMaxTotal:     
    Gas + Chloride <= 50;
  ctMaxTotal2:    
    3 * Gas + 4 * Chloride <= 180;
  ctMaxChloride:  
    Chloride <= 40;
}

execute
{
writeln(ctMaxTotal.dual);
writeln(ctMaxTotal2.dual);
writeln(ctMaxChloride.dual);

}

which gives

// solution (optimal) with objective 2300
10
10
0

Upvotes: 0

Related Questions