AMPLS-API is an open source set of lightweight interfaces between AMPL and solvers, which allow:
- Read in an AMPL model instance from an
NL
file - Write out the solution as a
sol
file, ready to be imported by AMPL - A choice between:
- Use of all the solver's capabilities, using its own C API functionalities
- Use of a (provided) generic interface, that encapsulates the most common functionalities of the solver interfaces, permitting hassle-free solver swap
- Usage of existing AMPL licenses, when used together with the AMPL drivers
The interfaces are available for multiple languages; the core is written in C++ and it is wrapped using swig to other target languages.
- Gurobi
- CPLEX
- XPRESS
- Copt
-
Example: Jupyter Notebook with TSP Example
-
More examples:
- PyPI Repository for amplpy-gurobi: https://pypi.python.org/pypi/amplpy-gurobi
- PyPI Repository for amplpy-cplex: https://pypi.python.org/pypi/amplpy-cplex
Install from the PyPI repositories:
$ python -m pip install amplpy-gurobi amplpy-cplex
Note: For Windows, Linux, and macOS, the python packages come with binary wheels for many Python versions and platforms. Please make sure that you are using the latest version of pip
before installing them (upgrade using pip install pip --upgrade
or python -m pip install pip --upgrade
). If a binary wheel for your platform or python version is not available, a C++ compiler and python development libraries will be required.
BSD-3
Copyright © 2020-2021 AMPL Optimization inc. All rights reserved.