我想在cplex中找到约束的对偶

时间:2018-10-08 15:12:17

标签: cplex opl

找到约束的对偶的方法如下:

    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.

2 个答案:

答案 0 :(得分:0)

让我从OPL目录中的volsay例子中给您一个小例子。

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);

}

给出

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

答案 1 :(得分:-1)

使用3D,您只需索引:

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);
}