Download presentation
Presentation is loading. Please wait.
Published byBeverly Sherman Modified over 9 years ago
1
1 Chapter 5 Nonlinear Programming Chemical Engineering Department National Tsing-Hua University Prof. Shi-Shang Jang May, 2003
2
2 Problem Statement
3
3 5-1 Examples Example: Multistage Compressor Optimization Driver stage1stage2stage3 N (ml/hr) P = 1 (atm) T T T X1X1 X2X2 T,P=64atm
4
4 Example: Multistage Compressor Optimization
5
5
6
6 5-3 Lagrange Multiplier
7
7 Lagrange Multiplier f(x,y)=(x-3) 2 +(y-3) 2,h(x)=y+x 2 -3x=0
8
8 Solution
9
9 Physical Meaning of Lagrange Multiplier – Shadow Price
10
10 5-4 Kuhn-Tucker Condition
11
11 K-T Condition - Example
12
12 K-T Condition - Example
13
13 K-T Condition - Example The above problem is reduced to :
14
14 K-T Theory Theorem 1: (Necessity) Consider the NLP problem (1). Let f, g and h be differentiable and x* is the solution, also g j (x*) and h k (x*) be differentiable. Then there exist u*, v* solve K-T problem. Theorem 2 : (Sufficiency) Consider the NLP problem (1). Let f(x) be convex, g (x) be concave functions, and h(x) be linear if there exist x*, u* and v* solve K-T problem., then x* is the optimality of (1).
15
15 K-T Theory - Example f(x)=x 1 2 -x 2 (1,1),(2,2),(1.5,1.5) f(1,1)=0, f(2,2)=2,f(1.5,1.5)=0.75<1 ∴ f convex h 1 =x 1 +x 2 -6 linear g 1 =x 1 -1 concave g 2 =30-x 1 2 -x 2 2 (1,1), (2,2),(1.5,1.5) g 2 (1,1)=28, g 2 (2,2)=22, g 2 (1.5,1.5)=25.5>25, ∴ g 2 concave The solution is global optimum
16
16 5-5 Duality of Linear Programming Primal problem: The corresponding Lagrangian can be expressed by
17
17 Duality of Linear Programming At x* Also Substitute for c i above get:
18
18 Duality of Linear Programming The Dual Problem hence becomes:
19
19 Example – Primal Problem
20
20 Example – Dual Problem
21
21 Example: Charity Work The local college’s School of American Craftsman has decided to participate seriously in a local charity event by manufacturing special commemorative desks, tables, and chairs. Resources are restricted as shown in the next table. The local lumber cooperative has donated 48 board feet of lumber. Faculty and staff have volunteered 20 finishing hours and 8 carpentry hours. The desk will be sold for $60, the table $30 and the chair for $20. The school does not expect to sell more than 5 tables. How does the school should do to maximize the profit?
22
22 Example: Charity Work- Continued ResourcesDeskTableChair Lumber (Board feet)861 Finishing hours (hours)421.5 Carpentry (hours)21.50.5
23
23 Example: Charity Work- Continued (Primal and Dual) Primal: Dual:
24
24 Example: Charity Work- Continued (MATLAB Code) %Primal b=[48;20;8;5]; Aeq=[];beq=[]; UB=[Inf Inf Inf]';LB=[0 0 0]'; f=[-60;-30;-20]; A=[8 6 1;4 2 1.5;2 1.5 0.5;0 1 0]; [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(f,A,b,Aeq,beq,LB,UB); X' LAMBDA.ineqlin %Dual ff=f; AA=-A'; bb=b; UB=[Inf Inf Inf Inf]';LB=[0 0 0 0]'; [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(bb,AA,ff,Aeq,beq,LB,UB) X' LAMBDA.ineqlin
25
25 Example: Charity Work- Continued (MATLAB Result) >> Optimization terminated successfully. ans = 2.0000 0.0000 8.0000 ans = 0.0000 10.0000 0.0000 Optimization terminated successfully. ans = 0.0000 10.0000 10.0000 0.0000 ans = 2.0000 0.0000 8.0000
26
26 5-6 MATLAB NLP tool FMINCON Finds a constrained minimum of a function of several variables. FMINCON solves problems of the form: min F(X) subject to: A*X <= B, Aeq*X = Beq (linear constraints) X C(X) <= 0, Ceq(X) = 0 (nonlinear constraints) LB <= X <= UB X=FMINCON(FUN,X0,A,B) starts at X0 and finds a minimum X to the function FUN, subject to the linear inequalities A*X <= B. FUN accepts input X and returns a scalar function value F evaluated at X. X0 may be a scalar, vector, or matrix.
27
27 MATLAB NLP tool-continued X=FMINCON(FUN,X0,A,B,Aeq,Beq) minimizes FUN subject to the linear equalities Aeq*X = Beq as well as A*X <= B. (Set A=[] and B=[] if no inequalities exist.) X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB) defines a set of lower and upper bounds on the design variables, X, so that a solution is found in the range LB <= X <= UB. Use empty matrices for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) = Inf if X(i) is unbounded above.
28
28 MATLAB NLP tool-continued X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB,NO NLCON) subjects the minimization to the constraints defined in NONLCON. The function NONLCON accepts X and returns the vectors C and Ceq, representing the nonlinear inequalities and equalities respectively. FMINCON minimizes FUN such that C(X)<=0 and Ceq(X)=0. (Set LB=[] and/or UB=[] if no bounds exist.)
29
29 Example: Multi-Stage compressor (MATLAB Code) A=[-1 0;1 -1;0 1]; B=[-1;0;64]; X0=[2;10]; X=FMINCON('stage_com',X0,A,B) function obj=stage_com(x); x1=x(1);x2=x(2); obj=x1^(0.25)+(x2/x1)^0.25+(64/x2)^(0.25);
30
30 Example: Multi-Stage compressor (MATLAB Result) >> Warning: Large-scale (trust region) method does not currently solve this type of problem, switching to medium-scale (line search). > In C:\MATLAB6p5\toolbox\optim\fmincon.m at line 213 In C:\MATLAB6p5\work\stage_com_main.m at line 4 Optimization terminated successfully: Magnitude of directional derivative in search direction less than 2*options.TolFun and maximum constraint violation is less than options.TolCon No Active Constraints X = 3.9994 16.0011
31
31 Example
32
32 Contour Plot and Constraints
33
33 MATLAB PROGRAM X0=[2 1];A=[];B=[];Aeq=[];Beq=[];LB=[0 0];UB=[5 5]; X=FMINCON('examp_FUN',X0,A,B,Aeq,Beq,LB,UB,'exa mp_NONLCON') function y=examp_FUN(x) y=(x(1)-3)^2+(x(2)-3)^2; function [c,ceq]=examp_NONLCON(x) ceq=[]; c(1)=-2*x(1)+x(2)^2+1; c(2)=0.8*x(1)^2+2*x(2)-9; X = 2.5000 2.0000
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.