Date: 2010-02-14 11:57:00

# `BONMIN` Users' Manual

Introduction | Download | Install | Use | Setting Options | Options List | Bibliography |

- Bonmin
- Wiki
- NEOS
- IBM-CMU OCR
- IBM MINLP
- COIN-OR Home
- Projects
- FAQs
- Download
- Mailing Lists
- Get Involved
- Related Resources
- COIN-OR Foundation
- Events
- Members

## Running BONMIN

On an .nl file / From Ampl / priorities and SOS in Ampl / From GAMS / From a C++ Programm /

#### References

1 Writing .nl files. D.M. Gay.

2 AMPL: A Modeling Language for Mathematical Programming, Second Edition, Duxbury Press Brooks Cole Publishing Co., 2003. R. Fourer and D.M. Gay and B.W. Kernighan.

### Running BONMIN

BONMIN can be run

- from a command line on a .nl file (see [Gay2005] ),
- from the modeling language Ampl (see [Fourrer2003] ),
- from the Gams modeling language,
- by invoking it from a C/C++ program.
- remotely through the NEOS web interface.

In this page, we give some details about the various ways to run BONMIN.

### On a .nl file

BONMIN can read a .nl file which could be generated by Ampl (for example mytoy.nl in the Bonmin-dist/Bonmin/test subdirectory). The command line takes just one argument which is the name of the .nl file to be processed.

For example, if you want to solve mytoy.nl, from the Bonmin-dist directory, issue the command:

bonmin test/mytoy.nl

### From Ampl

To use BONMIN from Ampl you just need to have the directory where the bonmin executable is in your $PATH and to issue the command

option solver bonmin;

in the Ampl environment. Then the next solve will use BONMIN to solve the model loaded in Ampl. After the optimization is finished, the values of the variables in the best-known or optimal solution can be accessed in Ampl. If the optimization is interrupted with <CTRL-C> the best known solution is accessible (this feature is not available in Cygwin).

### Example Ampl model

simple Ampl example model follows:

# An Ampl version of toy reset; var x binary; var z integer >= 0 <= 5; var y{1..2} >=0; minimize cost: - x - y[1] - y[2] ; subject to c1: ( y[1] - 1/2 )^2 + (y[2] - 1/2)^2 <= 1/4 ; c2: x - y[1] <= 0 ; c3: x + y[2] + z <= 2; option solver bonmin; # Choose BONMIN as the solver (assuming that # bonmin is in your PATH solve; # Solve the model display x; display y;

(This example can be found in the subdirectory Bonmin/examples/amplExamples/ of the BONMIN package.)

### Setting up branching priorities, directions and declaring SOS1 constraints in ampl

Branching priorities, branching directions and pseudo-costs can be passed using Ampl suffixes. The suffix for branching priorities is "priority" (variables with a higher priority will be chosen first for branching), for branching direction is "direction" (if direction is 1 the ≥ branch is explored first, if direction is -1 the ≤ branch is explored first), for up and down pseudo costs "upPseudoCost" and "downPseudoCost" respectively (note that if only one of the up and down pseudo-costs is set in the Ampl model it will be used for both up and down).

For example, to give branching priorities of 10 to variables y and 1 to variable x and to set the branching directions to explore the upper branch first for all variables in the simple example given, we add before the call to solve:

suffix priority IN, integer, >=0, <= 9999; y[1].priority := 10; y[2].priority := 10; x.priority := 1; suffix direction IN, integer, >=-1, <=1; y[1].direction := 1; y[2].direction := 1; x.direction := 1;

SOS Type-1 branching is also available in BONMIN from Ampl. We follow the conventional way of doing this with suffixes. Two type of suffixes should be declared:

suffix sosno IN, integer, >=1; # Note that the solver assumes that these # values are positive for SOS Type 1 suffix ref IN;

Next, suppose that we wish to have variables

var X {i in 1..M, j in 1..N} binary;

and the “convexity” constraints:

subject to Convexity {i in 1..M}: sum {j in 1..N} X[i,j] = 1;

(note that we must explicitly include the convexity constraints in the Ampl model).

Then after reading in the data, we set the suffix values:

# The numbers ‘val[i,j]’ are chosen typically as # the values ‘represented’ by the discrete choices. let {i in 1..M, j in 1..N} X[i,j].ref := val[i,j]; # These identify which SOS constraint each variable belongs to. let {i in 1..M, j in 1..N} X[i,j].sosno := i;

### From Gams

Thanks to the GAMSlinks project, Bonmin is available in Gams since release 22.5 of the GAMS modeling system. The system is available for download from GAMS. Without buying a license it works as a demo with limited capabilities. Documentation for using BONMIN in GAMS is available here.

### From a C/C++ program

BONMIN can also be run from within a C/C++ program if the user codes the functions to compute first- and second-order derivatives. An example of such a program is available in the subdirectory CppExample of the examples directory. For further explanations, please refer to this example and to the reference manual.