如何为 cplex 制定这个条件约束:
if (S[i][t] <=0 ) then S[i][t+1]=S[i][t]-livraison[i][t]+order[i][t]
其中 S[i][t]
和order[i][t]
是决策变量并且
livraison[i][t]
是已知参数
(S[i][t] <=0 ) => (S[i][t+1]==S[i][t]-livraison[i][t]+order[i][t]);
让我们检查一下这段代码
{int} part ={1, 2};
{int} time = {1, 2, 3, 4, 5};
int livraison [part][time] =[[20, 30, 46, 24, 53], [12, 12, 14, 65, 34]];
dvar int S[part][time];
dvar int order[part][time];
int iniS[part] = [0, 0];
int iniorder[part] = [0, 0];
subject to {
forall(i in part, t in time) {
if (t == 1){
S[i][t + 1] == iniS[i]-livraison[i][t]+iniorder[i];
}
else if (t >= 2){
(S[i][t-1] <=0) => (S[i][t] == S[i][t-1]-livraison[i][t-1]+order[i][t-1]);
}
}
}
我希望它可以帮助你,或者查看这个讨论:https ://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014923153