0% found this document useful (0 votes)
87 views

L12 Optim Constrain

This document discusses constrained optimization techniques including linear programming and MATLAB's fmincon function. It provides an example of setting up and solving a linear programming problem to maximize profit given limited resources using graphical and simplex methods. It also gives an example of using fmincon to minimize a nonlinear objective function subject to nonlinear inequality constraints.

Uploaded by

andresboy123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

L12 Optim Constrain

This document discusses constrained optimization techniques including linear programming and MATLAB's fmincon function. It provides an example of setting up and solving a linear programming problem to maximize profit given limited resources using graphical and simplex methods. It also gives an example of using fmincon to minimize a nonlinear objective function subject to nonlinear inequality constraints.

Uploaded by

andresboy123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Numerical Methods for Civil Engineers

Lecture 12 Constrained Optimization

- Linear Programming - Nonlinear Constrained Optimization - MATLABs fmincon Function

Suranaree
UNIVERSITY OF TECHNOLOGY NAKORNRATCHSIMA

Mongkol JIRAVACHARADET School of Civil Engineering

LINEAR PROGRAMMING Standard Form


Objective Function: Maximize Z = c1x1+ c2x2+ . . . + cnxn where cj = payoff of jth activity xj = magnitude of jth activity Z = total payoff due to all activities Constraints: ai1x1 + ai2x2 + . . . + ainxn bi

where aij = amount of ith resource used by jth activity bi = amount of ith resource available

Example: Setting Up the Linear Programming Problem Producing product with limited resources: Gas processing plant Product Resource Raw gas Production time Storage Profit Set Regular 7 m3/ton 10 hr/ton 9 ton 150 / ton Premium 11 m3/ton 8 hr/ton 6 ton 175 / ton Resource Availability 77 m3/week 80 hr/week

x1 = amount of regular gas produced x2 = amount of premium gas produced

Total profit = 150x1 + 175x2

Maximize Z = 150x1 + 175x2 Objective function Total gas used = 7x1 + 11x2 cannot exceed 77 m3/week 7x1 + 11x2 10x1 + 8x2 x1 9 x2 0 77 80 6 Constraints

x1 , x2

Graphical Solution x2

Maximize Z = 150x1 + 175x2


7 x1 + 11x2 77 10 x1 + 8 x2 80 0 x1 9 0 x2 6 (1) (2) (3) (4)

10x1+8x2 = 80 10x1+8x2 80 7 6 7x1+11x2 = 77

7x1+11x2

77 x1 9 11

Increasing Objective Function x2

From Z = 150x1 + 175x2 For Z = 0, 150x1 + 175x2 = 0

Unique solution Z = 1400

0 Z=0 Z = 600

x1

Other Possible Outcomes x2 Objective function parallel to constraint. Alternate Solution

x1

No Feasible Solution x2

x1

Unbounded Problems x2

x1

Simplex Method Assumption: optimal solution will be an extreme point x2 Extreme points: corner points where two constraints meet Z = 1400 Objective function is LINEAR

Z=0

Z = 600

x1

Slack Variables Reformulate constraint inequalities as equalities slack variable

7 x1 + 11x2 77 7 x1 + 11x2 + S1 = 77
Resource constraint How much slack of the resource is available ?

IF . . . S1 = + Surplus resource is not fully used. S1 = - Exceeded the constraint. S1 = 0 Exactly meet the constraint. All resource is used.

Fully Augmented Version Maximize Z = 150x1 + 175x2 subject to


7 x1 + 11x2 77 10 x1 + 8 x2 80 0 x1 9 0 x2 6
7 x1 + 11x2 + S1 10 x1 + 8 x2 + S2 x1 + S3 x2 + S4 = 77 = 80 =9 =6 0

x1 , x2 , S1 , S 2 , S3 , S4

Linear algebraic equations solving 4 equations with 6 unknowns

Algebraic Solution
Underspecified : more unknowns (6) than equations (4) x2
10x1 + 8x2 = 80 S2 = 0 x1 = 9, S3 = 0 Extreme Point Zero Variables

x2 = 6, S4 = 0

E D C
7x1 + 11x2 = 77 S1 = 0

