OPTIMIZATION LINEAR PROGRAMMING EXAMPLE Production

advertisement
OPTIMIZATION
1. LINEAR PROGRAMMING EXAMPLE
Production planning: Two products A and B, require production time in two
department.
Product A
Product B
Required time in
department A
1h
1h
Required time in
department B
1.25 h
0.75 h
Available time in each department are 200 h. Maximum market potential for
product B is 150 units. Profit per unit is 4$ for product A and $5 for product B.
Aim: total profitmax.
Mathematical formulation:
F1 ( x)  4 x1  5 x2
g1 :
x1  x2  200
g2 :
1.25 * x1  0.75 x2  200
x1  0 , x2  0 , x2  150
MATLAB solution using function linprog
f=[-4 -5]
lb=[0 0]
ub=[Inf 150]
A=[1 1; 1.25 0.75]
b=[200;200]
[x,f,flag,output]=linprog(f,A,b,[],[],lb,ub)
% options = optimset('LargeScale', 'off', 'Simplex', 'on')
2. QUADRATIC PROGRAMMING EXAMPLE
Solve the following problem:
1
f ( x)  xT Hx  xT p  min
2
Ax  b
Data:
 H1
H
 2
Here H   H 3

H 4
and
H2
H1
H2
H3
H2
H1
H3
H2
H4 
 p1 

p 
H3 
p   2 , A  H H
 p3 
3
2
H2 

 
H1 
 p4 
10 8 7 6 
3
 8 10 8 7 
2


H1 
H 
 7 8 10 8  , 2 1



 6 7 8 10 
0
H1 H 4  , b  1 14 3  4T
2 1 0
2

1
3 2 1
H 
2 3 2 , 3 0


1 2 3
0
1 
0 
2
0 
  1
0 
2
0 






p1 
p 
p 
p  
 2  , 2 0  , 3  4  , 4 0  .
 
 
 
 
 2
0 
  4
0 
Solution:
a) using MATLAB function quadprog
[x,f]=quadprog(H,p,A,b,Aeq,beq,lb,ub,x0,options)
H
 x



b) using given formula  
 A
 
1
AT   p 
  
0   b 
1 0 0
2 1 0
1 2 1 , H 4  I ,

0 1 2
3. NONLINEAR UNCONSTRAINED PROGRAMMING EXAMPLE
Find maximum on the bottom of the bottle:
f ( x)  (C  1) / 8  max ,
C
1 2
( A  B 2  3)  sin( A2  B 2  2) ,
2
A  6 x1  3 , B  6 x2  3
0  x1  1 , 0  x2  1
MATLAB solution using fminunc or fminsearch
x10=linspace(0,1,50);
x20=linspace(0,1,50);
[x1,x2]=meshgrid(x10,x20);
A=6*x1-3; B=6*x2-3;
C=(A.^2+B.^2+3)./2+sin(A.^2+B.^2+2);
bottle=(C+1)/8;
colormap([1 1 1])
surf(x1,x2,bottle);
zlabel('f')
xlabel('x1')
ylabel('x2')
view(-10,45)
text(0.1,0.9,1.8,'Bottle bottom')
obj=inline('-(((6*x(1)-3)^2+(6*x(2)-3)^2+3)/2+sin((6*x(1)-3)^2+(6*x(2)3)^2+2)+1)/8','x')
x0=[0.2 0.8]
[xx,ff]=fminsearch(obj,x0)
a) try solution with initial points: x0=[0.2 0.9] and x0=[0.3 0.6] and make
conclusions.
b) try solution using function fminunc (syntax is the same, but fminsearch
uses derivative free method).
c) use objective function given in file instead of inline function
4. NONLINEAR CONSTRAINED PROGRAMMING EXAMPLE
Problem formulation:
f ( x)   x13  x23  2x1 x32  min
h( x)  2 x1  x 22  x3  5
g ( x)  5 x12  x 22  x3  2
x1  0 , x2  0 , x3  0 .
Find solution(s) to posed optimization problem using function fmincon
[x,fn,code]=fmincon(@obj_fn,x0,A,b,Aeq,beq,lb,ub,@constraint_fn)
5. LAGRANGE MULTIPLIERS METHOD
Problem formulation:
f ( x)  x12 x2  min
h( x)  x 12  x 22  3  0
Solution:
a) Compose the Lagrange function
L  x12 x2   ( x 12  x 22  3)
b) Derive optimality conditions
L
L
L
 2 x1 x2  2x1  0 ,
 x12  2x2  0 ,
 x 12  x 22  3  0
x1
x2

