INDU 323 - Industrial Operations Research LINDO Tutorial: Syntax Required in A LINDO Model
INDU 323 - Industrial Operations Research LINDO Tutorial: Syntax Required in A LINDO Model
LINDO Tutorial
LINDO (Linear, INteractive, and Discrete Optimizer) is a convenient tool for solving linear, integer, and
quadratic programming problems.
The guiding design philosophy for LINDO has been that if a user wants to do something simple, then there
should not be a large setup cost to learn the necessary features of LINDO. If, for example, a users wishes
to:
Maximize 2X + 3Y
Subject to
4X + 3Y < 10
3X + 5Y < 12
then that is exactly what the user types into LINDO immediately after starting the program.
The objective function must always be at the start of the model and is initiated with either MAX (for
maximize) or MIN (for minimize). The end of the objective function and the beginning of the constraints is
signified with any of the following:
SUBJECT TO
SUCH THAT
S.T.
ST
LINDO has a limit of eight characters in a variable name. Names must begin with an alphabetic character
(A to Z), which may then be followed by up to seven additional characters. These additional characters
may include anything with the exception of the following: ! ) + - = < >. So, as an example, the following
names would be considered valid:
The first example contains more than eight characters, while the second contains a forbidden hyphen, and
the last example does not begin with an alphabetic character.
You may, optionally, name constraints in a model. Constraint names make many of LINDO's output reports
easier to interpret. Constraint names must follow the same conventions as variable names. To name a
constraint you must start the constraint with its name terminated with a right parenthesis. After the right
parenthesis, you continue entering the constraint as before. As an example, the following constraint is given
the name XBOUND:
XBOUND) X < 10
LINDO recognizes only five operators: plus (+), minus (-), greater than (>), less than (<), and equals (=).
When you enter the strict inequality operators, greater than (>) or less than (<), LINDO will interpret them
with the loose inequality operators > or < respectively. This is because many keyboards do not have the
loose inequality operators. On systems that do have the loose operators, LINDO will not recognize them.
However, if you prefer, you may enter ">=" (and "<=") in place of ">" (and "<").
LINDO will not accept parentheses as indicators of a preferred order of precedence. All operations in
LINDO are ordered from left to right.
Comments may be placed anywhere in a model. A comment is denoted by an exclamation mark (!).
Anything following the exclamation mark on the current line will be considered a comment.
Example 1 The Wyndor Glass Co. example discussed in the class is recast below using comments:
Your model has now been entered and it is ready to be solved. To begin solving the model, select the Solve
command from the Solve menu, or press the Solve button on the toolbar at the top of the window. You
should get the following solution:
Constraints and objective functions may be split over multiple lines, or combined on single lines. You may
spilt a line anywhere except in the middle of a variable name or a coefficient. LINDO is not case sensitive.
All input is converted to upper case internally by LINDO. Only constant values, not variables, are permitted
on the right-hand side of a constraint equation. Thus, an entry such as:
X>Y
would be rejected by LINDO. Such an entry could be made as:
X-Y>0
Conversely, only variables and their coefficients are permitted on the left-hand side of constraints. For
instance, the constraint:
3X + 4Y - 10 = 0
is not permitted due to the constant term of -10 on the left-hand side. Of course, the constraint may be
recast as:
3X + 4Y = 10
in order to comply with LINDO syntax.
Example 2: Now change the RHS value of the second constraint to 13 and solve the problem again.
which is no longer integer. To have an integer solution, you need to use GIN option for variables X1 and
X2 as follows:
Min 8X1+10X2+7X3+6X4+11X5+9X6+2Y1+2Y2
ST
12X1+9X2+25X3+20X4+17X5+13X6 >= 60
35X1+42X2+18X3+31X4+56X5+49X6 >= 150
37X1+53X2+28X3+24X4+29X5+20X6 >= 125
X1-1000Y1<=0
X2-1000Y2<=0
X1 <= 1
X2 <= 1
X3 <= 1
X4 <= 1
X5 <= 1
X6 <= 1
END
INT Y1
INT Y2
Min 8X1+10X2+7X3+6X4+11X5+9X6+2Y1+2Y2
ST
12X1+9X2+25X3+20X4+17X5+13X6 >= 60
35X1+42X2+18X3+31X4+56X5+49X6>=150
37X1+53X2+28X3+24X4+29X5+20X6>=125
X1-1000Y1<=0
X2-1000Y2<=0
END
SUB X1 1
SUB X2 1
SUB X3 1
SUB X4 1
SUB X5 1
SUB X6 1
INTE Y1
INTE Y2
Of course, this formulation should yield the same results, but there are two points to keep in mind. First of,
SUBs and SLBs are handled implicitly by the solver, and, therefore, are more efficient from a performance
point of view than constraints. Secondly, SUBs and SLBs do not count against the constraint limit in
LINDO, allowing you to solve larger models within the limits of your version of LINDO.
Lastly, to capture a solution into a file select “Log Output” under “File” menu.