Cplex帮助我制定条件约束

时间:2018-05-30 12:56:05

标签: cplex opl

我需要帮助 我怎样才能为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]是已知参数

2 个答案:

答案 0 :(得分:1)

(S[i][t] <=0 ) =>   (S[i][t+1]==S[i][t]-livraison[i][t]+order[i][t]);

问候

答案 1 :(得分:1)

让我们检查一下这段代码

{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