Documente Academic
Documente Profesional
Documente Cultură
Introduction
Lingo is a software that helps you to model and solve some kinds of optimization problems, such as: o Linear o Nonlinear o Integer Not only you can enter each term of each constraint explicitly (separately and clearly), but also you can express a whole series of similar constraints in a single compact statement. For those problems which involve large number of similar variables and constraints, using set-base model is a powerful approach.
Linear Programming
f(x1, x2, ,xn) = c1x 1 c2x2 cnxn is a linear function. Note that we have no power of 2 or 3 or (for example x2 is not acceptable). f(x1, x2, ,xn) b or f(x1, x2, ,xn) b is a linear inequality. A linear programming problem (LP) is an optimization problem: - To max. or min. a linear function of decision variables (objective function) - The values of decision variables should satisfy a set of constraints.
Notes
Comments are initiated with (!) (exclamation point). Each statement (line) must be end in a (;) (semi-colon). Variable names must begin with a letter (A-Z) (They are not case sensitive). (*) (Asterisk) used to denote multiplication. Parentheses should use to define the order of mathematical operations. 1
To start entering a new optimization problem type: MODEL: Enter the objective function by typing: MIN=. ; Or MAX= ; The last statement should be: END Type the constraints after the objective function without: o St o Such that o Subject to
You can use (^) (carat sign) as a power symbol (In nonlinear programming). In Lingo, the lower bound for variables is zero.
Each model can be solved by: Clicking the solve button Selecting Solve from the LINGO menu Using Ctrl+S keyboard shortcut.
Error (if any) will be reported. LINGO Solver Status Window If no errors are found, the LINGO solver status window appears:
LINGO Solution Report Window Close the Solver Status window to see the Solution Report window.
If we increase one unit of a non-basic variable, how much the objective function will degrade (decrease)? For example, if we want to produce one unit of x2 then we have to produce 23 units of x1, so the objective function will be: (5*1) + (3*23) = 74. Then the reduced cost will be: 75 74 = 1
Dual Price: (for information)
If for example we increase (or decrease) one unit to the 2nd constraint (It is 25 now), then the objective function increase (or decrease) 3 units. Note: The second constraint is satisfied equally, so it is a Compulsory Constraint.
Slack or Surplus: (for information)
Zero: if a constraint is completely satisfied equality (3re row or 2nd constraint). Positive: shows that how many more units of the variable could be added to the optimal solution before the constraint becomes an equality (2nd row: 60- (2*25)= 10)
Example (exp-02)
Maximize Subject to -5/36Q2 + 160/9Q 125/9 10 Q 100
LINGO Model
Example (exp-03)
Minimize Subject to 50S+100F 5 S + 17 F 40 20 S + 7 F 60 S,F 0
LINGO Model
Problem 1
A least cost diet has to be planned for the kitchen of the Strong Boys High School. The total daily requirements of the nutritional elements for healthy young boys, and the cost and the nutritional contents of general food types are given in the following table.
Required Nutritional Element
Units of Nutritional Elements Per Unit of Food Type Milk 160 110 90 50 $ 0.42 Meat 210 130 190 50 $ 0.68 Bread 120 110 90 75 $ 0.32 Vegetable 150 120 130 70 $ 0.17
Total Daily Requirement 2700 Calories 300 grams 250 grams 60 grams
Consider that each student may eat at most 16 units of food stuff per day and the amount of protein taken from animal sources should not be more than the 60% of the total protein intake. Formulate as an LP model.
Solution:
Objective: To obtain minimum cost daily diet which satisfying the Nutritional requirements and
eating capacity
Decision Variables: Xj number of units of food type j into the daily diet of the student (where j=1
MODEL:
Objective Function:
Subject to:
Min Z= 0.42X1+0.68X2+0.32X3+0.17X4 160X1+210X2+120X3+150X4 2700 110X1+130X2+110X3+120X4 300 90X1+190X2+90X3+130X4 50X1+50X2+75X3+70X4 36X1+76X2-54X3-78X4 X1+X2+X3+X4 Xj 0 16 ; j=1,2,3,4 250 60 0
Calories: Carbohydrate: Protein: Vitamins: Protein balance: Or: Eating Capacity: Non-negativity:
Lingo Model:
90X1+190X2 0.6(90X1+190X2+90X3+130X4)
Problem 2
Steelco manufactures two types of steel at three different steel mills. During a given month, each steel mill has 200 hours of blast furnace time available. Because of differences in the furnaces at each mill, the time and cost to produce a ton of steel differs for each mill. The time and cost for each mill are shown in the bellow table.
Steel
Cost ($) Mill 1 Mill 2 Mill 3 10 12 14 Time (Minutes) 20 24 28 Cost ($) 11 9 10
Steel 2
Time (Minutes) 22 18 30
Each month, Steelco must manufacture at least 500 tons of steel 1 and 600 tons of steel 2. Formulate an LP to minimize the cost of manufacturing the desired steel. xij: tons of steel j that reached from mill i, where i=1,2,3 and j=1,2.
Lingo Model: