解决方案不满足某些约束

时间:2017-06-27 08:56:37

标签: cplex

我想用IBM ILOG CPLEX解决一个简单的整数编程问题,我的整个代码如下所示。

在特定数据下,找到了具有目标11,306的解决方案,但某些解决方案不满足特定约束ct2。 我想知道CPLEX是否被认为是最佳解决方案,即使它不满足某些约束,或者我的编码是否有问题?如果您需要,我可以发送数据。我想在这篇文章中附上数据,但找不到办法。

真的希望我能在这里得到一些答案。

int NbGroup = ...;
int NbAutoclave = ...;
int NbTimeslot = ...;
range Group = 1..NbGroup;
range Autoclave = 1..NbAutoclave;
range Timeslot = 1..NbTimeslot;
int MonthlyProduct[Group] = ...;
int CycleTime[Group][Timeslot] = ...;
int CureTime[Group] = ...;
int Compatibility[Group][Autoclave] = ...;



dvar int Assign[Group][Autoclave][Timeslot] in 0..1;


minimize
  sum( g in Group, a in Autoclave, t in Timeslot ) t * Assign[g][a][t];



subject to {


forall (g in Group)
  ct1:
    sum( a in Autoclave, t in Timeslot ) 
        Compatibility[g][a] * Assign[g][a][t] == MonthlyProduct[g]; 


forall (g in Group)
forall (t in 1..NbTimeslot:t in (1..NbTimeslot-CycleTime[g][t]+1))
  ct2:
    sum( a in Autoclave, cy in 1..CycleTime[g][t] )
        Compatibility[g][a] * Assign[g][a][t+cy-1] <= 1;                  


forall( a in Autoclave, t in Timeslot )
  ct3:
    sum( g in Group, cu in 1..CureTime[g]: t-cu+1 in Timeslot)
        Compatibility[g][a] * Assign[g][a][t-cu+1] <= 1; 


  ct4:
    sum( g in Group, a in 1..1, t in 1..7 ) 
        Assign[g][a][t] == 0;

  ct5:
    sum( g in Group, a in 2..2, t in 1..6 ) 
        Assign[g][a][t] == 0;


//to fix some solutions

Assign[9][1][23]==1;
Assign[9][1][95]==1;
Assign[9][1][143]==1;
Assign[9][1][167]==1;
Assign[9][1][239]==1;
Assign[9][1][287]==1;
Assign[9][1][311]==1;


}


tuple SolutionT{ 
    int a;
    int b;
    int c;
    int d; 
};
{SolutionT} Solution = {<a0,b0,c0,Assign[a0][b0][c0]> | a0 in Group, b0 in Autoclave, c0 in Timeslot};
execute{ 
    writeln(Solution);
}

1 个答案:

答案 0 :(得分:0)