Modul Lingo
Modul Lingo
BY SAMPOERNA UNIVERSITY
VARIABLE TYPES IN LINGO
All variables in a LINGO model are considered to
• Similar syntax is used for the @GIN, @BIN, and
be non-negative and continuous unless otherwise
@FREE variable domain functions. The general form
specified.
for the declaration of a variable x using any of these
functions is @FUNCTION(X);
• @GIN – any positive integer value • The @BND function has a slightly modified syntax,
which includes the upper and lower bounds for the
• @BIN – a binary value (ie, 0 or 1) acceptable variable values. The general form for the
• @FREE – any positive or negative real value declaration of a variable x between a lower bound
and an upper bound is given by
• @BND – any value within the specified
bounds • @BND(lowerBound, X, upperBound);
LINGO OPERATORS AND FUNCTIONS
There are three types of operators that LINGO
• #GT#: TRUE if the left argument is strictly greater than
uses: arithmetic, logical, and relational operators.
the right argument, else FALSE
The arithmetic operators are as follows:
• #GE#: TRUE if the left argument is greater-than-or-
•Exponentiation: ^ equal-to the right argument, else FALSE
•Multiplication: * • #EQ#: TRUE if both arguments are equal, else FALSE
•Division: / • #NE#: TRUE if both arguments are not equal, else FALSE
•Addition: + • #AND#: TRUE only if both arguments are TRUE, else
FALSE
•Subtraction: -
• #OR#: FALSE only if both arguments are FALSE, else
The logical operators are used in set looping TRUE
functions to define true/false conditions:
• #NOT#: TRUE if the argument immediately to the right
•#LT#: TRUE if the left argument is strictly less is FALSE, else FALSE
than the right argument, else FALSE
•#LE#: TRUE if the left argument is less-than-or-
equal-to the right argument, else FALSE
LINGO OPERATORS AND FUNCTIONS
The relational operators are used when defining the •@LOG(X) – calculates the natural log of X
constraints for a model. They are as follows:
•@SIN(X) – returns the sine of X, where X is the angle
• The expression is equal: = in radians
• The left side of the expression is less than or equal •@COS(X) – returns the cosine of X
to the right side: <=
•@TAN(X) – returns the tangent of X
• The left side of the expression is greater than or
equal to the right side: >=
LINGO also contains a plethora of financial,
The following list contains a sampling of probability, and import/export functions. These are
mathematical functions that can be used in LINGO: commonly used in more advanced models, which are
• @ABS(X) – returns the absolute value of X beyond the intended scope of this tutorial.
1 60 2 37
2 55 3 22
3 51 4 32
4 43 5 41
5 41 6 32
6 52 7 43
8 38
CASE STUDI 2 (CONTINUE)
• The following data is available: Vendor Widget Capacity Data
Shipping Cost per Widget ($)
Warehouse Widgets On Hand
1 35
2 37
3 22
4 32
Objective Function:
5 41
𝑚𝑖𝑛 = 𝐶𝑜𝑠𝑡𝑖𝑗 . 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗
6 32
7 43
The Constrain:
8 38
σ𝑖 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 = 𝐷𝑒𝑚𝑎𝑛𝑑𝑗 ,∀𝑗 ∈ 𝑉𝑒𝑛𝑑𝑜𝑟𝑠
Suppose you run the popular Pluto Dogs hot dog stand that is open seven days a week. You hire
employees to work a five-day workweek with two consecutive days off. Each employee receives
the same weekly salary. Some days of the week are busier than others and, based on past
experience, you know how many workers are required on a given day of the week. In particular,
your forecast calls for these staffing requirements:
You need to determine how many employees to start on each day of the week in order to minimize
the total number of employees, while still meeting or exceeding staffing requirements each day of
the week.
PRACTICE 2
The Problem
The Chess Snackfoods Co. markets four brands of mixed nuts. The four brands of nuts are called
the Pawn, Knight, Bishop, and King. Each brand contains a specified ratio of peanuts and
cashews. The table below lists the number of ounces of the two nuts contained in each pound
of each brand and the price the company receives per pound of each brand:
Chess has contracts with suppliers to receive 750 pounds of peanuts/day and 250 pounds of
cashews/day. Our problem is to determine the number of pounds of each brand to produce
each day to maximize total revenue without exceeding the available supply of nuts.
THANK YOU.
Sampoerna University