AMPL doesn't allow variables in subscripts yet. However there is a way to emulate them. For example, M1[a] >= 10
can be emulated as follows:
s.t. c: exists{i in A} (M1[i] >= 10 and i = a);
This is not very efficient, but should work fine for small problems. Note that to solve a problem containing the above constraint (or variables in subscripts once they are added) requires a constraint programming solver such as ilogcp or gecode. See LOGIC AND CONSTRAINT PROGRAMMING EXTENSIONS for details.
New version of ilogcp driver for AMPL supports the element
constraint, for example:
include cp.ampl;
var x{i in 0..2} >= i integer;
var y in 0..2 integer;
minimize o: element({i in 0..2} x[i], y);
option solver ilogcp;
solve;
where element({i in 0..2} x[i], y)
is equivalent to x[y]
and is translated into an IloElement
constraint.