我正在使用OPL CPLEX 12.9
我在制定以下约束时遇到问题:
例如,我想获得以下结果
K[i][t] = [0 0 1 0 0 1 1 1 0 0 0 ]
我已经尝试过:
range T = t_min..t_max;
range T1 = t_min-1 ..t_max+1;
dvar boolean K[I][T1];
forall ( i in I, t in T){
ct:
(K[i][t-1]==0) => (K[i][t]== 0) => (K[i][t+1]==1 || K[i][t+1]==0) &&
(K[i][t-1]==1) => (K[i][t]==1 || K[i][t]==0);
但是在结果中,这些副条件被忽略了。我得到的结果是
K[i][t] = [0 0 1 0 1 1 0 0 1 1 0 ]
答案 0 :(得分:0)
我认为您的条件为“如果K [i] [t]为0,那么K [i] [t-1]或K [i] [t + 1]也必须为零”。所以你需要
forall (i in ...) {
(K[i][t_min] == 0) => (K[i][t_min+1] == 0);
(K[i][t_max] == 0) => (K[i][t_max-1] == 0);
forall(t in t_min+1..t_max-1)
(K[i][t] == 0) => ((K[i][t-1] == 0) || (K[i][t+1] == 0));
}