problem

18

Click here to load reader

Upload: fikre-ayele

Post on 01-Nov-2014

41 views

Category:

Documents


0 download

DESCRIPTION

mthematics

TRANSCRIPT

Page 1: problem

EGR 599 Advanced Engineering Math II _____________________ LAST NAME, FIRST Problem set #4

1. (P. 15.1 Chapra1) A company makes two types of products, A and B. These products are

produced during a 40-hour work week and then shipped out at the end of the week. They require

20 and 5 kg of raw material per kg of product, respectively, and the company has access to

10,000 kg of raw material per week. Only one product can be created at a time with a production

times for each of 0.05 and 0.15 hrs, respectively. The plant can only store 550 kg of total

product per week. Finally, the company makes profits of $45 and $30 on each unit of A and B,

respectively.

(a) Set up the linear programming problem to maximize profit.

(b) Solve the linear programming problem graphically.

(c) Solve the linear programming problem with the simplex method.

(d) Solve the linear programming problem with Matlab.

Solution

(a) Set up the linear programming problem to maximize profit.

Define xa = amount of product A produced, and xb = amount of product B produced. The objective function is to maximize profit,

P x xa b 45 30

Subject to the following constraints

20 5 10000x xa b {raw materials}

0 05 015 40. .x xa b {production time}

x xa b, 0 {positivity}

(b) To solve graphically, the constraints can be reformulated as the following straight lines

x xb a 2000 4 {raw materials}

x xb a 266 667 0 3333. . {production time}

x xb a 550 {storage}

The objective function can be reformulated as

x P xb a ( / ) .1 30 15

1 Chapra and Canale, Numerical Methods for Engineers , Mc-Graw Hill, 4 th Edition, 2002

Page 2: problem

The constraint lines can be plotted on the xb-xa plane to define the feasible space. Then the objective function line can be superimposed for various values of P until it reaches the boundary. The result is P 23700 with xa 483 and xb 67. Notice also that material and storage are the binding constraints and that there is some slack in the time constraint.

0

100

200

300

0 200 400 600P

= 15000

P = 5000

P = 23700

xb

xa

time

storage

material

optimum

(c) The simplex tableau for the problem can be set up and solved as

Basis P xa xb S1 S2 S3 Solution InterceptP 1 -45 -30 0 0 0 0

material S1 0 20 5 1 0 0 10000 500time S2 0 0.05 0.15 0 1 0 40 800storage S3 0 1 1 0 0 1 550 550

Basis P xa xb S1 S2 S3 Solution InterceptP 1 0 -18.75 2.25 0 0 22500

xa xa 0 1 0.25 0.05 0 0 500 2000time S2 0 0 0.1375 -0 1 0 15 109.0909storage S3 0 0 0.75 -0.05 0 1 50 66.66667

Basis P xa xb S1 S2 S3 Solution InterceptP 1 0 0 1 0 25 23750

xa xa 0 1 0 0.067 0 -0.333 483.33333time S2 0 0 0 0.007 1 -0.183 5.8333333xb xb 0 0 1 -0.07 0 1.333 66.666667

(d) Solve the linear programming problem with Matlab.

The problem is reformulated using slack variable S1, S2, and S3

Minimize y = 45xa 30xb

Subject to

20xa + 5xb + S1 = 10000 0.05xa + 0.15xb + S2 = 40xa + xb + S3 = 550

Page 3: problem

xa, xb, S1, S2, and S3 0

The arguments for the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB) are given as

f = , A = 0, b = 0, Aeq = , beq = , LB = , UB =

--------------------------------------------------------------------

% Set 4, Problem 1

f=[-45;-30;0;0;0];

A=zeros(5,5);

b=zeros(5,1);

Aeq=[20 5 1 0 0 ;0.05 0.15 0 1 0;1 1 0 0 1;0 0 0 0 0;0 0 0 0 0];

beq=[10000;40;550;0;0];

LB=[0;0;0;0;0];UB=[inf;inf;inf;inf;inf];

x=linprog(f,A,b,Aeq,beq,LB,UB)

>> s4p1

Optimization terminated successfully.

x =

483.3333

66.6667

0.0000

5.8333

0.0000

------------------------------------------------------The solution from the Matlab program is

xa = 483.3333

x2 = 66.6667

S1 = 0

S2 = 5.8333

S3 = 0

Page 4: problem

2. (P. 15.2 Chapra)A gas processing plant receives a fixed amount of raw gas each week. The raw gas is processed into three grades of heating gas, regular, premium, and supreme quality. Their production involves both time and on-site storage constraints. For example, only one of the grades can be produced at a time, and the facility is open for only 80 hrs/week. There is limited on-site storage for each of the products. All these factors are listed in Table 4-1 with a metric ton denoted tonne equal to 1000 kg.

Table 4-1Product

Resource Regular Premium Supreme AvailabilityRaw gasProduction timeStorage

7 m3/tonne10 hr/tonne9 tonnes

11 m3/tonne8 hr/tonne6 tonnes

15 m3/tonne12 hr/tonne5 tonnes

154 m3/week80 hr/week

Profit 150/tonne 175/tonne 250/tonne

(a) Set up the linear programming problem to maximize profit.

(b) Solve the linear programming problem with the simplex method.

(c) Solve the linear programming problem with Matlab.

Solution

(a) Set up the linear programming problem to maximize profit.

The total LP formulation is given by

Maximize Z x x x 150 175 2501 2 3 {Maximize profit}

subject to

7 11 15 1541 2 3x x x {Material constraint}10 8 12 801 2 3x x x {Time constraint}x1 9 {“Regular” storage constraint}

{“Premium” storage constraint}{“Supreme” storage constraint}

x x x1 2 3 0, , {Positivity constraints}

(b) The simplex tableau for the problem can be set up and solved as

Basis P x1 x2 x3 S1 S2 S3 S4 S5 Solution InterceptP 1 -150 -175 -250 0 0 0 0 0 0S1 0 7 11 15 1 0 0 0 0 154 10.2667S2 0 10 8 12 0 1 0 0 0 80 6.66667S3 0 1 0 0 0 0 1 0 0 9 S4 0 0 1 0 0 0 0 1 0 6 S5 0 0 0 1 0 0 0 0 1 5 5

Basis P x1 x2 x3 S1 S2 S3 S4 S5 Solution InterceptP 1 -150 -175 0 0 0 0 0 250 1250S1 0 7 11 0 1 0 0 0 -15 79 7.18182

Page 5: problem

S2 0 10 8 0 0 1 0 0 -12 20 2.5S3 0 1 0 0 0 0 1 0 0 9 S4 0 0 1 0 0 0 0 1 0 6 6x3 0 0 0 1 0 0 0 0 1 5

Basis P x1 x2 x3 S1 S2 S3 S4 S5 Solution InterceptP 1 68.75 0 0 0 21.88 0 0 -12.5 1687.5S1 0 -6.75 0 0 1 -1.375 0 0 1.5 51.5 34.3333x2 0 1.25 1 0 0 0.125 0 0 -1.5 2.5 -1.66667S3 0 1 0 0 0 0 1 0 0 9 S4 0 -1.25 0 0 0 -0.125 0 1 1.5 3.5 2.33333x3 0 0 0 1 0 0 0 0 1 5 5

Basis P x1 x2 x3 S1 S2 S3 S4 S5 SolutionP 1 58.3333 0 0 0 20.83 0 8.33 0 1716.7S1 0 -5.5 0 0 1 -1.25 0 -1 0 48x2 0 0 1 0 0 0 0 1 0 6S3 0 1 0 0 0 0 1 0 0 9S5 0 -0.8333 0 0 0 -0.083 0 0.67 1 2.3333x3 0 0.83333 0 1 0 0.083 0 -0.67 0 2.6667

(c) Solve the linear programming problem with Matlab.

The problem is reformulated as

Minimize y =7 11 15 1541 2 3x x x {Material constraint}10 8 12 801 2 3x x x {Time constraint}x1 9 {“Regular” storage constraint}

{“Premium” storage constraint}{“Supreme” storage constraint}

x x x1 2 3 0, , {Positivity constraints}

We use the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB)

The coefficient vector f for the objective function is

f =

The matrix coefficient A for the inequality constraints is

A =

The right hand vector b for the inequality constraints is

Page 6: problem

b =

Since there are no equality constraints in this example, Aeq and beq are zeros.

Aeq = 0 and beq = 0

The lower and upper bounds vectors are given by

LB = and UB =

The following Matlab statements are used to solve this linear programming problem.

Matlab Program -----------------------------------------------------

% Set 4, Problem 2f=[-150;-175;-250];A=[7 11 15;10 8 12;0 0 0];b=[154;80;0];Aeq=zeros(3,3);beq=zeros(3,1);LB=[0;0;0];UB=[9;6;5];x=linprog(f,A,b,Aeq,beq,LB,UB)

