# AMPL Gurobi Define Variables Bounds

I am trying to define both upper and lower bounds for a vector of variables in AMPL (solver Gurobi). However, after solving to optimal solution, the variables violate the bounds. The only way these bounds work is defined as explicit constraint in AMPL through the 'subject to' clause. Any idea why AMPL doesn't accept the bounds defined in the first way? Thanks.

The first way:

var pi{t in 1..T} >= lb_pi[t] <= ub_pi[t];


The explicit way:

subject to C_pi_low{t in 1..T}:
pi[t] >= lb_pi[t];

subject to C_pi_up{t in 1..T}:
pi[t] <= ub_pi[t];

• The first way looks correct to me. What happens if you execute expand pi;? – RobPratt Dec 31 '20 at 5:38
• Missing comma between the bounds? – Erwin Kalvelagen Dec 31 '20 at 19:51