Configuring a solver
The Xpress executable used by the example above is contained in the Xpress distribution. For other solvers please follow these steps:
- Download a solver executable working with the NL format
- for example: http://ampl.com/products/solvers/open-source
- Make sure the solver executable is on the PATH
- for example, same location as amplxpress[.exe]
(bin subdirectory of Xpress installation) - alternatively, specify NL_SOLVERPATH
- for example, same location as amplxpress[.exe]
- Configure your model to use the solver:
- NL_SOLVER always needs to be set
- use NL_SOLVERPATH if
- the solver executable is not on the path, or
- the executable name is different from the solver prefix in NL_SOLVER, or
- the executable requires additional options (define a batch script)
- optional: define specific solver settings in NL_OPTIONS
Here are some configuration examples for nlsolv controls under Windows:
- Xpress Optimizer (LP, MIP, QCQP)
setparam("NL_SOLVER", "xpress") setparam("NL_SOLVERPATH", "amplxpress.exe")
- Knitro (requires a separate license, NLP)
setparam("NL_SOLVER", "knitro") setparam("NL_SOLVERPATH", "knitroampl.exe")
- Cplex (requires a separate license, LP, MIP, QCQP)
setparam("NL_SOLVER", "cplex") setparam("NL_SOLVERPATH", "cplexamp.exe")
- ipopt (NLP)
setparam("NL_SOLVER", "ipopt")
- cbc (NLP)
setparam("NL_SOLVER", "cbc") setparam("NL_SOLVERPATH", "cbc.bat") ! Contents: cbc %3 -AMPL