2
$\begingroup$

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?

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];
$\endgroup$
2
  • $\begingroup$ The first way looks correct to me. What happens if you execute expand pi;? $\endgroup$
    – RobPratt
    Dec 31, 2020 at 5:38
  • 1
    $\begingroup$ Missing comma between the bounds? $\endgroup$ Dec 31, 2020 at 19:51

2 Answers 2

1
$\begingroup$

I am going to answer my own question. After I made the post, I realized the variable pi actually don't show up in the model though declared. It looks like this is the reason why the first way doesn't take effective in the 'solve' process while the second explicit way works.

$\endgroup$
1
  • $\begingroup$ After presolve, these two formulations should result in the same variables with the same bounds being sent to the solver. It's very likely that there is a simple explanation for why you're getting a wrong solution with the first formulation, but it's not possible to find the explanation given only the information provided. In this situation, I recommend providing complete model and data files, so that pi's definition can be seen in context. $\endgroup$
    – 4er
    Jan 15, 2021 at 14:17
0
$\begingroup$

According to section 14-1 of AMPL book:

For continuous variables, normally AMPL passes to solvers the first set of bounds, but you can instruct it to pass the second set by changing option var_bounds to 2 from its default value of 1. When active-set methods (like the simplex method) are applied, the second set tends to give rise to more degenerate variables, and hence more degenerate iterations that may impede progress toward a solution.

Reference: https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf

$\endgroup$
2
  • $\begingroup$ I don't think this quote about original versus presolved bounds is relevant to the question. The variables should respect the lower and upper bounds whether they are specified in the VAR statement or via explicit constraints. $\endgroup$
    – RobPratt
    Dec 31, 2020 at 17:21
  • $\begingroup$ Thanks @RobPratt but I think this is a way to define both upper and lower bounds for the variables if I understood the question correctly. $\endgroup$ Dec 31, 2020 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.