In order to download the language, go to AMPL’s download a free demo page. Scroll down the page to where it says AMPL Command Line download for Windows. Download the zipped file ampl.mswin64.zip for the 64-bit version.

Step 2: Install AMPL

On your PC, unzip and extract the folder ampl.mswin64 from the zip file you downloaded.

To start an AMPL command interface session, you’ll need to double-click on the sw.exe icon in your AMPL folder. In the command interface, type ampl. Press Enter. You’ll see ampl: This prompt means that you can now type AMPL commands.

Step 3: Write a Model in AMPL

To write our model, let's define the variables, write an expression to be minimised and, finally, set some constraints. For a quick model set-up, copy and paste the snippet below into the system prompt.

var x1 := 1;
var x2 := 1;
var x3;
var x4 := 1;
var x5;
minimize Expression: 42*x1 - 0.5*(100*x1*x1 + 100*x2*x2 + 100*x3*x3 + 100*x4*x4 + 100*x5*x5) + 44*x2 + 45*x3 + 47*x4 + 47.5*x5;
subject to Constraint: 20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40;
subject to x1_lim: 0 <= x1 <= 1;
subject to x2_lim: 0 <= x2 <= 1;
subject to x3_lim: 0 <= x3 <= 1;
subject to x4_lim: 0 <= x4 <= 1;
subject to x5_lim: 0 <= x5 <= 1;

Step 4: Set the Number of Cores (optional)

To make Octeract Engine solve in parallel, enter

options octeract_options 'num_cores=4';

where 4 can be any number of cores offered by your subscription.

Step 5: Solve the Model

At the system prompt, where AMPL is running, call the solver to solve the problem. After running these commands, the problem will be processed and you'll see the solution. To display the new variable values on screen, use the display command.

If successful, it will print out the optimal solution for your model.

And that’s it - you’re done!
You've just solved an optimisation problem using AMPL.

AMPL on Linux

Before reaching this guide, you’ll have:

installed the Engine.

installed your authentication token.

Step 1: Launch a Terminal

Open your terminal of choice. You can search for “terminal” in your start menu or try shortcut ctrl+shift+t.

Step 2: Download AMPL

In order to download the language, go to AMPL's download a free demo page. Scroll down the page to where it says AMPL Command Line download for Linux. Download the distribution archive ampl.linux64.tgz for a 64-bit version.

Step 3: Install AMPL

In the terminal use the command in the snippet below to extract the contents of the downloaded file.. Once the extraction is complete, a directory named ampl.linux64 will be created. Start an AMPL command interface session by using the cd command to go to the AMPL directory. Type ./ampl at the system prompt and you'll see ampl: which means you can now type AMPL commands.

tar xzf ampl.linux64.tgz

Step 4: Write a Model in AMPL

To write our model, let's define the variables, write an expression to be minimised and, finally, set some constraints. For a quick model set-up, copy and paste the snippet below into the system prompt.

var x1 := 1;
var x2 := 1;
var x3;
var x4 := 1;
var x5;
minimize Expression: 42*x1 - 0.5*(100*x1*x1 + 100*x2*x2 + 100*x3*x3 + 100*x4*x4 + 100*x5*x5) + 44*x2 + 45*x3 + 47*x4 + 47.5*x5;
subject to Constraint: 20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40;
subject to x1_lim: 0 <= x1 <= 1;
subject to x2_lim: 0 <= x2 <= 1;
subject to x3_lim: 0 <= x3 <= 1;
subject to x4_lim: 0 <= x4 <= 1;
subject to x5_lim: 0 <= x5 <= 1;

Step 5: Set the Number of Cores (optional)

To make Octeract Engine solve in parallel, enter

options octeract_options 'num_cores=4';

where 4 can be any number of cores offered by your subscription.

Step 6: Solve Your Model

At the system prompt, where AMPL is running, call the solver to solve the problem. You'll need to provide the whole path where the Engine is installed. After running these commands, the problem will be processed and you'll see the solution.

option solver "<path/to/octeract-engine>";

Where <path/to/octeract-engine> is the path to where Octeract Engine was installed on your PC. For example, if it was installed in /usr/bin/ then the command would look like this: option solver "/usr/bin/octeract-engine";

solve;

To display the new variable values on screen, use the display command.

display x1, x2, x3, x4, x5;

If successful, it will print out the optimal solution for your model.

And that’s it - you’re done!
You've just solved an optimisation problem using AMPL.