0% found this document useful (0 votes)
119 views

Modul Lingo

The document provides an overview of variable types, operators, and functions in Lingo, including common error messages. It also presents two case studies, one modeling a cookie production problem to maximize profit, and another modeling a transportation problem to minimize shipping costs between warehouses and vendors. Common aspects of the Lingo interface are also briefly described.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views

Modul Lingo

The document provides an overview of variable types, operators, and functions in Lingo, including common error messages. It also presents two case studies, one modeling a cookie production problem to maximize profit, and another modeling a transportation problem to minimize shipping costs between warehouses and vendors. Common aspects of the Lingo interface are also briefly described.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

TRAINING HOW TO USE 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.

• @SIGN(X) – returns -1 if X is negative and +1 if X is


positive
• @EXP(X) – calculates eX
COMMON LINGO ERROR MESSAGES
• 7: Unable to open file: filename o Retype filename • 68: Multiple objective functions in model
correctly
– Only one is allowed, please
• 11: Invalid input: A syntax error has occurred
• 71: Improper use of a variable domain function (eg,
– Check the line LINGO suggests for missing semi- @GIN, @BIN, @FREE, @BND)
colons, etc.
– Check the syntax
• 12: Unmatched parenthesis
• 81: No feasible solution found
– Close the parenthesis set
– Check model’s consistency and constraints
• 15: No relational operator found
• 82: Unbounded solution
– Make sure all constraints contain =, <=, >=
– Add constraints
• 44: Unterminated condition
• 102: Unrecognized variable name: variable name
– Put a colon at the end of each conditional
– Check spelling
statement in a set operator
• 108: The model’s dimensions exceed the capacity of
• 50: Improper use of the @FOR() function
this version
– @FOR() functions cannot be nested inside other
– Upgrade to full version or use Excel
set operators
• 164: Invalid LINGO name
– Create a name to conform to LINGO’s naming
conventions
NAVIGATING THE LINGO INTERFACE
The following list details the commands in the File menu. Shortcut keys
are included in parentheses when available:
NAVIGATING THE LINGO INTERFACE
A single toolbar located at the top of the main LINGO window
CASE STUDI 1

• A cookie store can produce drop cookies • Fungsi Objektive model:


and decorated cookies, which sell for $1 X=drop cookies Variabel
and $1.50 apiece, respectively. The two Y=decorated cookie Keputusan
bakers each work 8 hours per day and
can produce up to 400 drop cookies and MAX Profit = 1*X + 1.5*Y
200 decorated cookies. It takes 1 minute • Batasan:
to produce each drop cookie and 3 X ≤ 400;
minutes to produce each decorated Y ≤ 200;
cookie. What combination of cookies 1 3
produced will maximize the baker's *X+ *Y ≤16;
6 60
profit?
CASE STUDI 1
Sintax LINGO

• MAX = 1*Drop + 1.5*Deco;


!Demand Constraints;
Drop <= 400;
Deco <= 200;
!Working Hours Contraint;
1/60*Drop + 3/60*Deco <=16;
CASE STUDI 2
For our example, suppose that the following diagram illustrates the problem:
Wireless Widget (WW) Company has six
warehouses supplying eight vendors
with their widgets. Each warehouse has
a supply of widgets that cannot be
exceeded, and each vendor has a
demand for widgets that must be
satisfied. WW wants to determine how
many widgets to ship from each
warehouse to each vendor so as to
minimize the total shipping cost. This is
a classic optimization problem referred
to as the transportation problem. The
Since each warehouse can ship to each vendor,
there are a total of 48 possible shipping paths, or
arcs. We will need a variable for each arc to
represent the amount shipped on the arc.
CASE STUDI 2
• The following data is available: Vendor Widget Capacity Data
Warehouse Widgets On Hand
Warehouse Widgets On Hand

Warehouse Widgets On Hand 1 35

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
σ𝑖 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 = 𝐷𝑒𝑚𝑎𝑛𝑑𝑗 ,∀𝑗 ∈ 𝑉𝑒𝑛𝑑𝑜𝑟𝑠

෍ 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 ≤ 𝐶𝑎𝑝𝑖 , ∀𝑖 ∈ 𝑊𝑎𝑟𝑒ℎ𝑜𝑢𝑠𝑒𝑠


𝑗
CASE STUDI 2 (CONTINUE)
SETS:
WAREHOUSES: CAPACITY; ! The objective;
VENDORS: DEMAND; MIN = @SUM( LINKS( I, J):
LINKS( WAREHOUSES, VENDORS): COST, VOLUME; COST( I, J) * VOLUME( I, J));
ENDSETS
! Here is the data; ! The demand constraints;
DATA: @FOR( VENDORS( J):
!set members; @SUM( WAREHOUSES( I): VOLUME( I, J))
WAREHOUSES = WH1 WH2 WH3 WH4 WH5 WH6; = DEMAND( J));
VENDORS = V1 V2 V3 V4 V5 V6 V7 V8;
! The capacity constraints;
!attribute values; @FOR( WAREHOUSES( I):
CAPACITY = 60 55 51 43 41 52; @SUM( VENDORS( J): VOLUME( I, J)) <=
DEMAND = 35 37 22 32 41 32 43 38; CAPACITY( I));
COST = 6 2 6 7 4 2 5 9 END
49538582
52197433
76739271
23957265
5 5 2 2 8 1 4 3;
ENDDATA
CASE STUDI 2 (CONTINUE)
PRACTICE 1
The Staff Scheduling Problem

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:

Day Mon Tue Wed Thu Fri Sat Sun


Staff Req'd 20 16 13 16 19 14 12

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:

Day Mon Tue Wed Thu


Peanuts (oz.) 15 10 6 2
Cashews (oz.) 1 6 10 14
Selling Price ($) 2 3 4 5

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

You might also like