将AMPL转换为CPLEX

问题描述

以下约束是在AMPL环境中编写的,我想将其转换为CPLEX吗?

subject to ex_one{b in B}: sum{t in T: t >= early[b]} y[b,t] <= 1;

#subject to most_one{tt in T,b not in BT[tt]}: sum{t in T} y[b,t] <= 1;

subject to grade1{t in T}: G_min*sum{b in B: early[b] <= t}(if g[b] > total[b] then 
total[b] else 0)*y[b,t] <= sum{b in B: early[b] <=t}(if g[b] > total[b]  then g[b] else 
0)*y[b,t];

解决方法

range B=1..4;
range T=1..3;
{int} BT[t in T]=asSet(1..t);
int early[b in B]=b;

dvar boolean y[B][T];

subject to
{

forall(b in B)ex_one: sum(t in T: t >= early[b]) y[b,t] <= 1;

forall(tt in T,b in B:b not in BT[tt]) mostone: sum(t in T) y[b,t] <= 1;


 
} 

在OPL CPLEX中工作正常