>> s4p2Optimization terminated successfully.x = 0.0000 6.0000 2.6667-------------------------------------------------------------------------------------------------------------The solution from the Matlab program is

x1 = 0

x2 = 6

x3 = 2.6667

Page 7: problem

3. (P. 15.3 Chapra)

Consider the linear programming problem:

Maximize f(x, y) = x + y, subject to

x + 2.5y 15

x + y 7

2x + y 9

x 0 and y 0

(a) Solve the linear programming problem graphically.

(b) Solve the linear programming problem with the simplex method.

(c) Solve the linear programming problem with Matlab.

Solution

(a) Solve the linear programming problem graphically.

To solve graphically, the constraints can be reformulated as the following straight lines

y = 6 0.4x

y = 7 x

y = 9 2x

The objective function can be reformulated as

y = x +f(x, y)

The constraint lines can be plotted on the x-y plane to define the feasible space. Then the

objective function line can be superimposed for various values of f(x, y) until it reaches the

boundary. The result is f(x, y) 8.33 with x = 23 and y = 5.

Page 8: problem

(b) Solve the linear programming problem with the simplex method.

Maximize f(x, y) = x + y, subject to

x + 2.5y + S1 = 15

x + y + S2 = 7

2x + y + S3 = 9

x, y, S1, S2, S3 0

at A, x = 0 y = 0

S1 = 15, S2 = 7, S3 = 9, and f(x, y) = 0

at B, y = 0 S3 = 0

x + S1 = 15

x + S2 = 7

2x = 9

x = 4.5, S1 = 10.5, S2 = 2.5, and f(x, y) = 7.5

at C, S3 = 0 S2 = 0

x + 2.5y + S1 = 15

x + y = 7

2x + y = 9

x = 2, y = 0, S1 = 0.5, and f(x, y) = 8.33

Page 9: problem

(c) Solve the linear programming problem with Matlab.

The problem is reformulated as

Minimize y = x y

x + 2.5y + S = 15

x + y 7

2x + y 9

x, y, and S 0

We use the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB).

The coefficient vector f for the objective function is

f =

The matrix coefficient A for the inequality constraints is

A =

The right hand vector b for the inequality constraints is

b =

The equality constraints Aeq and beq are given as

Aeq = and beq =

The lower and upper bounds vectors are given by

LB = and UB =

The following Matlab statements are used to solve this linear programming problem.

Matlab Program -----------------------------------------------------

Page 10: problem

% Set 4, Problem 3f=[-5/3;-1;0];A=[1 1 0;2 1 0;0 0 0];b=[7;9;0];Aeq=[1 2.5 1; 0 0 0;0 0 0];beq=[15;0;0];LB=[0;0;0];UB=[inf;inf;inf];x=linprog(f,A,b,Aeq,beq,LB,UB)

>> s4p3Optimization terminated successfully.x = 2.0000 5.0000 0.5000-------------------------------------------------------------------------------------------------------------The solution from the Matlab program is

x1 = 2

x2 = 5

S = 0.5

Page 11: problem

4. (P. 13.7 Chapra) Employ the following methods to find the maximum of

f(x) = 2x 1.75x2 + 1.1x3 0.25x4

a) Quadratic interpolation (x0 = 1.75, x1 = 2, x2 = 2.25, iterations = 5)b) Newton method (x0 = 2.5, |xi+1 xi| < 0.01)

Solution

f(x) = 2x 1.75x2 + 1.1x3 0.25x4

f’(x) = 2 3.5x + 3.3x2 x3

f”(x) = 3.5 + 6.6x 3x2

% Set 4, problem 4

fx = '2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4';

x0 = 1.75; x = x0; f0 = eval(fx);

x1 = 2; x = x1; f1 = eval(fx);

x2 = 2.25; x = x2; f2 = eval(fx);

f3save=f0;

disp('Quadratic interpolation')

for i=1:5

top = f0*(x1*x1-x2*x2)+f1*(x2*x2-x0*x0)+f2*(x0*x0-x1*x1);

bot = 2*f0*(x1-x2)+2*f1*(x2-x0)+2*f2*(x0-x1);

x3 = top/bot;

x = x3; f3 = eval(fx);

fprintf('x3 = %10.5f, f(x3) = %10.5f\n',x,f3)

% if abs(f3save-f3)<.00001, break, end

f3save=f3;

if x3<x0

x0=x3;x2=x1;x1=x0;

f0=f3;f2=f1;f1=f0;

elseif x3<x1

