[AMPL 24623] Variables in the upper limit of the set

Dear Robert:
I have a problem that I don’t know how to describe in ampl language.
m[i,k] denotes the number of grids taken by vehicle i in the kth step, k ∈ {0,… ,K}, and I want to implement the constraint in ampl that the vehicle walks all the meshes in the least number of steps, A being the number of grids.
when vehicle i walks through all the grids, i.e. sum{i in CARS, k in T[i]. .k_x}m[i,k]=A, k_x is minimum. But here k ∈ {T[i]. .k_x} where k_x is a variable and cannot be used as the upper limit of the set.
Thank you very much for your time and assistance.
Best regards.
liufan

As you have observed, you cannot sum over {i in CARS, k in T[i]. .k_x} where k_x is a variable. You would need to reformulate this in some other way, most likely using some additional zero-one variables and additional constraints.

This is a general mathematical formulation problem rather than specifically an AMPL issue. Thus, to get help, I suggest that you ask your question on the Operations Research StackExchange site, where there are many questions about formulating optimization problems, and usually they are answered pretty quickly.