AMPL Presolve phase

43 views
Skip to first unread message

Samuele Viaro

unread,
Jul 15, 2022, 10:11:34 AM7/15/22
to AMPL Modeling Language
Hello!
I have a model in which, for a particular case, the presolve phase found an infeasibility of this kind:
presolve, constraint sc[2,1]:
 all variables eliminated, but upper bound = -1 < 0

I tried to turn off presolve using   option presolve 0, and I the solver found an feasible solution!  My question is, does anyone know why?? Is there a possible issue with my mathematical model??

Keeping presolve on does slow down my simulations in all other cases except the one in which I found an infeasibility...but  I cannot afford to have no simulation at all!!

Thanks in advance!!

Have a nice day


AMPL Google Group

unread,
Jul 16, 2022, 2:32:10 AM7/16/22
to AMPL Modeling Language
There are some tests that need to be run to determine whether your problem is actually infeasible as presolve says, or is actually feasible as the solver says. Once that is known, it will be possible to determine whether some fix is needed in AMPL or the AMPL-solver interface, or whether you need some different presolve settings.

Can you provide a complete example (with model and data) that shows the behavior that you are describing? Then we can run the tests quickly.


--
Robert Fourer
am...@googlegroups.com
{#HS:1950247029-111001#}

Samuele Viaro

unread,
Jul 18, 2022, 11:31:38 AM7/18/22
to am...@googlegroups.com
Hi, here attached are the data you requested.
Thanks for the help

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/7BZaplNudjs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1950247029-5780564019-1657953125-34887743%40helpscout.net.
dataIn.dat
schedule_7.cpp
dynamic.mod

AMPL Google Group

unread,
Jul 20, 2022, 3:31:05 AM7/20/22
to AMPL Modeling Language
We will need your help to get a "snapshot" of the model and data at the point where the presolve issue occurs. This can be done by running your C++ program again after adding a few statements:

1. Check that you have an executable on your computer for "x-ampl", which is a special version of the "ampl" executable that includes the snapshot feature.

2. In place of "ampl::AMPL ampl;" use the following statements to select the x-ampl executable:

ampl::Environment env("", "x-ampl");
ampl::AMPL ampl(env);


3. After "ampl.solve();" add the following statements to save a snapshot file when the infeasible case occurs:

if (ampl.getValue("solve_result").str() == "infeasible") {
ampl.eval("snapshot > snapshot.run;")
*** STOP ***
}


Here *** STOP *** should be replaced by appropriate C++ statements to exit the loops and end the run.

After running this modified version, you will have a file "snapshot.run" that you can send to us and that we can use to reproduce the presolve issue.


--
Robert Fourer
am...@googlegroups.com
{#HS:1950247029-111001#}
On Mon, Jul 18, 2022 at 3:31 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi, here attached are the data you requested.
Thanks for the help

On Sat, Jul 16, 2022 at 6:31 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
There are some tests that need to be run to determine whether your problem is actually infeasible as presolve says, or is actually feasible as the solver says. Once that is known, it will be possible to determine whether some fix is needed in AMPL or the AMPL-solver interface, or whether you need some different presolve settings.

Can you provide a complete example (with model and data) that shows the behavior that you are describing? Then we can run the tests quickly.


--
Robert Fourer
am...@googlegroups.com

Samuele Viaro

unread,
Jul 21, 2022, 5:18:34 AM7/21/22
to am...@googlegroups.com
Hello,
in the ampl directory I only have the ampl executable. Where can I download the x-ampl executable from?
Thanks
Sam

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/7BZaplNudjs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.

AMPL Google Group

unread,
Jul 21, 2022, 8:27:33 AM7/21/22
to AMPL Modeling Language
The easiest way is to log in to your account at the AMPL Download Portal, then select "My Downloads" from the menu. The links to the x-ampl downloads are near the bottom of the page. Place the downloaded executable (named x-ampl or x-ampl.exe) in the same folder/directory as your current ampl executable.

Alternatively, after logging in to the Portal you can scroll down to "AMPL & Solvers bundle" and download the "command line bundle" for your platform. Then unpack it and move the x-ampl executable over to the same folder/directory as your current ampl executable.


--
Robert Fourer
am...@googlegroups.com
{#HS:1950247029-111001#}
On Thu, Jul 21, 2022 at 9:18 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello,
in the ampl directory I only have the ampl executable. Where can I download the x-ampl executable from?
Thanks
Sam

On Wed, Jul 20, 2022 at 7:30 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
We will need your help to get a "snapshot" of the model and data at the point where the presolve issue occurs. This can be done by running your C++ program again after adding a few statements:

1. Check that you have an executable on your computer for "x-ampl", which is a special version of the "ampl" executable that includes the snapshot feature.

2. In place of "ampl::AMPL ampl;" use the following statements to select the x-ampl executable:

ampl::Environment env("", "x-ampl");
ampl::AMPL ampl(env);


3. After "ampl.solve();" add the following statements to save a snapshot file when the infeasible case occurs:

if (ampl.getValue("solve_result").str() == "infeasible") {
ampl.eval("snapshot > snapshot.run;")
*** STOP ***
}


Here *** STOP *** should be replaced by appropriate C++ statements to exit the loops and end the run.

After running this modified version, you will have a file "snapshot.run" that you can send to us and that we can use to reproduce the presolve issue.


--
Robert Fourer
am...@googlegroups.com

Samuele Viaro

unread,
Jul 22, 2022, 10:30:40 AM7/22/22
to am...@googlegroups.com
Hello,
I tried running the code with x-ampl as you specified but I get an error:
error running cplex
        termination code 9

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/7BZaplNudjs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.

AMPL Google Group

unread,
Jul 22, 2022, 1:39:24 PM7/22/22
to AMPL Modeling Language
The "termination code 9" can happen with any solver. It indicates that the solver failed to start, or crashed while running, but it does not give any more specific information than that.

Normally this error is not affected by the choice of AMPL version. Can you answer a few more questions that will help to clarify the situation?

1. If you replace


ampl::Environment env("", "x-ampl");

by

ampl::Environment env("", "ampl");

and run again, do you get a the same CPLEX error?

2. Does the error occur at the first solve, or are there some successful solves before the error occurs?

3. Which platform (Windows, Linux, MacOS) are you using?

4. Did you install a new copy of CPLEX at the same time that you added x-ampl?


--
Robert Fourer
am...@googlegroups.com
{#HS:1950247029-111001#}
On Fri, Jul 22, 2022 at 2:30 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello,
I tried running the code with x-ampl as you specified but I get an error:
error running cplex
termination code 9

On Thu, Jul 21, 2022 at 12:27 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The easiest way is to log in to your account at the AMPL Download Portal, then select "My Downloads" from the menu. The links to the x-ampl downloads are near the bottom of the page. Place the downloaded executable (named x-ampl or x-ampl.exe) in the same folder/directory as your current ampl executable.

Alternatively, after logging in to the Portal you can scroll down to "AMPL & Solvers bundle" and download the "command line bundle" for your platform. Then unpack it and move the x-ampl executable over to the same folder/directory as your current ampl executable.


--
Robert Fourer
am...@googlegroups.com

Samuele Viaro

unread,
Jul 26, 2022, 7:44:16 AM7/26/22
to am...@googlegroups.com
Hello!
To answer your  questions:
1) if I replace "x-ampl" with "ampl" I do get the same error.
2) The error occurs at first solve
3) I'm using Linux
4) No

