Good afternoon
My MATLAB optimization code for a turbojet engine in order to maximize and minimize the following functions with various constraints is not working and even when plotting in 3D it appears some errors:
Could someone help me get it working please?
function [f, g] = turbojet_objective(x)
% Objective function to minimize and maximize at the same time
% x(1) = TIT (Turbine Inlet Temperature)
% x(2) = CIT (Compressor Inlet Temperature)
% x(3) = CPR (Compressor Pressure Ratio)
% x(4) = BPR (Bypass Ratio)
% Objective function to minimize: Specific Fuel Consumption, NOx Emissions (LTO),Fuel Weight,Wto,Flight time
f(1) = specific_fuel_consumption(x(1), x(2), x(3), x(4));
f(2) = NOx_emissions(x(1), x(2), x(3), x(4));
f(3) = fuel_weight(x(1), x(2), x(3), x(4));
f(4) = Wto(x(1), x(2), x(3), x(4));
f(5) = flight_time(x(1), x(2), x(3), x(4));
% Objective function to maximize: Propulsive efficiency, Overall efficiency,Thermal Efficiency,Thurst
g(1) = propulsive_efficiency(x(1), x(2), x(3), x(4));
g(2) = overall_efficiency(x(1), x(2), x(3), x(4));
g(3) = thermal_efficiency(x(1), x(2), x(3), x(4));
g(4) = thurst(x(1), x(2), x(3), x(4));
end
function c = turbojet_constraints(x)
% Define the constraints
c(1) = x(1) - 2000;
c(2) = x(2) - 800;
c(3) = x(3) - 30;
c(4) = x(4) - 10;
end
% Generate random values for the optimization variables
vars = rand(1, 4) .* [2000, 800, 30, 10];
% Define the optimization problem
prob = optimproblem('Objective', @(x) turbojet_objective(x));
% Define the optimization variables with lower and upper bounds
TIT = optimvar('TIT', 'LowerBound', 0, 'UpperBound', 2000);
CIT = optimvar('CIT', 'LowerBound', 0, 'UpperBound', 800);
CPR = optimvar('CPR', 'LowerBound', 0, 'UpperBound', 30);
BPR = optimvar('BPR', 'LowerBound', 0, 'UpperBound', 10);
prob.Objective.x = [TIT, CIT, CPR, BPR];
% Define the constraints
prob.Constraints.con1 = TIT <= 2000;
prob.Constraints.con2 = CIT <= 800;
prob.Constraints.con3 = CPR <= 30;
prob.Constraints.con4 = BPR <= 10;
% Solve the problem
options = optimoptions('gamultiobj', 'PlotFcn', 'gaplotpareto');
[sol, fval] = solve(prob, 'Objective', @(x) turbojet_objective(x), 'Constraints', @(x) turbojet_constraints(x), 'Options', options);
% Plot the 3D Pareto front
pareto(fval(:, 1), fval(:, 2), fval(:, 3));
Thanks,
King Regards