A B C D E

x1, x2 x2, S2 S1, S2 S1, S4 x1, S4

A 0

B 9 x1

@ Extreme point : 4 equations with 4 unknowns The problem can be solved.

For point E : Setting x1 = S4 = 0 The standard form reduced to


0

nonbasic variables

7 x1 + 11x2 + S1 0 10 x1 + 8 x2 + S2 0 x1 + S3 0 x2 + S4

= 77 = 80 =9 =6

11x2 + S1 8 x2 + S2 S3 x2

= 77 = 80 =9 =6

which can be solved for x1 0 x2 6 S1 11 S2 32 S3 9 S4 0 basic variables

Simplex Method Implementation Start at point A : Setting x1 = x2 = 0

S1 S2 S3 S4

= 77 = 80 = 9 = 6

Tableau: Z - 150x1 - 175x2 - 0S1 - 0S2 - 0S3 - 0S4 = 0 Basic Z S1 S2 S3 S4 Z x1 x2 S1 0 1 0 0 0 S2 0 0 1 0 0 S3 0 0 0 1 0 S4 Solution Intercept 0 0 0 0 1 0 77 80 9 6 11 8 9

1 -150 -175 0 7 11 0 10 8 0 1 0 0 0 1

Graphical Depiction of Simplex Method x2 S2 6 E D C S1 A 0 B 8 F 11 x1 S4 S3 Change x1 to basic variable (entering variable) Move from A horizontally Check intercept: Intercept = Solution (for each S) x1 coeff. S2 give min. intercept = 8

Therefore, change S2 to nonbasic(leaving) variable.

Move to point B : Setting x2 = S2 = 0

7 x1 + S1 10 x1 x1

+ S3 S4

= = = =

77 80 9 6

Pivot row S2: Dividing row by 10 and replacing S2 by x1 Basic Z S1 x1 S3 S4 Z Z x1 x2 S1 0 1 0 0 0 0 S2 0 0 0.1 0 0 S3 0 0 0 1 0 S4 Solution 0 0 0 0 1 0 0 77 8 9 6 1200 x -150 1 -150 -175 0 7 11 0 1 0.8 0 1 0 0 0 1 1 0 -55

15 0

Perform same operation on the remaining rows, Basic Z S1 x1 S3 S4 Z 1 0 0 0 0 x1 x2 S1 S2 S3 0 0 0 1 0 S4 Solution Intercept 0 0 0 0 1 1200 21 8 1 6 3.889 10 -1.25 6

0 -55 0 5.4 1 0.8 0 -0.8 0 1

0 15 1 -0.7 0 0.1 0 -0.1 0 0

- From A to B, objective function has increased to 1200 - S1 give min. positive intercept = 3.889 is entering variable - Move from B to C

Final Tableau: Basic Z S1 x1 S3 S4 Z 1 0 0 0 0 x1 0 0 1 0 0 x2 0 1 0 0 0 S1 S2 S3 0 0 0 1 0 S4 0 0 0 0 1 Solution 1414 3.89 4.89 4.11 2.11

10.19 7.87 0.19 -0.13 -0.15 0.20 0.15 -0.20 -0.19 0.13

- No negative coeff. in objective func. row, No more increasing. Final solution: x1 = 3.89, x2 = 4.89 Z = 1414

MATLABs fmincon Function


2 f ( x) = e x1 ( 4 x12 + 2 x2 + 4 x1 x2 + 2 x2 + 1)

subject to the constraints:

x1 x2 x1 x2 1.5 x1 x2 10

rewrite the constraints in the form c(x) 0 :

x1 x2 x1 x2 + 1.5 0 x1 x2 10 0

Write M-file confun.m for the constraints function [c, ceq] = confun(x) % nonlinear inequality constraints c = [1.5 + x(1)*x(2) - x(1) - x(2); -x(1)*x(2) - 10]; % nonlinear equality constraints ceq = [];
> x0 = [-1,1]; > options = optimset(LargeScale,off); > [x, fval] = . . . fmincon(objfun,x0,[],[],[],[],[],[],confun,options) x = -9.5474 fval = 0.0236

1.0474

You might also like