However I noticed that this error appears when I try to simulate a bigger case than the previous one in which I had problems.
In this case it seems that the problem is when I try to initialize a very large array...I'm working on it!

I was able to run the previous case and get the snapshot.run file (attached)...

Thanks a lot for your help!


--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/7BZaplNudjs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.

AMPL Google Group

unread,
Jul 27, 2022, 5:49:07 PM7/27/22
to AMPL Modeling Language
After loading the snapshot, I do see that presolve determines infeasibility with a lot of "all variables eliminated" messages:

ampl: solve;
presolve, constraint con10[1,13,1,14,1,1]:
	all variables eliminated, but lower bound = 37.6437 > 0
presolve, constraint con10[1,12,1,14,1,1]:
	all variables eliminated, but lower bound = 47.5927 > 0
presolve, constraint con10[1,12,1,13,1,1]:
	all variables eliminated, but lower bound = 37.9127 > 0
presolve, constraint con10[1,11,1,14,1,1]:
	all variables eliminated, but lower bound = 49.4163 > 0
presolve, constraint con10[1,11,1,13,1,1]:
	all variables eliminated, but lower bound = 39.7363 > 0
72 presolve messages suppressed.

I looked more closely at con10[1,13,1,14,1,1], which is mentioned in the first message. It is as follows:

subject to con10[1,13,1,14,1,1]: 
   t[1,14] - t[1,13] >= 
      alpha[1,13,1,14,1,1] - M * (3 - z[1,13,1] - z[1,14,1] - y[1,13,1,14]);

According to the snapshot, however, at this point t[1,13] and t[1,14] have been fixed to 0, and y[1,13,1,14] has been fixed to 1:

ampl: display t[1,13].lb, t[1,13].ub;
t[1,13].lb = 0
t[1,13].ub = 0

ampl: display t[1,14].lb, t[1,14].ub;
t[1,14].lb = 0
t[1,14].ub = 0

ampl: display y[1,13,1,14].lb, y[1,13,1,14].ub;
y[1,13,1,14].lb = 1
y[1,13,1,14].ub = 1

Also the parameters in the constraint are as follows:

ampl: display alpha[1,13,1,14,1,1], M, z[1,13,1], z[1,14,1];
alpha[1,13,1,14,1,1] = 37.6437
M = 1e+06
z[1,13,1] = 1
z[1,14,1] = 1

Thus the constraint reduces to 0 >= 37.6437, which correctly flagged as infeasible by presolve. But also, when I set "option presolve 0" before solving, CPLEX reports that the problem is infeasible:

ampl: option presolve 0;
ampl: solve;
CPLEX 20.1.0.0: return_mipgap 1
...
Infeasibility row 'c2310220':  0 >= 39.9277.
...
CPLEX 20.1.0.0: integer infeasible.

So, I have not been able to reproduce the behavior you were seeing, where turning off presolve led to CPLEX reporting a feasible solution. When you turned off presolve, did you set "option presolve 0;" before the main loop in your program? In that case, the sequence of subproblems might not have been the same (for example, due to some subproblems having more than one optimal solution) and as a result the runs with and without presolve might not be comparable.

In any case, this example appears to be a true infeasibility, which might be due to an error in your procedure, or might be something that your procedure needs to handle specially.


--
Robert Fourer
am...@googlegroups.com
{#HS:1950247029-111001#}
On Tue, Jul 26, 2022 at 11:44 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello!
To answer your questions:
1) if I replace "x-ampl" with "ampl" I do get the same error.
2) The error occurs at first solve
3) I'm using Linux
4) No

However I noticed that this error appears when I try to simulate a bigger case than the previous one in which I had problems.
In this case it seems that the problem is when I try to initialize a very large array...I'm working on it!

I was able to run the previous case and get the snapshot.run file (attached)...

Thanks a lot for your help!
Sam
On Fri, Jul 22, 2022 at 5:39 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The "termination code 9" can happen with any solver. It indicates that the solver failed to start, or crashed while running, but it does not give any more specific information than that.

Normally this error is not affected by the choice of AMPL version. Can you answer a few more questions that will help to clarify the situation?

1. If you replace

ampl::Environment env("", "x-ampl");

by

ampl::Environment env("", "ampl");

and run again, do you get a the same CPLEX error?

2. Does the error occur at the first solve, or are there some successful solves before the error occurs?

3. Which platform (Windows, Linux, MacOS) are you using?

4. Did you install a new copy of CPLEX at the same time that you added x-ampl?


--
Robert Fourer
am...@googlegroups.com

Samuele Viaro

unread,
Jul 28, 2022, 10:51:10 AM7/28/22
to am...@googlegroups.com
Ok!
I'll work on the procedure...
Thanks a lot for your help!!
Samuele

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/7BZaplNudjs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages