Beruflich Dokumente
Kultur Dokumente
DATE: 04/09/2013
Q.1. Find the solution of the following Linear Programming problem using MATLAB function linprog and Optimization Tool. a) Minimize subject to f=-x1-2x2-x3 2x1-x2+5x3<=6 2x1+x2-x3<=2 4x1+x2+x3<=6, MATLAB Code:
clc; f=[-1 -2 -1]; A=[2 -1 5;2 1 -1;4 1 1]; b=[6;2;6]; lb=[0 0 0]; [x,fval]=linprog(f,A,b,[],[],lb,[])
Optimization Tool:
62
Remarks: The feasible optimal solution has been obtained using MATLAB m.file code as well as optimization tool . b) Minimize subject to f=-3x1-2x2 x1-x2<=1 3x1-2x2<=6, MATLAB Code:
clear all; close all; clc; f=[-3 -2]; A=[1 -1;3 -2]; b=[1;6]; lb=[0;0]; [x,fval]=linprog(f,A,b,[],[],lb,[])
Result: Exiting: One or more of the residuals, duality gap, or total relative error has stalled: the dual appears to be infeasible (and the primal unbounded). (The primal residual < TolFun=1.00e-008.) x = 1.0e+014 * 3.2081 4.8121 fval = -1.9248e+015 Optimization Tool:
63
Remarks: The solution of the minimization function was unbounded. So solution is infeasible solution.
c) Minimize subject to
MATLAB Code:
clear all; close all; clc; f=[-40 -100]; A=[10 5;4 10;2 5]; b=[2500;2000;900]; lb=[0;0]; [x,fval]=linprog(f,A,b,[],[],lb,[])
64
d) Minimize subject to
65
MATLAB Code:
clear all; close all; clc; f=[-1 -2 -1]; A=[2 1 -1;2 -1 5;4 1 1]; b=[2;6;6]; lb=[0 0 0]; [x,fval]=linprog(f,A,b,[],[],lb,[])
Result: Optimization terminated. x= 0.0000 4.0000 2.0000 fval = Optimization Tool: -10.0000
Q.2 Find the solution of the following non-linear optimization problem using the MATLAB function fmincon. Minimize Subject to f=9.82x1x2+2x2 g1=2500/x1x2-500<=0; g2=2500/x1x2-((x12+x22)/0.5882)<=0; g3=-x1+2<=0; g4=x1-14<=0; g5=-x2+0.2<=0; g6=x2-0.8<=0; MATLAB Code : a) With Non Linear Function solver fmincon: The objective function objpara.m
function y =objpara(x) y=9.82*x(1)*x(2)+2*x(1);
Result: Active inequalities (to within options.TolCon = 1e-006): x= fval = c= 9.0638 35.9287 -61.0125 67 0.2000
Optimization Tool:
Remarks: The solution of non-linear optimization problem has been obtained using MATLAB function fmincon.
68
Q.3 Find the solution of the following non-linear optimization problem using the MATLAB function ga (Genetic Algorithm). Minimize Subject to f=9.82x1x2+2x2 g1=2500/x1x2-500<=0; g2=2500/x1x2-((x12+x22)/0.5882)<=0; g3=-x1+2<=0; g4=x1-14<=0; g5=-x2+0.2<=0; g6=x2-0.8<=0; xi>=0 for i=1,2.
MATLAB Code: First, create the objective function an M-file named spobf_1.m as follows:
function f=spobj_1(x) f=9.82*x(1)*x(2)+2*x(1);
To minimize the fitness function, you need to pass a function handle to the fitness function as the first argument to the ga function, as well as specifying the number of variables as the second argument. Lower and upper bounds are provided as LB and UB respectively. In addition, you also need to pass a function handle to the nonlinear constraint function.
ObjectiveFunction = @spobj_1; nvars = 3; % Number of variables LB = [2 0.2]; % Lower bound ConstraintFunction = @simple_constraint; [x,fval]=ga(ObjectiveFunction,nvars,[],[],[],[],LB,[14 0.8],ConstraintFunction)
Result: Optimization terminated: average change in the fitness value less than options.TolFun and constraint violation is less than options.TolCon. x= fval = Optimization Tool: 9.0632 35.9300 0.2000
69
Remark: The solution of the non-linear optimization problem using the MATLAB function ga (Genetic Algorithm) has been obtained.
Q.4 Find the solution of the following linear programming problem using MATLAB function ga (Genetic Algorithm). Minimize Subject to f=-x1-2x2-x3 2x1+x2-x3<=2 2x1-x2+5x3<=6 4x1+x2+x3<=6, xi>=0 for i=1,2,3.
70
Result: Optimization terminated: average change in the fitness value less than options.TolFun. x= fval = exitflag = 0.0087 -9.9229 1 3.9644 1.9855
Optimization Tool:
Remark: The solution of linear programming problem has been obtained using ga function. 71
Q.5 Find the minimum solution of the following function using MATLAB simulated annealing function. f=500-20x1-26x2-4x1x2+4x12+3x22
OptimizationTool:
Remark: The minimum value of the function using MATLAB function simulated annealing has been obtained.
72