Hi Good Afternoon. Can someone help me with my genetic algorithm in matlab , unfortunately it is not working but the structure is right I think . I need it to work in order to see the pareto front 3D and the performance of the constraints please. I would be very grateful if you could. The constraints are these and the objective functions are also written correctly. Note this is a personal project not an assignment! King regards MATLAB CODE: % Define decision variables, objectives, and constraints nvars = 56; % number of decision variables nobj = 8; % number of objectives ncon = 56; % 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))), -WPL/WC, -M/(TSFC/Fn)]; % Define your own constraint functions myCon1 = @(x) f=>1; % f= fuel to air ratio myCon2 = @(x) Fn=>1; % Fn= net thurst myCon3 = @(x) m0=>1; % m0= air mass flow rate myCon4 = @(x) p3=>1; % p3=inlet pressure myCon5 = @(x) Tpz=>1; % Tpz=primary zone temperature myCon6 = @(x) o=>1; % o=equivalence ratio myCon7 = @(x t=>1; % t=residence time myCon8 = @(x) aa=>1; % aa=pressure term myCon9 = @(x) WTO=>1; % Wto=take off weight myCon10 = @(x) WLanding=>1; ; % Wlanding=landing weight myCon11 = @(x) WF=>1; % Wf=fuel weight myCon12 = @(x) WE=>1; % WE=empty weight myCon13 = @(x) WPL=>1; ; % Wpl=payload weight myCon14 = @(x) WC==>1; % Wc=crew weight myCon15 = @(x) M==>1; % Fuel load mass myCon16 = @(x) Fab=>1; % afterburner fuel-to-air ratio myCon17 = @(x) V9=>1; % exhaust velocity myCon18 = @(x) V0=>1; % cruising speed myCon19 = @(x) QR=>1; % fuel heating value myCon20 = @(x) NB=>1; % burner efficiency myCon21 = @(x) T1=>1; % inlet temperature myCon22 = @(x) T0=>1; % ambient static temperature myCon23 = @(x) L=>1; % lift myCon24= @(x) p=>1; % density myCon25= @(x) V=>1; % velocity myCon26 = @(x) A=>1; % wing area myCon27 = @(x) bw=>1; % wing span myCon28 = @(x) sw=>1; % Trapezoidal wing area in ft myCon29 = @(x) WZF=>1; ; % zero fuel weight myCon30 = @(x) b=>1; ; % upper dimension of wing myCon31 = @(x) cr=>1; ; % right dimension side of wing myCon32 = @(x) ct=>1; ; % left dimension side of wing myCon33 = @(x) WS==>1; ; % wing span myCon34 = @(x) RC=>1; % root chord myCon35 = @(x) l=>1; % lenght myCon36 = @(x) m=>1; ; % moment myCon37 = @(x) W0=>1; % gross weight of aicraft myCon38 = @(x) VH=>1; % maximum demonstrated level airpeed myCon39 = @(x) VS=>1; % stalling speed myCon40 = @(x) VS1=>1; % stalling speed with flaps retracted myCon41 = @(x) KG=>1; % Gust alleviation factor myCon42 = @(x) UREF=>1; ; % reference gust velocity myCon43 = @(x) VC=>1; % design cruise speed myCon44 = @(x) pi=>1; ; % pi number myCon45 = @(x) Ude=>1; % vertical gust velocity myCon46 = @(x) x=>1; % distance in ft penetrated into the gust myCon47 = @(x) CMGC=>1; ; % Mean geometric chord myCon48 = @(x) UG=>1; % i dont know the name myCon49 = @(x) D=>1; % Drag myCon50 = @(x) Y=>1; % fuel weight fraction for the cruise segment myCon51 = @(x) CL=>1; % lift coefficient myCon52 = @(x) CD=>1; % drag coefficient myCon53 = @(x) A=>1; % Area myCon54 = @(x) Cla=>1; ; %3-dimensional lift curve slope myCon55 = @(x) B=log(Y);% 56 variable 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)); % Run genetic algorithm [x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], confun, options); % Plot Pareto front pareto(fval(:,1:nobj/2), -fval(:,nobj/2+1:end)); xlabel('Objective 1'); ylabel('Objective 2'); zlabel('Objective 3');
Hi Good Afternoon.
Can someone help me with my genetic
I need it to work in order to see the pareto front 3D and the performance of the constraints please.
I would be very grateful if you could.
The constraints are these and the objective functions are also written correctly.
Note this is a personal project not an assignment!
King regards
MATLAB CODE:
% Define decision variables, objectives, and constraints
nvars = 56; % number of decision variables
nobj = 8; % number of objectives
ncon = 56; % 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))), -WPL/WC, -M/(TSFC/Fn)];
% Define your own constraint functions
myCon1 = @(x) f=>1; % f= fuel to air ratio
myCon2 = @(x) Fn=>1; % Fn= net thurst
myCon3 = @(x) m0=>1; % m0= air mass flow rate
myCon4 = @(x) p3=>1; % p3=inlet pressure
myCon5 = @(x) Tpz=>1; % Tpz=primary zone temperature
myCon6 = @(x) o=>1; % o=equivalence ratio
myCon7 = @(x t=>1; % t=residence time
myCon8 = @(x) aa=>1; % aa=pressure term
myCon9 = @(x) WTO=>1; % Wto=take off weight
myCon10 = @(x) WLanding=>1; ; % Wlanding=landing weight
myCon11 = @(x) WF=>1; % Wf=fuel weight
myCon12 = @(x) WE=>1; % WE=empty weight
myCon13 = @(x) WPL=>1; ; % Wpl=payload weight
myCon14 = @(x) WC==>1; % Wc=crew weight
myCon15 = @(x) M==>1; % Fuel load mass
myCon16 = @(x) Fab=>1; % afterburner fuel-to-air ratio
myCon17 = @(x) V9=>1; % exhaust velocity
myCon18 = @(x) V0=>1; % cruising speed
myCon19 = @(x) QR=>1; % fuel heating value
myCon20 = @(x) NB=>1; % burner efficiency
myCon21 = @(x) T1=>1; % inlet temperature
myCon22 = @(x) T0=>1; % ambient static temperature
myCon23 = @(x) L=>1; % lift
myCon24= @(x) p=>1; % density
myCon25= @(x) V=>1; % velocity
myCon26 = @(x) A=>1; % wing area
myCon27 = @(x) bw=>1; % wing span
myCon28 = @(x) sw=>1; % Trapezoidal wing area in ft
myCon29 = @(x) WZF=>1; ; % zero fuel weight
myCon30 = @(x) b=>1; ; % upper dimension of wing
myCon31 = @(x) cr=>1; ; % right dimension side of wing
myCon32 = @(x) ct=>1; ; % left dimension side of wing
myCon33 = @(x) WS==>1; ; % wing span
myCon34 = @(x) RC=>1; % root chord
myCon35 = @(x) l=>1; % lenght
myCon36 = @(x) m=>1; ; % moment
myCon37 = @(x) W0=>1; % gross weight of aicraft
myCon38 = @(x) VH=>1; % maximum demonstrated level airpeed
myCon39 = @(x) VS=>1; % stalling speed
myCon40 = @(x) VS1=>1; % stalling speed with flaps retracted
myCon41 = @(x) KG=>1; % Gust alleviation factor
myCon42 = @(x) UREF=>1; ; % reference gust velocity
myCon43 = @(x) VC=>1; % design cruise speed
myCon44 = @(x) pi=>1; ; % pi number
myCon45 = @(x) Ude=>1; % vertical gust velocity
myCon46 = @(x) x=>1; % distance in ft penetrated into the gust
myCon47 = @(x) CMGC=>1; ; % Mean geometric chord
myCon48 = @(x) UG=>1; % i dont know the name
myCon49 = @(x) D=>1; % Drag
myCon50 = @(x) Y=>1; % fuel weight fraction for the cruise segment
myCon51 = @(x) CL=>1; % lift coefficient
myCon52 = @(x) CD=>1; % drag coefficient
myCon53 = @(x) A=>1; % Area
myCon54 = @(x) Cla=>1; ; %3-dimensional lift curve slope
myCon55 = @(x) B=log(Y);% 56 variable
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));
% Run genetic algorithm
[x, fval, exitflag, output, population, scores] = ga(objfun, nvars, [], [], [], [], [], [], confun, options);
% Plot Pareto front
pareto(fval(:,1:nobj/2), -fval(:,nobj/2+1:end));
xlabel('Objective 1');
ylabel('Objective 2');
zlabel('Objective 3');
Step by step
Solved in 7 steps with 7 images