Ampl Indexing expressions using colons error: variable in such-that part of set specification

1.2k views Asked by At

I'm trying to figure out why I get this error in one of my constraints.

The line is as follows:

subject to resource1{t in time: operation[1,1,t]= 1}:
    sum {p in plane, m in t..(t+process_time[p,1])} 
         (operation[p,1,m] + operation[p,8,m]) <= 1;

This is pretty much saying that for all time where the binary variable "operation" = 1, which means that operation is using a particular machine/resource at given time t, no other operation must start until that operation is done processing.

1

There are 1 answers

0
vitaut On

You can't use variables in indexing expressions in AMPL. If you are using CPLEX, you can formulate this as an indicator constraint instead:

subject to resource1{t in time}:
    operation[1,1,t] = 1 ==> sum {p in plane, m in t..(t+process_time[p,1])} 
         (operation[p,1,m] + operation[p,8,m]) <= 1;

Alternatively, you can use some kind of a Big M formulation.