[AMPL 24598] variable in lower bound of range set

Dear AII,

I hope this email finds you well. I am writing to ask for your help with a problem I am facing in my work. Specifically, I am having trouble with the variable in the lower bound of a range set problem.

The specific constraint is as follows:

subject to move_forward {i in CARS, k in K_i[i]} :
   sum{j in p[i,k] .. p[i,k]+m[i,k]-1} x[i,k,j] = m[i,k];

where p[i,k] and m[i,k] are variables, and x[i,k,j] is a 0-1 variable.

When I run this program, ampl will prompt me variable in lower bound of range set, how can I solve this problem. I would greatly appreciate any guidance or advice you could offer on this matter. Please let me know if you have any questions or if there is any additional information I can provide.

Thank you very much for your time and assistance.

Best regards,

liufan

I hope this helps! Let me know if you have any other questions.

When using any of the popular MIP solvers (CPLEX, Gurobi, Xpress, COPT, CBC, HiGHS, etc.) that work with 0-1 variables, AMPL must send the solver a complete list of the nonzero coefficients of the variables. Consequently, these solvers cannot work with a summation over a set like p[i,k]..p[i,k]+m[i,k]-1 which depends on knowing the values of the variables.

Here’s an outline of one possible alternative. Sum over the set of all possible j values; I don’t know what that set is in your model, so I will call it J:

 subject to move_forward {i in CARS, k in K_i[i]} :
   sum {j in J} x[i,k,j] = m[i,k];

Then add some constraints to say that:

  • if j < p[i,k] then x[i,k,j]=0
  • if j > p[i,k]+m[i,k]-1 then x[i,k,j]=0

Or equivalently,

  • if x[i,k,j]=1 then p[i,k]<=j
  • if x[i,k,j]=1 then p[i,k]+m[i,k]-1>=j

When using most MIP solvers, this can actually be written directly in AMPL by using the ==> operator that means “implies”:

subject to UpperBound  {i in CARS, k in K_i[i], j in J}:
   x[i,k,j]=1 ==> p[i,k] <= j; 
subject to LowerBound  {i in CARS, k in K_i[i], j in J}:
   x[i,k,j]=1 ==> p[i,k]+m[i,k]-1 >= j;

The attached file varinsub.mod contains the example that I used for some tests.

Are you actually trying to say that x[i,j,k] should be 1 for all j values from p[i,k] to p[i,k]+m[i,k]-1, and 0 for all other j values? There might be other ways to linearize that; I think there was some discussion of similar problems on Operations Research Stack Exchange.

1 Like

See the answer in our new, enhanced user forum:
https://discuss.ampl.com/t/ampl-24598-variable-in-lower-bound-of-range-set/469

Thank you very much for your answer. I have solved my problem according to your method, which is very important to me. Your answer has solved the problem that has plagued me for a long time, so that my research can continue to advance. Thank you again.