I am trying to use AMPL to run a single model several times. All variables and parameters have a time dimension as well, since their values change with each iteration of the model.
I have defined the model using the problem statement in order to be able to solve it iteratively.
problem MIQP_Complex_CR{t in T}: Dev,
{i in A} dx[i,t], {i in A} dy[i,t], {i in A} uarg[i,t],
{i in A} larg[i,t],{(i,j) in P} vrx[i,j,t],
{(i,j) in P} vry[i,j,t], {(i,j) in P} z[i,j,t],
{(i,j) in P} bin11[i,j,t], {(i,j) in P} bin12[i,j,t],
{(i,j) in P} bin311[i,j,t], {(i,j) in P} bin312[i,j,t],
{(i,j) in P} bin321[i,j,t], {(i,j) in P} bin322[i,j,t],
{(i,j) in P} bin331[i,j,t], {(i,j) in P} bin332[i,j,t],
{(i,j) in P} bin341[i,j,t], {(i,j) in P} bin342[i,j,t],
{(i,j) in P} cvrx[i,j,t], {(i,j) in P} cvry[i,j,t];
There is a set A of numbers 1..n. Set P is simply members of A ordered as i,j in A with i less than j. There are some constraints (such as bin311
above) which are only to be activated when the variables satisfy certain conditions. So, each constraint will be invoked for only some of the variables. For instance,
s.t. bin342{(i,j) in P, t in T : xrRoll[i,j,t] < 0 and yrRoll[i,j,t] < 0} : -2*a[i,j,t]*vrx[i,j,t] + vry[i,j,t]*(c[i,j,t] + sqrt(c[i,j,t]**2 - 4*a[i,j,t]*b[i,j,t])) <= z[i,j,t]*Mbin342[i,j,t];
So, if the condition is not satisfied by a member of P, then the constraint should not be switched on for that member. The problem is this – in this series of constraints of the binxyz
series, the last constraint(and only this one) is activated regardless of whether the members of P satisfy the condition or not. Since there is always one pair (i,j) in P which will not satisfy it, this shows an ‘invalid subscript’ error for that constraint for that pair of set P.
This always happens with the last constraint, and the first member of P which is unable to satisfy the condition on this constraint. If I change the order of the constraints in the model definition, then the last one gives the error. If I comment out some of the constraints, then too the last active one gives the error. Only if I remove all binxyz
constraints is the problem solved, but obviously not as accurately as I desire. Please help.
Thanks!