> Tutorials > Interactive Optimizer Tutorial > Entering a Problem > Using the LP Format |
Using the LP Format |
INDEX
![]() |
Entering a new problem is basically like typing it on a page, but there are a few rules to remember. These rules conform to the ILOG CPLEX LP file format and are documented in the reference manual ILOG CPLEX File Formats. LP format appears throughout this tutorial.
The problem should be entered in the following order:
Before entering the objective function, you must state whether the problem is a minimization or maximization. For this example, you type:
You may type minimize
or maximize
on the same line as the objective function, but you must separate them by at least one space.
In the example, the variables are named simply x1
, x2
, x3
, but you can give your variables more meaningful names such as cars
or gallons
. The only limitations on variable names in LP format are that the names must be no more than 255 characters long and use only the alphanumeric characters (a-z, A-Z, 0-9) and certain symbols: ! " # $ % & ( ) , . ; ? @ _ ` ' { } ~. Any line with more than 510 characters is truncated.
A variable name cannot begin with a number or a period, and there is one character combination that cannot be used: the letter e
or E
alone or followed by a number or another e
, since this notation is reserved for exponents. Thus, a variable cannot be named e24
nor e9cats
nor eels
nor any other name with this pattern. This restriction applies only to problems entered in LP format.
Once you have entered the objective function, you can move on to the constraints. However, before you start entering the constraints, you must indicate that the subsequent lines are constraints by typing:
or
These terms can be placed alone on a line or on the same line as the first constraint if separated by at least one space. Now you can type in the constraints in the following way:
In this simple example, it is easy to keep track of the small number of constraints, but for many problems, it may be advantageous to name constraints so that they are easier to identify. You can do so in ILOG CPLEX by typing a constraint name and a colon before the actual constraint. If you do not give the constraints explicit names, ILOG CPLEX will give them the default names c1, c2, . . . , cn
. In the example, if you want to call the constraints time
and labor
, for example, enter the constraints like this:
Constraint names are subject to the same guidelines as variable names. They must have no more than 16 characters, consist of only allowed characters, and not begin with a number, a period, or the letter e
followed by a positive or negative number or another e
.
The objective function can be named in the same manner as constraints. The default name for the objective function is obj
. ILOG CPLEX assigns this name if no other is entered.
Finally, you must enter the lower and upper bounds on the variables. If no bounds are specified, ILOG CPLEX will automatically set the lower bound to 0 and the upper bound to +. You must explicitly enter bounds only when the bounds differ from the default values. In our example, the lower bound on
x1
is 0, which is the same as the default. The upper bound 40, however, is not the default, so you must enter it explicitly. You must type bounds
on a separate line before you enter the bound information:
Since the bounds on x2
and x3
are the same as the default bounds, there is no need to enter them. You have finished entering the problem, so to indicate that the problem is complete, type:
on the last line.
The CPLEX>
prompt returns, indicating that you can again enter a ILOG CPLEX command.
Entering a problem in ILOG CPLEX is straightforward, provided that you observe a few simple rules:
maximize
or minimize
must precede the objective function; the term subject to
must precede the constraints section; both must be separated from the beginning of each section by at least one space.
bounds
must be alone on a line preceding the bounds section.
end
must appear.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |