Good afternoon, Would it be possible for someone to help me to correct this code in matlab unfortunately it is not working a small error appears and make some changes as : This is an multi objective genetic algorithm to optimize an turbojet two spool afterburner. % Define your own constraint functions as a cell array myCons = {@(x) f>=1, @(x) Fn>=1, @(x) m0>=1, @(x) p3>=1, @(x) Tpz>=1, @(x) o>=1, @(x) t>=1, @(x) aa>=1, @(x) WTO>=1, @(x) WLanding>=1, @(x) WF>=1, @(x) WE>=1, @(x) WPL>=1, @(x) WC>=1, @(x) M>=1, @(x) Fab>=1, @(x) V9>=1, @(x) V0>=1, @(x) QR>=1, @(x) NB>=1, @(x) T1>=1, @(x) T0>=1, @(x) L>=1, @(x) p>=1, @(x) V>=1, @(x) A>=1, @(x) bw>=1, @(x) sw>=1, @(x) WZF>=1, @(x) b>=1, @(x) cr>=1, @(x) ct>=1, @(x) WS>=1, @(x) RC>=1, @(x) l>=1, @(x) m>=1, @(x) W0>=1, @(x) VH>=1, @(x) VS>=1, @(x) VS1>=1}; confun = @(x) cellfun(@(f) f(x), myCons); % Evaluate all constraint functions for the given x % Run genetic algorithm [x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], confun, options); % ... MAIN MATLAB CODE: % Define decision variables, objectives, and constraints nvars = 56; % number of decision variables nobj = 2; % number of objectives ncon = 44; % number of constraints   % Set up genetic algorithm options options = optimoptions('ga', ... 'PopulationSize', 100, ... 'MaxGenerations', 100, ... 'MutationFcn', {@mutationuniform, 0.05}, ... 'CrossoverFcn', @crossoverarithmetic); % Define the objective functions to maximize and minimize f = @(x) [(Fn/m0)*V0/(1+f+Fab)*((V9^2)/2)-(V0^2)/2, (Fn/m0)*V0/(f*QR*NB), -1-(1/(T1/T0)), m0*V0]; g = @(x) [-f/(Fn/m0), -10^13*p3/(1.4*10^6)*exp(-71442/Tpz)*(7.56*o^7.2-1.6)*(t^0.64), -WT0*(1-WF/WTO-WE/WTO), -(WTO-WLanding), -WT0*(1-WF/WTO-WE/WTO), -M/(TSFC/Fn)]; confun = @(x) deal(myCon1(x), myCon2(x), myCon3(x), myCon4(x), myCon5(x), myCon6(x), myCon7(x), myCon8(x), myCon9(x), myCon10(x), myCon11(x), myCon12(x), myCon13(x), myCon14(x), myCon15(x), myCon16(x), myCon17(x), myCon18(x), myCon19(x), myCon20(x), myCon21(x), myCon22(x), myCon23(x), myCon24(x), myCon25(x), myCon26(x), myCon27(x), myCon28(x), myCon29(x), myCon30(x), myCon31(x), myCon32(x), myCon33(x), myCon34(x), myCon35(x), myCon36(x), myCon37(x), myCon38(x), myCon39(x), myCon40(x), myCon41(x), myCon42(x), myCon43(x), myCon44(x), myCon45(x), myCon46(x), myCon47(x), myCon48(x), myCon49(x), myCon50(x), myCon51(x), myCon52(x), myCon53(x), myCon54(x), myCon55(x) ); % Define your own constraint functions myCon1 = @(x) f>=1; myCon2 = @(x) Fn>=1; myCon3 = @(x) m0>=1; myCon4 = @(x) p3>=1; myCon5 = @(x) Tpz>=1; myCon6 = @(x) o>=1; myCon7 = @(x) t>=1; myCon8 = @(x) aa>=1; myCon9 = @(x) WTO>=1; myCon10 = @(x) WLanding>=1; myCon11 = @(x) WF>=1; myCon12 = @(x) WE>=1; myCon13 = @(x) WPL>=1; myCon14 = @(x) WC>=1; myCon15 = @(x) M>=1; myCon16 = @(x) Fab>=1; myCon17 = @(x) V9>=1; myCon18 = @(x) V0>=1; myCon19 = @(x) QR>=1; myCon20 = @(x) NB>=1; myCon21 = @(x) T1>=1; myCon22 = @(x) T0>=1; myCon23 = @(x) L>=1; myCon24 = @(x) p>=1; myCon25 = @(x) V>=1; myCon26 = @(x) A>=1; myCon27 = @(x) bw>=1; myCon28 = @(x) sw>=1; myCon29 = @(x) WZF>=1; myCon30 = @(x) b>=1; myCon31 = @(x) cr>=1; myCon32 = @(x) ct>=1; myCon33 = @(x) WS>=1; myCon34 = @(x) RC>=1; myCon35 = @(x) l>=1; myCon36 = @(x) m>=1; myCon37 = @(x) W0>=1; myCon38 = @(x) VH>=1; myCon39 = @(x) VS>=1; myCon40 = @(x) VS1>=1; % Run genetic algorithm [x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], 20:45, options);% Plot Pareto front pareto(fval(:,1:nobj/2), -fval(:,nobj/2+1:end)); xlabel('Objective 1'); ylabel('Objective 2'); zlabel('Objective 3'); Error in untitled20 (line 58) [x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], 20:45, options);% Plot Pareto front King regards

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Good afternoon,
Would it be possible for someone to help me to correct this code in matlab unfortunately it is not working a small error appears and make some changes as :

This is an multi objective genetic algorithm to optimize an turbojet two spool afterburner.

% Define your own constraint functions as a cell array
myCons = {@(x) f>=1, @(x) Fn>=1, @(x) m0>=1, @(x) p3>=1, @(x) Tpz>=1, @(x) o>=1, @(x) t>=1, @(x) aa>=1, @(x) WTO>=1, @(x) WLanding>=1, @(x) WF>=1, @(x) WE>=1, @(x) WPL>=1, @(x) WC>=1, @(x) M>=1, @(x) Fab>=1, @(x) V9>=1, @(x) V0>=1, @(x) QR>=1, @(x) NB>=1, @(x) T1>=1, @(x) T0>=1, @(x) L>=1, @(x) p>=1, @(x) V>=1, @(x) A>=1, @(x) bw>=1, @(x) sw>=1, @(x) WZF>=1, @(x) b>=1, @(x) cr>=1, @(x) ct>=1, @(x) WS>=1, @(x) RC>=1, @(x) l>=1, @(x) m>=1, @(x) W0>=1, @(x) VH>=1, @(x) VS>=1, @(x) VS1>=1};

confun = @(x) cellfun(@(f) f(x), myCons); % Evaluate all constraint functions for the given x

% Run genetic algorithm
[x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], confun, options);

% ...

MAIN MATLAB CODE:

% Define decision variables, objectives, and constraints
nvars = 56; % number of decision variables
nobj = 2; % number of objectives
ncon = 44; % number of constraints
 
% Set up genetic algorithm options
options = optimoptions('ga', ...
'PopulationSize', 100, ...
'MaxGenerations', 100, ...
'MutationFcn', {@mutationuniform, 0.05}, ...
'CrossoverFcn', @crossoverarithmetic);
% Define the objective functions to maximize and minimize
f = @(x) [(Fn/m0)*V0/(1+f+Fab)*((V9^2)/2)-(V0^2)/2, (Fn/m0)*V0/(f*QR*NB), -1-(1/(T1/T0)), m0*V0];
g = @(x) [-f/(Fn/m0), -10^13*p3/(1.4*10^6)*exp(-71442/Tpz)*(7.56*o^7.2-1.6)*(t^0.64), -WT0*(1-WF/WTO-WE/WTO), -(WTO-WLanding), -WT0*(1-WF/WTO-WE/WTO), -M/(TSFC/Fn)];
confun = @(x) deal(myCon1(x), myCon2(x), myCon3(x), myCon4(x), myCon5(x), myCon6(x), myCon7(x), myCon8(x), myCon9(x), myCon10(x), myCon11(x), myCon12(x), myCon13(x), myCon14(x), myCon15(x), myCon16(x), myCon17(x), myCon18(x), myCon19(x), myCon20(x), myCon21(x), myCon22(x), myCon23(x), myCon24(x), myCon25(x), myCon26(x), myCon27(x), myCon28(x), myCon29(x), myCon30(x), myCon31(x), myCon32(x), myCon33(x), myCon34(x), myCon35(x), myCon36(x), myCon37(x), myCon38(x), myCon39(x), myCon40(x), myCon41(x), myCon42(x), myCon43(x), myCon44(x), myCon45(x), myCon46(x), myCon47(x), myCon48(x), myCon49(x), myCon50(x), myCon51(x), myCon52(x), myCon53(x), myCon54(x), myCon55(x) );
% Define your own constraint functions
myCon1 = @(x) f>=1;
myCon2 = @(x) Fn>=1;
myCon3 = @(x) m0>=1;
myCon4 = @(x) p3>=1;
myCon5 = @(x) Tpz>=1;
myCon6 = @(x) o>=1;
myCon7 = @(x) t>=1;
myCon8 = @(x) aa>=1;
myCon9 = @(x) WTO>=1;
myCon10 = @(x) WLanding>=1;
myCon11 = @(x) WF>=1;
myCon12 = @(x) WE>=1;
myCon13 = @(x) WPL>=1;
myCon14 = @(x) WC>=1;
myCon15 = @(x) M>=1;
myCon16 = @(x) Fab>=1;
myCon17 = @(x) V9>=1;
myCon18 = @(x) V0>=1;
myCon19 = @(x) QR>=1;
myCon20 = @(x) NB>=1;
myCon21 = @(x) T1>=1;
myCon22 = @(x) T0>=1;
myCon23 = @(x) L>=1;
myCon24 = @(x) p>=1;
myCon25 = @(x) V>=1;
myCon26 = @(x) A>=1;
myCon27 = @(x) bw>=1;
myCon28 = @(x) sw>=1;
myCon29 = @(x) WZF>=1;
myCon30 = @(x) b>=1;
myCon31 = @(x) cr>=1;
myCon32 = @(x) ct>=1;
myCon33 = @(x) WS>=1;
myCon34 = @(x) RC>=1;
myCon35 = @(x) l>=1;
myCon36 = @(x) m>=1;
myCon37 = @(x) W0>=1;
myCon38 = @(x) VH>=1;
myCon39 = @(x) VS>=1;
myCon40 = @(x) VS1>=1;
% Run genetic algorithm
[x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], 20:45, options);% Plot Pareto front
pareto(fval(:,1:nobj/2), -fval(:,nobj/2+1:end));
xlabel('Objective 1');
ylabel('Objective 2');
zlabel('Objective 3');

Error in untitled20 (line 58)
[x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], 20:45, options);% Plot Pareto front

King regards

 

% Define the objective functions to maximize and minimize
f
=
@(x) [x(1)^2, x(2)^2, -x(3)^2, -x(4)^2];
g = @(x) [-x(1)^2, -x(2)^2, x(3)^2, x(4)^2];
% Define the constraints
A
[-1 0 0 1; 0 -1 0 1; 0 0 -1 1; 1 1 1 1];
b
[-1; -1; -1; 1];
% Set the GA options
=
=
options = optimoptions('gamultiobj', 'Display', 'iter', 'PlotFcn', {@gaplotpareto, @gaplotscorediversity});
% Run the GA
[x, fval] = gamultiobj (@(x) [f(x), g(x)], 4, A, b, [], [], [], [], options);
% Plot the Pareto front in 3D
scatter3(fval(:,1),
xlabel('f_1(x)');
ylabel('f_2(x)');
zlabel('f_3(x)');
title('Pareto Front');
fval(:,2), fval(:,3), 20, 'filled');
% Find best overall design
bestIndex = find (output.consViol==0);
bestDesign = x(bestIndex, :);
grid on;
Transcribed Image Text:% Define the objective functions to maximize and minimize f = @(x) [x(1)^2, x(2)^2, -x(3)^2, -x(4)^2]; g = @(x) [-x(1)^2, -x(2)^2, x(3)^2, x(4)^2]; % Define the constraints A [-1 0 0 1; 0 -1 0 1; 0 0 -1 1; 1 1 1 1]; b [-1; -1; -1; 1]; % Set the GA options = = options = optimoptions('gamultiobj', 'Display', 'iter', 'PlotFcn', {@gaplotpareto, @gaplotscorediversity}); % Run the GA [x, fval] = gamultiobj (@(x) [f(x), g(x)], 4, A, b, [], [], [], [], options); % Plot the Pareto front in 3D scatter3(fval(:,1), xlabel('f_1(x)'); ylabel('f_2(x)'); zlabel('f_3(x)'); title('Pareto Front'); fval(:,2), fval(:,3), 20, 'filled'); % Find best overall design bestIndex = find (output.consViol==0); bestDesign = x(bestIndex, :); grid on;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education