INTEGER PROGRAMMING IN AMPL
ZUZANA FÍGLOVÁ
UNIVERSITY OF ECONOMICS, PRAGUE, CZECH REPUBLIC
1 . Introduction
Many problems that arise in manufacturing and socio-economic systems, such as
machine scheduling, vehicle routing, resource management, production planning,
telecommunications network design, etc., can be modeled as integer programs. Integer
programming (IP) usually involve optimization of a linear objective function subject to linear
constraints, nonnegativity conditions and integer value conditions [1].
Problems containing integer variables fall into several classes: pure IP problem – a problem
in which all variables are integer, mixed IP problem – a problem with some integer and some
continuous variables, 0-1 linear IP – a problem in which the integer variables are restricted to
equal either zero or one, also called binary or Boolean variables. In this paper we present
AMPL as a modeling language and system for formulating, solving and analyzing integer
optimization problems.
2. AMPL
AMPL stands for “A Modeling Language for Mathematical Programming”. It is a high
level programming language that translates mathematical statements that describe a
mathematical program into a format readable by most optimization software packages. The
Student Edition version V1.6 consists of two implementations of the AMPL command
environment and language processor – AMPL for DOS and AMPL Plus for Windows,
together with the MINOS 5.5 and CPLEX 6.5.3 solvers. Mathematical programs generated by
the Student Edition are limited to 300 variables and 300 constraints and it can be downloaded
from www.ampl.com.
To start, AMPL needs a mathematical programming model, which describes variables,
objectives and relationships without referring to specific data. It also needs an instance of the
data, or a particular data set. The model and one (or more) data files are fed into the AMPL
program. AMPL works like a compiler. It means, the model and input are put into an
intermediate form, which can be read a solver. The solver actually finds an optimal solution to
the problem by reading in the intermediate file produced by AMPL and applying an
67
appropriate algorithm. The use of program we show on the lockbox problem as an example of
0/1 linear integer programming.
3. Lockbox problem
Lockbox problem is a subset of the fixed costs problem of determining the number of
location of payment centers that minimize the sum of fixed operating costs and lost interest
costs.
We define following model [2]:
minimize
∑ ∑ Lij xij + ∑ c j y j
i∈I j∈J
subject to
j∈J
∑ xij = 1
for all i ∈ I ,
∑ xij ≤ I y j
for all j ∈ J ,
xij , y j ∈ {0,1}
for all i ∈ I , j ∈ J ,
j∈J
i∈I
where I is set of sources/regions (number = I ), J is set of lockbox sites (number = J ), cij is
cost to open lockbox j, Lij is average annual loss if source/region i is assigned to send its
checks to lockbox j. Variables take values:
1 if lockbox j is opened;
yj =
0 otherwise.
1 if source/region i is assigned to send its check to lockbox j;
xij =
0 otherwise.
In the model the first set of constraints means that every source/region must be
assigned exactly one lockbox and the second means that if lockbox j is not open, no
source/region is assigned.
3. 1 An example
Consider a US credit card company that receives payments from seven regions of the
country with following daily amount of payments: Central $65 000, Mid-Atlantic $60 000,
Midwest $50 000, Northeast $80 000, Northwest $60 000, Southeast $70 000 and Southwest
$60 000. A company earns 20% interest on these payments. We suppose opening lockboxes
that are located in Los Angeles, Salt Lake City, Atlanta, New York, Austin and Springfield.
The annual fixed cost of operating a lockbox is $60 000.
68
The average duration (in days) from mailing to clearing and the losses due to lost
interest in process on any given day for each possible assignment (for example, if the Central
sends to Los Angeles, a yearly loss is 3*$65 000*20% = $39 000) is given in Table 1.
Table 1 Clearing Times/Lost Interest ($1000)
Los Angeles
Salt Lake City
Atlanta
New York
Austin
Springfield
Central
3
39
4
52
5
65
4
52
5
65
2
26
Mid-Atlantic
5
60
4
48
2
24
3
36
4
48
6
72
Midwest
4
40
3
30
5
50
6
60
4
40
7
70
Northeast
6
96
4
64
3
48
3
48
2
32
3
48
Northwest
2
24
2
24
7
84
5
60
5
60
3
36
Southeast
6
84
3
42
5
70
4
56
3
42
4
56
Southwest
2
24
3
36
2
24
8
96
6
72
3
36
A company wants to determine the lockbox configuration that minimizes the sum of lost
interest and lockbox costs. For this problem we have 48 variables and 13 constraints.
3.2 Solving in AMPL
Figure 1 shows the entire data in AMPL syntax in data file. Comments can be added
anywhere with “#” at the beginning.
Figure 1 An AMPL data file lockbox.dat
69
Figure 2. An AMPL model file lockbox.mod
Figure 2 shows the entire model in AMPL syntax. This way of entering data and the
model makes it easy to modify our example later.
There are several ways to entering a model in AMPL. One of them is using the
command windows with providing and enhanced form of the scrolling command line
interface. We can also use text windows, which separate relationships between general form
of the model and the problem of data values. An alternative way to supply data values is using
data query window look like spreadsheet in MS Excel, for example.
After creating data and model file, we have to click on Build Model, Build Data and
then Solve Problem. For solving problems that contain integer variables, CPLEX uses a
branch-and-bound method. The optimizing algorithm maintains a hierarchy of related linear
programming subproblems, referred to the search tree.
CPLEX allows to control a number of branching heuristics, for instance, the choice of
the branching variable, the branch direction, the choice of the next node to be explored, and
amount of backtracking, etc. For instance, we can control also the algorithm used to solve the
root node as well as the algorithm used to solve subsequent nodes in the branch-and-bound
tree. If you decide to use the barrier algorithm, you can also specify if the crossover (required
to generate a vertex of the feasible polyhedron) uses primal or dual simplex.
Figure 3 presents the steps of algorithm branch-and-bound method of our example.
CPLEX takes 6 nodes, 70 MIP simplex iterations and 2 simplex iterations (0 in phase I) to
find the optimal integer solution.
70
Figure 3 Iterations in Command window
There are two possible ways to see other results. The first way displayed detailed
optimal solution in window Model (Figure 4).
Figure 4 Detailed optimal solution in Model window
71
The second ways is using Command window (Figure 5), we choose displayed optimal
values of variables assignment and y of our lockbox problem.
Figure 5 Optimal solution of variables assignment, y in Command window
4. Conclusion
This paper is a brief report on the AMPL modeling language. It offers a number of
features to facilitate development and testing of optimization models:
• a familiar GUI (graphical user interface),
• integrated text and mini-spreadsheet editing windows for creating and modifying AMPL
models and data declarations,
• an SQL query capability, providing access through ODBC to virtually any relational
database or external file,
• data can be selected, summarized, and loaded into AMPL Plus spreadsheet windows,
• a built-in model window which can be used to browse elements of the AMPL model and
data and select the variables and constraints which will be included in the problem,
• a built-in solver window which provides progress information and user control while an
AMPL-compatible solver is optimizing a model,
72
• an integrated commands window through which the Standard AMPL command-line
interface may be used,
• an integrated project facility which collects model, data, query and command files, and
automates the process of processing the model and solving the problem.
References
1. Fourer R., Gay D. M., Kernighan B. W.: AMPL: A Modeling Language for Mathematical
Programming, Scientific Press, Ferncroft Village Danvers, 1993.
2. Greenberg,
H.
J.:
Integer
Programming
Model
of
the
Lockbox
Problem,
http://carbon.cudenver.edu/~hgreenbe/glossary/examples/lockbox.pdf
3. Saaty, T. L.: Optimization in Integers and Related Extremal Problems, McGraw-Hill, New
York, 1970,
Ing. Zuzana Fíglová
Department of Econometrics, University of Economics, W. Churchill Sq. 4, 130 67 Prague 3,
Czech Republic, telephone: 00420-2-24095443, e-mail: [email protected]
73
© Copyright 2026 Paperzz