Sample Question

The Mosel Terminology Coding in Mosel is easy enough if you incorporate some experience with other high-level programming {dialects|different languages|’languages’}. The statements that {designate|identify|stipulate} a model’s variables and constraints closely resemble the usual notation to {explain|identify|illustrate} optimization models. The {associated|enclosed|associating} lines (see box) provide an sort of Mosel code.

1. A.

x1*p1 + x2*p2 –> max (where is p1 and p2 is unit profits)

x1*5 + x2*11 <= 550

x1*5 + x2*3 <= 300

x2 <= 40

x1 >= 0, x2 >= 0

B.

x1 – meters of light duty clothes

x2 – meters of heavy duty clothes

Each metre of light cloth requires five metres of raw cotton and each metre of heavy cloth requires eleven metres of raw cotton. Due to we have only 550 metres of raw cotton comes this equation: x1*5 + x2*11 <= 550

Same with processing time one metre of light cloth requires five hours, and each metre of heavy cloth requires 3 hours. We have only 300 hours available, so we have one more equation:

x1*5 + x2*3 <= 300

Also we have demand for heavy duty cloth is at most 40 metres from which x2 <= 40

And also we can’t have negative meters of clothes, so x1 >= 0, x2 >= 0

C.

A linear programming problem or LP problem in two unknowns x1 and x2 is one in which we are to find the maximum or minimum value of a linear expression

x1*p1 + x2*p2 (where p1 and p2 is constants)

called the objective function

The solution set of the collection of constraints is called the feasible region of the LP problem. The largest or smallest value of the objective function is called the optimal value, and a pair of values of x1 and x2 that gives the optimal value constitutes an optimal solution.

D.

For equation x1*5 + x2*11 <= 550 let’s draw line 5*x + 11*y = 550 (x1 = x, x2 = y)

Everything upon it will be red, and everything down it white.

For equation x1*5 + x2*3 <= 300 The line will be 5*x + 3*y = 300, everything upon it will be red, and everything down it white.

And last one x2 <= 40, y = 40 with same principe as shown upon.

We will get such picture:

The feasible region is shown in white.

To find maxima we should draw family of lines p1*x = p2*y, p1 and p2 is constant, let’s suppose p1 = p2 = 1, to make our life easier.

Only lines that has points from white area is needed. After that we much choose line that have max distance to (0,0).

Not hard to understand that it’s this line

The answer is this x and y matched in circles bellow

X = 41.25, Y = 31.25

E. So company should make 41.25 metres of light duty clothes and 31.25 meters of heavy duty clothes.

F.

model “Clothing”

!sample declarations section

declarations

x1,x2: mpvar ! Decision variables: produced quantities

end-declarations

Profit:= x1 + x2 !objective function

rawCotton:= 5*x1 + 11*x2 <= 550 ! cotton in metres

processingTime:= 5*x1 +3*x2 <= 300 !hrs of processing time

demand:= x2 <= 40 !demand

maximize(Profit) !Solve the problem

writeln(“Make “, getsol(x1), ” light Duty Clothes”)

writeln(“Make “,getsol(x2), ” heavy Duty Clothes”)

writeln(“Best profit is “, getobjval)

end-model

G. Graphically solution is good to understand LP problem but does not let you solve it 100% correct. Firstly it works only when your LP problem has 2 unknown secondly, it’s very hard to get accurately answer when. Mosel mode is hard to build but when you don’t know how to do it, but after you find out LP problems is very easy to solve.

2. A.

x1 – number of cask golden glow

x2 – number of cask autumn fresh

x3 – number of cask sparkling light

7500 * x1 + 8200 * x2 + 9500 * x3 –> max

20*x1 + 24*x2 + 18*x3 <= 1700

x1 + x2 + x3 <= 80

11*x1 + 8*x2 + 16*x3

Mosel mode :

model “cider”

!sample declarations section

declarations

x1,x2,x3: mpvar ! Decision variables: produced quantities

end-declarations

Profit:= 7500 * x1 + 8200 * x2 + 9500 * x3 !objective function

tonesApple:= 0.2*x1 + 0.24*x2 + 0.18*x3 <= 17 ! tones of apples

