"Presolve constraint cannot hold" -> I want to output data to a file in this case.

867 views
Skip to first unread message

leoniet...@gmail.com

unread,
May 17, 2016, 3:47:49 PM5/17/16
to AMPL Modeling Language
I'm going through several thousand iterations of my model each time it runs and due to the input data there are some infeasibilities and some "presolve: constraint cannot hold"/"all variables eliminated" errors that occur.
I currently note which iteration failed due to an actual infeasibility using this code in my script:

if match (solve_message, "infeasible") > 0 then {
 print "start:end, year, Problem?" , Start, End, CurrentYear, "- infeasible -" > SolverErrorOut.out;
          #break;
}

That works well. However I ALSO want to output some sort of note when the presolve has a fit. I tried the code below and it told me that "presolve_message" is not defined (which makes sense I guess...). Can anyone tell me what it is likely to output when this happens? Currently I'm thinking that at this point it throws caution to the wind and violates constraints at random so I want to filter these results out of my final dataset...

              if match (presolve_message, "all variables eliminated") > 0 then {
 print "start:end, year, Problem?" , Start, End, CurrentYear, "- infeasible -\n" > PreSolveErrorOut.out;
          #break;
      }

Thank you to anyone who knows more than I do!  :)

Robert Fourer

unread,
May 18, 2016, 10:48:42 AM5/18/16
to am...@googlegroups.com
When presolve finds there is no solution possible, a message to that effect is assigned to the built-in parameter solve_message:

ampl: display solve_message;
solve_message = 'presolve finds no feasible solution possible'

(You are correct that the infeasible solution that results at this point cannot be assumed to have any particular properties.) I see you are already testing solve_message, but "infeasible" does not appear in this particular message. A more robust test for infeasibility is

if solve_result = "infeasible" > 0 then { ...

However you still need to test solve_message to determine whether infeasibility was determined by presolve.

Bob Fourer
am...@googlegroups.com

=======

leoniet...@gmail.com

unread,
May 18, 2016, 6:28:38 PM5/18/16
to AMPL Modeling Language, 4...@ampl.com
Thank you!! I'll try this out tomorrow!
Here is a follow up question - in the ampl terminal window it will throw up messages like: "Presolve: Constraint _____ cannot hold". Is it possible to grab the name of the failed constraint somehow? I was planning to just remove all failed scenarios from my dataset but knowing what failed would be really useful too.

Thank you again for your help :)

Victor Zverovich

unread,
May 19, 2016, 12:28:17 PM5/19/16
to am...@googlegroups.com
You can print the constraint name with the following AMPL command:

  print _sconname[n];

where n is the constraint index given by the solver.

HTH,
Victor

--
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.

Robert Fourer

unread,
May 23, 2016, 9:08:38 PM5/23/16
to am...@googlegroups.com
The messages from presolve are not placed in a param where an AMPL script could access them and extract information. The only way to record them is by setting "option log_file ..." but then they are just all part of the overall log file for the session.

If it would be more helpful to have the infeasibility information from the solver, it is possible to set "option presolve 0;" in which case it will be left to the solver to do all of the presolving.
Reply all
Reply to author
Forward
0 new messages