Presolve error handling

36 views
Skip to first unread message

Peter Greistorfer

unread,
Apr 18, 2018, 2:50:53 PM4/18/18
to AMPL Modeling Language
Hello all!

Running AMPL with CPLEX from the console, I'm asking myself how error handling can be implemented in a run-file. Regarding AMPL's presolve: how can an error (e.g. "impossible deduced bounds") be intercepted (I mean, once it happened) in order to initialize a reasonable backtracking (e.g. in order to reverse a wrong fixing)? More or less the same functionality provided by CPLEX's solve_result or solve_result_num.

I'm really curious ...

AMPL Google Group

unread,
Apr 18, 2018, 4:23:26 PM4/18/18
to Ampl Modeling Language
AMPL provides command to modify data and model from the run file. You can read more about it https://ampl.com/BOOK/CHAPTERS/14-command.pdf. For your specific problem:

Let's say you have a model file as follows:

param lb;
var x>=lb,<=1;

minimize f: x;

lb is a param that I am going to set from the run file. In run file, I will have something as follows:

model dummy.mod;
let lb :=3;
solve;
if solve_result_num >=200 and solve_result_num <= 299 then let lb:=1;
solve;

Initially, I assigned lb = 3, so that x>=3,<=1, and the problem will be infeasible. I could detect the infeasibility in the presolve phase by comparing the solve_result_num. You can find about the status code at https://ampl.com/NEW/statuses.html. After detecting the infeasibility, I could use the modeling commands to change the data.

Thanks,
Paras

--
Paras Tiwari
am...@googlegroups.com
{#HS:564068131-5541#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



Peter Greistorfer

unread,
Apr 20, 2018, 3:53:06 PM4/20/18
to AMPL Modeling Language
Thanks, Paras, I understand, but what I wanted to achieve, was the detection of an AMPL-presolve-error without invoking CPLEX via solve ...(?)

AMPL Google Group

unread,
Apr 20, 2018, 11:18:47 PM4/20/18
to Ampl Modeling Language
The solve command invokes AMPL presolve and sends the problem to CPLEX only if the problem passes the presolve phase. You can read about presolve at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf .

--
Paras Tiwari
am...@googlegroups.com
{#HS:564068131-5541#}
On Fri, Apr 20, 2018 at 7:53 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Thanks, Paras, I understand, but what I wanted to achieve, was the detection of an AMPL-presolve-error without invoking CPLEX via solve ...(?)



On Wed, Apr 18, 2018 at 8:21 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL provides command to modify data and model from the run file. You can read more about it https://ampl.com/BOOK/CHAPTERS/14-command.pdf. For your specific problem:

Let's say you have a model file as follows:

param lb;
var x>=lb,<=1;

minimize f: x;

lb is a param that I am going to set from the run file. In run file, I will have something as follows:

model dummy.mod;
let lb :=3;
solve;
if solve_result_num >=200 and solve_result_num <= 299 then let lb:=1;
solve;

Initially, I assigned lb = 3, so that x>=3,<=1, and the problem will be infeasible. I could detect the infeasibility in the presolve phase by comparing the solve_result_num. You can find about the status code at https://ampl.com/NEW/statuses.html. After detecting the infeasibility, I could use the modeling commands to change the data.

Thanks,
Paras

--
Paras Tiwari
am...@googlegroups.com


AMPL Google Group

unread,
Apr 21, 2018, 9:51:05 AM4/21/18
to Ampl Modeling Language
AMPL's presolve procedure does set solve_result and solve_result_num appropriately when it finds that there is no solution possible. Here is a simple example:

ampl: solve;
presolve, variable Buy['FISH']:
impossible deduced bounds: lower = 105, upper = 100;
difference = 5

ampl: display solve_result,solve_result_num;
solve_result = infeasible
solve_result_num = 299

The same solve_result and solve_result_num values are set when presolve returns a "constraint . . . cannot hold" message. Are you encountering a situation where presolve reports infeasibility but your script cannot detect infeasibility by testing solve_result and solve_result_num?

--
Robert Fourer
am...@googlegroups.com
{#HS:564068131-5541#}
On Sat, Apr 21, 2018 at 3:18 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The solve command invokes AMPL presolve and sends the problem to CPLEX only if the problem passes the presolve phase. You can read about presolve at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf .

--
Paras Tiwari
am...@googlegroups.com


On Fri, Apr 20, 2018 at 7:53 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Thanks, Paras, I understand, but what I wanted to achieve, was the detection of an AMPL-presolve-error without invoking CPLEX via solve ...(?)



On Wed, Apr 18, 2018 at 8:21 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL provides command to modify data and model from the run file. You can read more about it https://ampl.com/BOOK/CHAPTERS/14-command.pdf. For your specific problem:

Let's say you have a model file as follows:

param lb;
var x>=lb,<=1;

minimize f: x;

lb is a param that I am going to set from the run file. In run file, I will have something as follows:

model dummy.mod;
let lb :=3;
solve;
if solve_result_num >=200 and solve_result_num <= 299 then let lb:=1;
solve;

Initially, I assigned lb = 3, so that x>=3,<=1, and the problem will be infeasible. I could detect the infeasibility in the presolve phase by comparing the solve_result_num. You can find about the status code at https://ampl.com/NEW/statuses.html. After detecting the infeasibility, I could use the modeling commands to change the data.

Thanks,
Paras

--
Paras Tiwari
am...@googlegroups.com


Peter Greistorfer

unread,
Apr 22, 2018, 2:37:16 PM4/22/18
to AMPL Modeling Language
Alright, well, these were precious hints and - not surprisingly - you're right: solve_result[_num] actually monitor(s) all my problems, those of presolve and those of CPLEX. In the presolve-case I always get a "solve_result = infeasible, solve_result_num = 299.00" and in the CPLEX-case a "suffix dunbdd OUT; solve_result = infeasible, solve_result_num = 210.00". So, explicitly answering Robert's question: all the cases recognized so far can be detected by those two parameters. That's good, now I can focus on my constraint-ignorance.

Thank you both, have a nice little weekend left and a good start in a new week,

Peter 


On Saturday, April 21, 2018 at 3:51:05 PM UTC+2, AMPL Google Group wrote:
AMPL's presolve procedure does set solve_result and solve_result_num appropriately when it finds that there is no solution possible. Here is a simple example:

ampl: solve;
presolve, variable Buy['FISH']:
impossible deduced bounds: lower = 105, upper = 100;
difference = 5

ampl: display solve_result,solve_result_num;
solve_result = infeasible
solve_result_num = 299

The same solve_result and solve_result_num values are set when presolve returns a "constraint . . . cannot hold" message. Are you encountering a situation where presolve reports infeasibility but your script cannot detect infeasibility by testing solve_result and solve_result_num?

--
Robert Fourer
am...@googlegroups.com
{#HS:564068131-5541#}
On Sat, Apr 21, 2018 at 3:18 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The solve command invokes AMPL presolve and sends the problem to CPLEX only if the problem passes the presolve phase. You can read about presolve at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf .

--
Paras Tiwari
am...@googlegroups.com


On Fri, Apr 20, 2018 at 7:53 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Thanks, Paras, I understand, but what I wanted to achieve, was the detection of an AMPL-presolve-error without invoking CPLEX via solve ...(?)
...
Reply all
Reply to author
Forward
0 new messages