processingTime:= 11*x1 + 8*x2 + 16*x3 <= 2500 ! hrs of processing time

casks:= x1 + x2 + x3 <= 80 ! can store at most 80 casks

1. A.

x1*p1 + x2*p2 –> max (where is p1 and p2 is unit profits)

x1*5 + x2*11 <= 550

x1*5 + x2*3 <= 300

x2 <= 40

x1 >= 0, x2 >= 0

B.

x1 – meters of light duty clothes

x2 – meters of heavy duty clothes

Each metre of light cloth requires five metres of raw cotton and each metre of heavy cloth requires eleven metres of raw cotton. Due to we have only 550 metres of raw cotton comes this equation: x1*5 + x2*11 <= 550

Same with processing time one metre of light cloth requires five hours, and each metre of heavy cloth requires 3 hours. We have only 300 hours available, so we have one more equation:

x1*5 + x2*3 <= 300

Also we have demand for heavy duty cloth is at most 40 metres from which x2 <= 40

And also we can’t have negative meters of clothes, so x1 >= 0, x2 >= 0

C.

A linear programming problem or LP problem in two unknowns x1 and x2 is one in which we are to find the maximum or minimum value of a linear expression

x1*p1 + x2*p2 (where p1 and p2 is constants)

called the objective function

The solution set of the collection of constraints is called the feasible region of the LP problem. The largest or smallest value of the objective function is called the optimal value, and a pair of values of x1 and x2 that gives the optimal value constitutes an optimal solution.

D.

For equation x1*5 + x2*11 <= 550 let’s draw line 5*x + 11*y = 550 (x1 = x, x2 = y)

Everything upon it will be red, and everything down it white.

For equation x1*5 + x2*3 <= 300 The line will be 5*x + 3*y = 300, everything upon it will be red, and everything down it white.

And last one x2 <= 40, y = 40 with same principe as shown upon.

We will get such picture:

The feasible region is shown in white.

To find maxima we should draw family of lines p1*x = p2*y, p1 and p2 is constant, let’s suppose p1 = p2 = 1, to make our life easier.

Only lines that has points from white area is needed. After that we much choose line that have max distance to (0,0).

Not hard to understand that it’s this line

The answer is this x and y matched in circles bellow

X = 41.25, Y = 31.25

E. So company should make 41.25 metres of light duty clothes and 31.25 meters of heavy duty clothes.

F.

model “Clothing”

!sample declarations section

declarations

x1,x2: mpvar ! Decision variables: produced quantities

end-declarations

Profit:= x1 + x2 !objective function

rawCotton:= 5*x1 + 11*x2 <= 550 ! cotton in metres

processingTime:= 5*x1 +3*x2 <= 300 !hrs of processing time

demand:= x2 <= 40 !demand

maximize(Profit) !Solve the problem

writeln(“Make “, getsol(x1), ” light Duty Clothes”)

writeln(“Make “,getsol(x2), ” heavy Duty Clothes”)

writeln(“Best profit is “, getobjval)

end-model

G. Graphically solution is good to understand LP problem but does not let you solve it 100% correct. Firstly it works only when your LP problem has 2 unknown secondly, it’s very hard to get accurately answer when. Mosel mode is hard to build but when you don’t know how to do it, but after you find out LP problems is very easy to solve.

2. A.

x1 – number of cask golden glow

x2 – number of cask autumn fresh

x3 – number of cask sparkling light

7500 * x1 + 8200 * x2 + 9500 * x3 –> max

20*x1 + 24*x2 + 18*x3 <= 1700

x1 + x2 + x3 <= 80

11*x1 + 8*x2 + 16*x3

Mosel mode :

model “cider”

!sample declarations section

declarations

x1,x2,x3: mpvar ! Decision variables: produced quantities

end-declarations

Profit:= 7500 * x1 + 8200 * x2 + 9500 * x3 !objective function

tonesApple:= 0.2*x1 + 0.24*x2 + 0.18*x3 <= 17 ! tones of apples

processingTime:= 11*x1 + 8*x2 + 16*x3 <= 2500 ! hrs of processing time

casks:= x1 + x2 + x3 <= 80 ! can store at most 80 casks

Project Details

• Date February 12, 2017
• Tags Mosel Programming, Programming