c) Solve the optimality conditions using MATLAB function fsolve
x0 = [0.5;-0.5]
options=optimset('Display','iter');
[x,fval] = fsolve(@objective,x0,options)
Try different initial points
6. GLOBAL OPTIMIZATION
Problem_1:
x2
y2
f 

 cos(x) cos(y)  max
200 200
2  x1  10 , 2  x2  10
a) compose graph of the function
b) solve the posed problem using genetic algorithm (MATLAB function ga)
[x,fval,exitflag]
= ga(@fitness_fn,N,A,b,Aeq,beq,lb,ub,@nonlcon,options)
Problem_2: solve the optimization problems formulated in sections 3 and 5
using global optimization technique.
7. MULTICRITERIAL OPTIMIZATION
Problem formulation:
F(x) = [F1(x), F2(x),...,Fr(x)]
F ( x)  min ,
xi*  xi  xi* , i  1,..., n ,
limits on variable
g j ( x)  0 ,
inequality constraints
hk ( x)  0
j  1,...,m .
k  1,...,l
equality constraints
Pareto optimality: Pareto efficient situations are those in which any change to make any
person better off is impossible without making someone else worse off.
Vilfredo Pareto, an Italian economist who used the concept in his studies of economic efficiency
and income distribution
Red line – Pareto frontier.
How to obtain pareto front: NSGA,NSGA2, etc
Typical pareto frontier:
Example: motor on platform, vibrating platform (Magrab, et. al).
Goals:
a) Maximize of the fundamental frequency of the beam (platfor type beam) - F1
b) Minimize the cost of the material comprising the beam F2
F1 ( x)  (

2 L2
) EI /   min
F2 ( x)  2b(c1d1  c2 (d 2  d1 )  c3 (d 3  d 2 ))  min,
Variables: d1 , d2 , d3 , b , L
Notation used:
EI  (2b / 3)( E1d13  E2 (d 23  d13 )  E3 (d 33  d 23 )),
  2b( 1d1   2 (d 2  d1 )   3 (d 3  d 2 )).
Constraints:
g1 :
L  2800  0
beam mass
g2 :
d 2  d1  0.15
layer thickness
g3 :
d 3  d 2  0.01
layer thickness
Limits on variables:
0.05  d1  0.5 , 0.2  d 2  0.5 , 0.2  d 3  0.6 , 0.35  b  0.5 , 3  L  6
Given constants:
i
i
Ei
ci
1
100
1.6*109
500
2
2770
70*109
1500
3
7780
200*109
800
Main program: (we are using function fminimax, because gamultiobj does not
support nonlinear constraints).
% Multiobjective optimization
% Vibrating platform
x0=[0.3 0.3 0.4 5 3]
lb=[0.05 0.2 0.2 0.35 3]
ub=[0.5 0.5 0.6 0.5 6]
E=[1.6 70 200]*10^9
Rho=[100 2770 7780]
c=[500 1500 800]
fmin=[500 100]
A=[-1 1 0 0 0; 0 -1 1 0 0]
b=[0.15;0.01]
for k=1:5
fmax=[100+k*10 500-k*50];
[xopt, fopt]=fminimax(@vib_platform,x0,A,b,[],[],
lb,ub,@vib_constr,[],E,Rho,c,fmin,fmax);
for m=1:2
ff(m)=fopt(m)*(fmax(m)-fmin(m))+fmin(m);
end
f1(k)=ff(1);
f2(k)=ff(2);
end
[f2sort,ind2]=sort(f2)
f1sort=f1(ind2)
plot(-f1sort,f2sort,'ko-')
xlabel('Negatiivne sagedus(Hz)')
ylabel('Hind')
Function vib_platform:
function f=vib_platform(x,E,Rho,c,fmin,fmax)
[EI,mu]=beam_prop(x,E,Rho);
f1=pi/(2*x(5)^2)*sqrt(EI/mu);
f(1)=(f1-fmin(1))/(fmax(1)-fmin(1));
f2=2*x(4)*(c(1)*x(1)+c(2)*(x(2)-x(1))+c(3)*(x(3)-x(2)));
f(2)=(f2-fmin(2))/(fmax(2)-fmin(2));
end
Function beam_prop:
function [EI,mu]=beam_prop(x,E,Rho)
EI=(2*x(4)/3)*(E(1)*x(1)^3+E(2)*(x(2)^3-x(1)^3)+E(3)*(x(3)^3-x(2)^3));
mu=2*x(4)*(Rho(1)*x(1)+Rho(2)*(x(2)-x(1))+Rho(3)*(x(3)-x(2)));
end
Function vib_constr:
function [c,ceq]=vib_constr(x,E,Rho,c,fmin,fmax)
[EI,mu]=beam_prop(x,E,Rho);
c=mu*x(5)-2800;
ceq=[];
end
Download