1 / 23

LINGO Part III (IE 311 – Lab)

LINGO Part III (IE 311 – Lab). Spring ‘0 7. Variables Doma in Function. Variables in a LINGO model default to being nonnegative and continuous. LINGO provides four variable domain function that allow you to override the default domain of a variable.

Download Presentation

LINGO Part III (IE 311 – Lab)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LINGOPart III(IE 311 – Lab) Spring ‘07

  2. Variables Domain Function • Variables in a LINGO model default to being nonnegative and continuous. • LINGO provides four variable domain function that allow you to override the default domain of a variable. @GINRestricts a variable to being an integer value. @BINMakes a variable binary (i.e. 0 or 1). @FREEAllows a variable to assume any real value, positive or negative. @BNDLimits a variable to fall within a finite range.

  3. @GIN • By default, LINGO assume all variables in a model are continuous. In many applications, fractional values may be undesirable. For example, you won’t be able two hire two-third of a person, or sell half an automobile. • In these instances, you will want to make use of the general integer variable domain function, @GIN. @GIN(variable_name);

  4. i.e.: @GIN(X) makes the scalar variable X general integer @GIN(Produce(5)) makes the variable Produce(5) general integer @FOR(DAY(I):@GIN(START(I)) makes all the variables of the START attribute general integer

  5. @BIN • A binary variable is a special case of an integer variable . @BIN(variable_name); i.e.: @BIN(X)makes the scalar variable, X, a binary integer @BIN(Produce(5)) makes the variable Produce(5) variable binary @FOR(DAY(I):@BIN(START(I)) makes all the variables of the START attribute binary

  6. @FREE • It removes the lower bound of zero and lets a variable take negative value. @FREE(variable_name); • i.e.: @FREE(X)makes the scalar variable, X, free @FREE(Produce(5)) makes the variable Produce(5) free @FOR(DAY(I):@FREE(START(I)) makes all the variables of the START attribute free

  7. @BND • It lets you, set specific upper and lower bounds on a variable. @BND(lower_bound, variable_name, upper_bound); • i.e @BND(-1,X,1)constrains X to lie in the interval [-1,1] @BND(100, QUANTITY(4),200) constrains QUANTITY(4)to fall within 100 to 200

  8. @SUM • Consider the following set: SETS: VENDORS/V1,V2,V3,V4,V5/:DEMAND; ENDSETS DATA: DEMAND=5 1 3 4 6; ENDDATA • We could sum up the values of the DEMAND attribute by adding the following expression after the ENDDATA statement: TOTAL_DEMAND = @SUM(VENDORS(J):DEMAND(J));

  9. LINGO evaluates the @SUM function by first initializing an internal accumulator zero. • Then, it begins looping over the members in the VENDORS set. The set index variable J, is set to the first member of VENDORS (i.e., V1) and DEMAND(V1) is then added to the accumulator … • The value of the sum is then stored into the TOTAL_DEMAND variable. • Suppose we want to sum the first three elements of DEMAND: DEMAND_3 = @SUM(VENDORS(J)|J #LE# 3: DEMAND(J));

  10. @MIN & @MAX • @MIN and @MAX functions are used to find the minimum and maximum of an expression over members of a set. • Again, consider the following set: SETS: VENDORS/V1,V2,V3,V4,V5/:DEMAND; ENDSETS DATA: DEMAND=5 1 3 4 6; ENDDATA

  11. @MIN & @MAX (cont). • To find the minimum and the maximum DEMAND, the following two lines are needed: MIN_DEMAND = @MIN(VENDORS(J):DEMAND(J)); MAX_DEMAND = @MAX(VENDORS(J):DEMAND(J)); • Suppose we had just wanted to compute the minimum and maximum values of the first three elements of DEMAND: MIN_3 = @MIN(VENDORS(J) |J #LE# 3 : DEMAND(J)); MAX_3 = @MAX(VENDORS(J) |J #LE# 3 : DEMAND(J));

  12. Example: • 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:

  13. Example: (cont) You need to determine how many employees to start on each day of the week in order to minimize the total number of required employees, while still meeting or exceeding staffing requirements.

  14. Solution: • What are the relevant sets and their attributes: • We have a single primitive set, the days of the weeks • We will concerned with two attributes of the DAY set: • The number of staff required on each day • The number of staff to start on each day

  15. SETS: DAYS / MON, TUE, WED, THU, FRI, SAT, SUN / : REQUIRED, START;ENDSETS Solution (cont.): • It’s useful to determine what attributes are data and what are decision variables. • REQUIRED attribute is given to us  Data • START attribute is something we need to determine Decision Variable DATA: REQUIRED = 20 16 13 16 19 14 12; ENDDATA

  16. Solution (cont.): • Objective: • Our objective is to minimize the sum of the total number of employees we start during the week. MIN = @SUM(DAYS(I) : START(I));

  17. Solution (cont.): • Constraint: • We must have enough staff on duty each day to meet or exceed staffing requirements. Staff on duty today  Staff required today for each day of the week RHS = The quantity REQUIRED(I) LHS = No. starting today + No. starting 1 day ago + No. starting 2 days ago +No. starting 3 days ago + No. starting 4 days ago

  18. Solution (cont.): @FOR(DAYS(J):@SUM(DAYS(I)|I#LE#5:START(J-I+1))>=REQUIRED(J)); • It says, for each day of a week, the sum of the employees starting over the five day period beginning four days ago and ending today must be greater than or equal to the required number of staff for the day.

  19. Solution (cont.): • IF you try to solve our model, we get the error message: • To see why we get this error message, consider what happens on Thursday (Index 4 in our DAYS set):

  20. Solution (cont.): START(4-1+1) + START(4-2+1) + START(4-3+1) + START(4-4+1) + START(4-5+1) >= REQUIRED(4); START(4) + START(3) + START(2) + START(1) + START(0)>= REQUIRED(4) • We would like to have any indices less than or equal to 0 wrap around to the end of the week. (0 would correspond to Sunday (7), -1 to Saturday (6) and so on)

  21. Solution (cont.): • LINGO has a function called @WRAP. It takes two argument: • INDEX • LIMIT • @WRAP will subtract or add LIMIT to INDEX until it falls in the range 1 to LIMIT: @FOR(DAYS(J):@SUM(DAYS(I)| I #LE# 5 : START(@WRAP(J-I+1,7))) >= REQUIRED(J));

  22. Solution (cont.):

  23. Solution (cont.):

More Related