Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Toy AMPL Driver
C Makefile
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
src
.gitignore
Makefile
README.rst

README.rst

MiniAMPL

A toy AMPL driver to demonstrate usage of the AMPL Solver Library and to get you going with the writing of your own AMPL driver.

Installing

First install the AMPL Solver Library. We recommend using Homebrew or Linuxbrew:

brew tap homebrew/science
brew install asl

Next, compile the miniampl executable by typing make.

Example

Once the miniampl executable is created, the following demonstrates how to call it from the command line. A test example is supplied in wb.mod and wb.dat. To generate the test example afresh, execute ampl wb.ampl. You can obtain the student edition of AMPL from www.ampl.com. But to save you time, I'v also packaged the nl file in the example folder.

[dpo@pod:miniampl (master)]$ ./bin/miniampl examples/wb    # Only print objective value
f(x0) = -2.000000000000000e+00

[dpo@pod:miniampl (master)]$ ./bin/miniampl -=    # Show available options
showgrad  Evaluate gradient
showname  Display objective name

[dpo@pod:miniampl (master)]$ ./bin/miniampl examples/wb showname=1
showname=1
Objective name: objective
f(x0) = -2.000000000000000e+00

[dpo@pod:miniampl (master)]$ ./bin/miniampl examples/wb showname=1 showgrad=1
showname=1
showgrad=1
Objective name: objective
f(x0) = -2.000000000000000e+00
g(x0) = [  1.0e+00  0.0e+00  0.0e+00 ]

What Next?

Writing AMPL drivers is best learned by example. Look through the examples that come with the AMPL Solver Library and keep http://www.ampl.com/REFS/HOOKING at hand as a reference.

Good luck. dominique.orban@gerad.ca

Bitdeli badge
Something went wrong with that request. Please try again.