Académique Documents
Professionnel Documents
Culture Documents
Introduction
Lingo is a software that helps you to model and solve some kinds of
Linear Programming
f(x1, x2, ,xn) = c1x 1 c2x2 cnxn is a linear function.
Note that we have no power of 2, 3 or 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. of the linear objective function. The values of decision variables should satisfy a set of constraints.
Notes
Variable names must begin with a letter A-Z and continue with letters
and digits 0-9. They are not case sensitive. Enter the objective function by typing: MIN=; or MAX= ; Each statement (line) must be end in a semi-colon (;). Asterisk used to denote multiplication (*) . carat sign is used as a power symbol (^) In nonlinear programming. Comments are initiated with exclamation point (!). Parentheses should use to define the order of mathematical operations. Type the constraints after the objective function without: St., Such that and Subject to. In Lingo, the lower bound for variables is zero.
A simple example
A company produces product A and B. Product A sells for $3 per
unit, and product B sells for $5 per unit. Producing a unit of product A requires 2 unit of raw material 1 and 1 unit of raw material 2. Producing a unit of product B requires 5 unit of raw material 1 and 2 unit of raw material 2. 60 units of raw material 1 and 25 unit of raw material 2 are available. Formulate an LP that can be used to maximize revenue.
2.
3.
items:
1. Objective Function is a formula that expresses exactly what it is you
want to optimize. In business oriented models, this will usually be a profit function you wish to maximize or a cost function you want to minimize. Models may have, at most, one objective function. In our example, the objective function will compute the company's profit as a function of the output of Standards and Turbos.
time, raw materials, your budget, etc). In our example, we will have one constraint for each of our production lines and one constraint on the total labor used.
must be constrained to the production line limits of 100 and 120, respectively. STANDARD <= 100; TURBO <= 120; The final constraint on the amount of labor used can be expressed as: STANDARD + 2 * TURBO <= 160;
variable names. Thus, TURBO, Turbo, Turbo would all be considered equivalent:
keywords, it displays them in blue, Comments are displayed in green, Matching parentheses are also highlighted in red and all remaining text is displayed in black.
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. 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.
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
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 (milk), 2(meat), 3(bread), 4(vegetables)).
Model:
Objective Function: Min Z= 0.42X1+0.68X2+0.32X3+0.17X4 Subject to: Calories: 160X1+210X2+120X3+150X4 2700 Carbohydrate: 110X1+130X2+110X3+120X4 300 Protein: 90X1+190X2+90X3+130X4 250 Vitamins: 50X1+50X2+75X3+70X4 60 Protein balance: 90X1+190X2 0.6(90X1+190X2+90X3+130X4) Or: 36X1+76X2-54X3-78X4 0 Eating Capacity: X1+X2+X3+X4 16 Non-negativity: Xj 0 ; j=1,2,3,4
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 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.
Steel
Steel 2
Cost ($)
Time (Minutes)
Cost ($)
Time (Minutes)
Mill 1
10
20
11
22
Mill 2
12
24
18
Mill 3
14
28
10
30
Lingo Model:
Problem 3
Walnut Orchard has two farms that grow wheat and
corn. Because of different soil conditions, there are differences in the yields and costs of growing crops on the two farms. The yields and costs are shown in the following table. Each farm has 100 acres available for cultivation; 11000 bushels of wheat and 7000 bushels of corn must be grown. Determine a planting plan that will minimize the cost of meeting these demands.
Farm 1
Farm 2
Corn yield/acre
500 bushels
650 bushels
Cost/acre of corn
$ 100
$ 120
Wheat yield/acre
400 bushels
350 bushels
Cost/acre of
wheat
$ 90
$ 80
Solution:
Objective: To decide how many acres to devote to
wheat and corn in each farm, so that total cost of producing requested wheat and corn is minimized. Decision Variables: xij: amount of acres devoted to produce i in farm j, where i= 1, 2 and j = 1, 2.
S.T:
x11 + x21 100 x12 + x22 100 500 x11 + 650 x12 7000 400 x21 + 350 x22 11000 xij 0 for all i,j
Free Variables
By default, a LINGO variable has a lower bound of zero
and an upper bound of infinity. @FREE removes the lower bound of zero and lets a variable take negative values, rendering it unconstrained in sign, or free. The syntax is: @FREE( variable_name); where variable_name is the name of the variable you wish to make free. The @FREE function may be used in a model anywhere you would normally enter a constraint.