Professional Documents
Culture Documents
Linear and Non-Linear Programming With Matlab
Linear and Non-Linear Programming With Matlab
Product A Product B
Required time in 1h 1h
department A
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.
Mathematical formulation:
F1 ( x) 4 x1 5 x2
g1 : x1 x2 200
x1 0 , x2 0 , x2 150
Data:
H1 H2 H3 H4 p1
H H1 H2 H 3 p
H 2 p 2 , A H H H1 H 4 , b 1 14 3 4T
Here H3 H2 H1 H2 p3 3 2
H 4 H3 H2 H1 4
p
10 8 7 6 3 2 1 0 2 1 0 0
8 10 8 7
H 2 3 2 1 1 0
H1
2 1
H3
and 7 8 10 8 , 2
1 2 3 2 , 0 1 2 1 , H 4 I ,
6 7 8 10 0 1 2 3 0 0 1 2
1 0 2 0
1 0 2 0
p1 , p2 , p3 , p4 .
2 0 4 0
2
0
4 0
Solution:
[x,f]=quadprog(H,p,A,b,Aeq,beq,lb,ub,x0,options)
1
x H AT p
b) using given formula
A 0 b
3. NONLINEAR UNCONSTRAINED PROGRAMMING EXAMPLE
f ( x) (C 1) / 8 max ,
1 2
C ( A B 2 3) sin( A2 B 2 2) ,
2
A 6 x1 3 , B 6 x2 3
0 x1 1 , 0 x2 1
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:
g ( x) 5 x12 x 22 x3 2
x1 0 , x2 0 , x3 0 .
[x,fn,code]=fmincon(@obj_fn,x0,A,b,Aeq,beq,lb,ub,@constraint_fn)
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 2x1 0 , x12 2x2 0 , x 12 x 22 3 0
x1 x2
x2 y2
f cos(x) cos(y) max
200 200
2 x1 10 , 2 x2 10
7. MULTICRITERIAL OPTIMIZATION
Problem formulation:
F ( x) min ,
Vilfredo Pareto, an Italian economist who used the concept in his studies of economic efficiency
and income distribution
Goals:
F1 ( x) ( ) EI / min
2 L2
F2 ( x) 2b(c1d1 c2 (d 2 d1 ) c3 (d 3 d 2 )) min,
Variables: d1 , d2 , d3 , b , L
Notation used:
Constraints:
Limits on variables:
i i Ei ci
Main program: (we are using function fminimax, because gamultiobj does not
support nonlinear constraints).
% Multiobjective optimization
% Vibrating platform
E=[1.6 70 200]*10^9
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