Hints for using Xpress solver in PYOMO

933 views
Skip to first unread message

Marc Meketon

unread,
Feb 7, 2018, 11:19:03 AM2/7/18
to Pyomo Forum
I now have a couple of hints about how to call the FICO Xpress solver from PYOMO, based on the thread https://groups.google.com/d/msg/pyomo-forum/0PyZk8THFkQ/V2OaH9rUBgAJ

This is in a separate post to make it easier to find.

  • The general way to call Xpress is through the 'nl' (aka AMPL) interface.  Note the use of the LOGFILE parameter
import pyomo.environ as pm
import pyomo.opt     as po
model
model = pm.ConcreteModel()
...
opt = po.SolverFactory("amplxpress")
opt.options["LOGFILE"]="CON:"  # The only way to see output from the optimizer.  For *NIX, try "/dev/stdout"
opt.options["GOMCUTS"]=0       # sample option
opt.options["TREECOVERCUTS"]=0 # sample option
opt.options["MAXTIME"]=600     # sample option
opt.options["MIPRELSTOP"]=0.01 # sample option
results = opt.solve(model, tee=True)


  • The set of parameters available for amplxpress is slightly different than for the normal xpress.  For example, OUTPUTLOG and HEURSEARCHROOTCUTFREQ, both available from the "normal" Xpress optimizer, are not available with amplxpress.  AMPL does document the available parameters at this link:
  • According to the PYOMO developers, when the optimizer stops due to time limit, it issues a warning.  Apparently this is true for 'nl' interfaces.  So that means to check if the solver returned a solution, you will need to check to see if a solution exists (I'm not sure how -- maybe a PYOMO developer could reply) and to check
    results.solver.status == po.SolverStatus.warning

Gabriel Hackebeil

unread,
Feb 7, 2018, 12:06:51 PM2/7/18
to pyomo...@googlegroups.com
Hi Marc,

Thanks for posting this info.

  • The general way to call Xpress is through the 'nl' (aka AMPL) interface.
Do you know if setting this option is also required to see output when amplxpress is used in AMPL? If not, maybe we should set it automatically.
  • The set of parameters available for amplxpress is slightly different than for the normal xpress.  For example, OUTPUTLOG and HEURSEARCHROOTCUTFREQ, both available from the "normal" Xpress optimizer, are not available with amplxpress.
Ipopt has similar behavior in that not all options can be set through the command-line for the ASL-compile executable. It exposes these to users by allowing them to be set in an options file that contains lines of the form:

option_name option_value

It will automatically pick up a file named ‘ipopt.opt’ in the working directory, but you can override that via the “option_file_name” command-line option. To make this easier to deal with, we recently added functionality to our ipopt solver interface to automatically write options beginning with “OF_” to a temporary options file that we automatically set on the command-line if any of these options exist.

Perhaps amplxpress does something similar with an options file. If so, let us know and we can add functionality to our Xpress solver interface to do the same.
  • So that means to check if the solver returned a solution, you will need to check to see if a solution exists 
The way to do this is to set load_solutions=False, and then check if the 'solution' attribute of the results object is empty or not.

from pyomo.opt import SolverStatus
results = opt.solve(model, load_solutions=False)
if len(results.solution):
    # the solution is stored in results.solution(0)
    # solvers that return multiple solutions would place them
    # in solution(0), solution(1), …
    # (but I don’t think we have any that do that yet)

    # check if we want to disable the warning
    # before loading the solution (e.g., because of a time limit)
    if <something about the results>:
        results.solver.status = SolverStatus.ok
    model.solutions.load_from(results)
else:
    # the solver did not return a solution

Gabe

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Meketon

unread,
Feb 7, 2018, 12:27:58 PM2/7/18
to Pyomo Forum
Thank you Gabe.

(1) I don't have AMPL so I cannot check if this needs to be set when calling from AMPL

(2) For the most part, a parameter in the normal "xpress" optimizer does have a counterpart. I asked FICO/Xpress about a couple of them. HEURSEARCHROOTSELECT in the normal xpress is HEURROOT for amplxpress,  HEURSEARCHROOTCUTFREQ is called HEURROOTCUTFREQ.  I don't know if there is an options file setting, but that should be explored.

Siirola, John D

unread,
Feb 8, 2018, 12:23:40 AM2/8/18
to pyomo...@googlegroups.com

For what it’s worth, AMPL documents the set of XPRESS options available through the command line here:  https://ampl.com/products/solvers/solvers-we-sell/xpress/options/

 

They unfortunately do not indicate if a supplementary options file is also available.

 

john

--

Fabio Leimgruber

unread,
Jan 22, 2019, 4:44:10 PM1/22/19
to Pyomo Forum
On Thursday, February 8, 2018 at 6:23:40 AM UTC+1, Siirola, John D wrote:

For what it’s worth, AMPL documents the set of XPRESS options available through the command line here:  https://ampl.com/products/solvers/solvers-we-sell/xpress/options/


How are options passed which are of the "no-assignment" type, e.g. the option "iis" in the quoted link?

Marc Meketon

unread,
Jan 22, 2019, 7:08:30 PM1/22/19
to pyomo...@googlegroups.com
Try:

opt = SolverFactory("amplxpress")
opt.options["iis"] = ''



--
You received this message because you are subscribed to a topic in the Google Groups "Pyomo Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyomo-forum/VRO3dURqNC8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyomo-forum...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages