【问题标题】:Convert AMPL to CPLEX将 AMPL 转换为 CPLEX
【发布时间】:2020-09-11 20:49:13
【问题描述】:

以下约束是在 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];

【问题讨论】:

标签: cplex ampl


【解决方案1】:
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 中工作正常

【讨论】:

    猜你喜欢
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    • 1970-01-01
    相关资源
    最近更新 更多