Modul Lingo

  • Uploaded by: Sri Susilawati Islam
  • 0
  • 0
  • January 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Modul Lingo as PDF for free.

More details

  • Words: 1,470
  • Pages: 17
Loading documents preview...
TRAINING HOW TO USE LINGO

BY SAMPOERNA UNIVERSITY

VARIABLE TYPES IN LINGO All variables in a LINGO model are considered to be non-negative and continuous unless otherwise specified.

• @GIN – any positive integer value • @BIN – a binary value (ie, 0 or 1) • @FREE – any positive or negative real value • @BND – any value within the specified bounds

• Similar syntax is used for the @GIN, @BIN, and @FREE variable domain functions. The general form for the declaration of a variable x using any of these functions is @FUNCTION(X); • The @BND function has a slightly modified syntax, which includes the upper and lower bounds for the acceptable variable values. The general form for the declaration of a variable x between a lower bound and an upper bound is given by

• @BND(lowerBound, X, upperBound);

LINGO OPERATORS AND FUNCTIONS There are three types of operators that LINGO uses: arithmetic, logical, and relational operators.

• #GT#: TRUE if the left argument is strictly greater than the right argument, else FALSE

The arithmetic operators are as follows: •Exponentiation: ^

• #GE#: TRUE if the left argument is greater-than-orequal-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: The logical operators are used in set looping functions to define true/false conditions: •#LT#: TRUE if the left argument is strictly less than the right argument, else FALSE •#LE#: TRUE if the left argument is less-than-orequal-to the right argument, else FALSE

• #OR#: FALSE only if both arguments are FALSE, else TRUE • #NOT#: TRUE if the argument immediately to the right is FALSE, else FALSE

LINGO OPERATORS AND FUNCTIONS The relational operators are used when defining the constraints for a model. They are as follows: • The expression is equal: =

• The left side of the expression is less than or equal to the right side: <= • The left side of the expression is greater than or equal to the right side: >= The following list contains a sampling of mathematical functions that can be used in LINGO: • @ABS(X) – returns the absolute value of X • @SIGN(X) – returns -1 if X is negative and +1 if X is positive • @EXP(X) – calculates eX

•@LOG(X) – calculates the natural log of X •@SIN(X) – returns the sine of X, where X is the angle in radians

•@COS(X) – returns the cosine of X •@TAN(X) – returns the tangent of X LINGO also contains a plethora of financial, probability, and import/export functions. These are commonly used in more advanced models, which are beyond the intended scope of this tutorial.

COMMON LINGO ERROR MESSAGES • 7: Unable to open file: filename o Retype filename correctly • 11: Invalid input: A syntax error has occurred – Check the line LINGO suggests for missing semicolons, etc.

• 12: Unmatched parenthesis – Close the parenthesis set • 15: No relational operator found – Make sure all constraints contain =, <=, >= • 44: Unterminated condition – Put a colon at the end of each conditional statement in a set operator • 50: Improper use of the @FOR() function – @FOR() functions cannot be nested inside other set operators

• 68: Multiple objective functions in model – Only one is allowed, please • 71: Improper use of a variable domain function (eg, @GIN, @BIN, @FREE, @BND) – Check the syntax • 81: No feasible solution found – Check model’s consistency and constraints • 82: Unbounded solution – Add constraints • 102: Unrecognized variable name: variable name – Check spelling • 108: The model’s dimensions exceed the capacity of this version – Upgrade to full version or use Excel • 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 and decorated cookies, which sell for $1 and $1.50 apiece, respectively. The two bakers each work 8 hours per day and can produce up to 400 drop cookies and 200 decorated cookies. It takes 1 minute to produce each drop cookie and 3 minutes to produce each decorated cookie. What combination of cookies produced will maximize the baker's profit?

• Fungsi Objektive model: X=drop cookies Y=decorated cookie MAX Profit = 1*X + 1.5*Y • Batasan: X ≤ 400; Y ≤ 200; 1 6

*X+

3 60

*Y ≤16;

Variabel Keputusan

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 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

following diagram illustrates the problem:

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 ($)

Objective Function: 𝑚𝑖𝑛 = ෍ 𝐶𝑜𝑠𝑡𝑖𝑗 . 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 The Constrain: σ𝑖 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 = 𝐷𝑒𝑚𝑎𝑛𝑑𝑗 ,∀𝑗 ∈ 𝑉𝑒𝑛𝑑𝑜𝑟𝑠 ෍ 𝑉𝑜𝑙𝑢𝑚𝑒𝑖𝑗 ≤ 𝐶𝑎𝑝𝑖 , ∀𝑖 ∈ 𝑊𝑎𝑟𝑒ℎ𝑜𝑢𝑠𝑒𝑠 𝑗

Warehouse

Widgets On Hand

1

35

2

37

3

22

4

32

5

41

6

32

7

43

8

38

CASE STUDI 2 (CONTINUE) SETS: WAREHOUSES: CAPACITY; VENDORS: DEMAND; LINKS( WAREHOUSES, VENDORS): COST, VOLUME; ENDSETS ! Here is the data; DATA: !set members; WAREHOUSES = WH1 WH2 WH3 WH4 WH5 WH6; VENDORS = V1 V2 V3 V4 V5 V6 V7 V8; !attribute values; CAPACITY = 60 55 51 43 41 52; DEMAND = 35 37 22 32 41 32 43 38; COST = 6 2 6 7 4 2 5 9 49538582 52197433 76739271 23957265 5 5 2 2 8 1 4 3; ENDDATA

! The objective; MIN = @SUM( LINKS( I, J): COST( I, J) * VOLUME( I, J)); ! The demand constraints; @FOR( VENDORS( J): @SUM( WAREHOUSES( I): VOLUME( I, J)) = DEMAND( J)); ! The capacity constraints; @FOR( WAREHOUSES( I): @SUM( VENDORS( J): VOLUME( I, J)) <= CAPACITY( I)); END

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 Staff Req'd

Mon

Tue

Wed

Thu

Fri

Sat

Sun

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

Related Documents

Modul Lingo
January 2021 1
02 Modul Pelatihan Lingo
January 2021 0
Lingo Tutorial
January 2021 1
Lingo 14
January 2021 12
Lingo Modelling
January 2021 11
Manual Lingo
March 2021 0

More Documents from ""