x2=x1;x1=x3;

f2=f1;f1=f3;

elseif x3<x2

x0=x1;x1=x3;

f0=f1;f1=f3;

else

Page 12: problem

x0=x1;x1=x2;x2=x3;

f0=f1;f1=f2;f2=f3;

end

end

disp('Newton method')

x = 2.5;

for i=1:10

fx = 2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4;

fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)

dx = (2 - 3.5*x + 3.3*x^2 - x^3)/(- 3.5 + 6.6*x - 3*x^2 );

x= x - dx;

if abs(dx)<0.01, break, end

end

fx = 2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4;fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)

>> s4p4Quadratic interpolationx3 = 2.06166, f(x3) = 1.80775x3 = 2.07412, f(x3) = 1.80813x3 = 2.07807, f(x3) = 1.80817x3 = 2.07898, f(x3) = 1.80817x3 = 2.07926, f(x3) = 1.80817Newton methodx = 2.50000, f(x) = 1.48438x = 2.19565, f(x) = 1.78800x = 2.09170, f(x) = 1.80796x = 2.07951, f(x) = 1.80817x = 2.07935, f(x) = 1.80817

Page 13: problem

5. (P. 13.9 Chapra) Employ the following methods to find the optimum of

f(x) = 6x + 7.5x2 + 3x3 + x4

a) Quadratic interpolation (x0 = 2, x1 = 1, x2 = 1, iterations = 5)b) Newton method (x0 = 1, |xi+1 xi| < 0.01)

Solution

f(x) = 6x + 7.5x2 + 3x3 + x4

f’(x) = 6 + 15x + 9x2 + 4x3

f”(x) = 15 + 18x + 12x2

% Set 4, problem 5

fx = '6*x + 7.5*x^2 + 3*x^3 + x^4';

x0 = -2; x = x0; f0 = eval(fx);

x1 = -12; x = x1; f1 = eval(fx);

x2 = 1; x = x2; f2 = eval(fx);

f3save=f0;

disp('Quadratic interpolation')

for i=1:5

top = f0*(x1*x1-x2*x2)+f1*(x2*x2-x0*x0)+f2*(x0*x0-x1*x1);

bot = 2*f0*(x1-x2)+2*f1*(x2-x0)+2*f2*(x0-x1);

x3 = top/bot;

x = x3; f3 = eval(fx);

fprintf('x3 = %10.5f, f(x3) = %10.5f\n',x,f3)

% if abs(f3save-f3)<.00001, break, end

f3save=f3;

if x3<x0

x0=x3;x2=x1;x1=x0;

f0=f3;f2=f1;f1=f0;

elseif x3<x1

x2=x1;x1=x3;

f2=f1;f1=f3;

elseif x3<x2

x0=x1;x1=x3;

f0=f1;f1=f3;

Page 14: problem

else

x0=x1;x1=x2;x2=x3;

f0=f1;f1=f2;f2=f3;

end

end

disp('Newton method')

x = -1;

for i=1:10

fx = 6*x + 7.5*x^2 + 3*x^3 + x^4;

fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)

dx = (6 + 15*x + 9*x^2 + 4*x^3)/(15 + 18*x + 12*x^2);

x= x - dx;

if abs(dx)<0.01, break, end

end

fx = 6*x + 7.5*x^2 + 3*x^3 + x^4;

fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)

>> s4p5

Quadratic interpolation

x3 = -0.50980, f(x3) = -1.43952

x3 = 0.18902, f(x3) = 1.42358

x3 = -0.35706, f(x3) = -1.30649

x3 = -0.50715, f(x3) = -1.43906

x3 = -0.52720, f(x3) = -1.44099

Newton method

x = -1.00000, f(x) = -0.50000

x = -0.55556, f(x) = -1.43766

x = -0.52782, f(x) = -1.44099

x = -0.52803, f(x) = -1.44099

Page 15: problem

6. Minimize the function f(x, y) = 4x2 + y2 2xy, using Newton method with x0 = [1 1]T.

Solution

x i+1 = x i Hi-1f(x i) (1)

f(x i) =

Hi =

Let x i = x i+1 x i, equation (1) becomes

Hix i = f(x i)

For i = 0, f(x i) = =

x = 1, y = 1

x1 = x0 + x = 1 1 = 0

y1 = y0 + y = 1 1 = 0

f(x = 0, y = 0) = 0 is the solution

a company makes two products a and b with two processing departments and wishes to add one

new product line what must be product C’s unit profit in order to profitably add it to the product

line