Search
Close this search box.

AMPL APIs

Our APIs ensure that you have a reliable and maintainable implementation as you embed your optimization models into applications.

About AMPL APIs

Our comprehensive Application Programming Interface (API) provides an object-oriented callable library that lets you access AMPL models and run AMPL commands from external programs. Data and results can be exchanged directly and efficiently between AMPL’s model entities and the external language’s data structures. Uses include:

Deployment of AMPL models

Embedding AMPL in enterprise applications

Programming complex algorithmic schemes

Getting Started

Our instructions add AMPL API to an existing installation of command-line AMPL and solvers, after which you will be able to access AMPL from any popular version of your chosen language. Contact us at support@ampl.com if you need help completing the AMPL or API setup. 

Who can access AMPL APIs?

AMPL API works with any purchased AMPL installation covered by current a maintenance & support service, and also with all trial and temporary versions. Contact us at licensing@ampl.com if you need help with reinstatement of maintenance or renewal of licenses.

Once you have installed your API you will find our extensive API documentation hosted on our documentation site. Use the links below to navigate to the pages you need. 

Introduction

AMPL API is an interface that allows developers to access the features of the AMPL interpreter from within a programming language.

Getting Started

The AMPL API can function as an add-on to any existing AMPL installation.

Class Structure

AMPL API library consists of a collection of classes to interact with the underlying AMPL interpreter and to access its inputs and outputs. It uses generic collections to represent the various entities which comprise a mathematical model. The structure of these entities is explained in this section. 

Quick Start

These links will show a simple example to illustrate various functionalities. The full example prints the version of the AMPL interpreter used, loads a model from file and the corresponding data file, solves it, gets some of the AMPL entities in your programming language and uses them to get the results and to assign data programmatically. The documentation in this section assumes that you are already familiar with the programming language you select. 

API Reference

All functions and classes provided by the AMPL API are described in this section.

API Examples

This section lists a few examples in your selected programming language. These are the same files that can be found in the examples directory of the distribution, and show the basic usage of the API.

Need more support? Contact us.

Check out all technical documentation here.

Join the conversation on the AMPL forum.