cplexampl

Convert AMPL to CPLEX


The following constraints are written in the AMPL environment and I want to convert it to a 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];

Solution

  • 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;
    
    
     
    } 
    

    works fine in OPL CPLEX