How to create a Triple Objective Genetic Algorithm establish constraints and plot 3D
4 次查看(过去 30 天)
显示 更早的评论
My code isnt working :
Objective one : improve overall efficiency-maximize
Objective two: improve specific fuel comsumption-minimize
Objective three: improve thurst- maximize
- The fuel-to-air ratio must be between 0.01 and 0.1.
- The air mass flow rate must be between 10 and 100 kg/s.
- The inlet pressure must be between 50 and 300 kPa.
- The primary zone temperature must be between 1200 and 2000 K.
- The equivalence ratio must be between 0.5 and 1.5.
- The residence time must be between 0.1 and 10 seconds.
- The pressure term must be between 0.5 and 1.5.
- The take off weight must be between 5000 and 50000 kg.
- The landing weight must be between 5000 and 50000 kg.
- The fuel weight must be between 500 and 5000 kg.
- The empty weight must be between 5000 and 50000 kg.
- The payload weight must be between 500 and 5000 kg.
- The crew weight must be between 100 and 1000 kg.
- The fuel load mass must be between 500 and 5000 kg.
- The afterburner fuel-to-air ratio must be between 0.01 and 0.1.
- The exhaust velocity must be between 1000 and 5000 m/s.
- The cruising speed must be between 200 and 1000 m/s.
- The fuel heating value must be between 40 and 50 MJ/kg.
- The burner efficiency must be between 0.8 and 1.0.
- The inlet temperature must be between 200 and 400 K.
- The ambient static temperature must be between 200 and 300 K.
- The lift must be between 5000 and 50000 N.
- The density must be between 0.5 and 2.5 kg/m3.
- The velocity must be between 50 and 1000 m/s.
- The wing area must be between 50 and 200 square meters.
- The wing span must be between 10 and 50 meters.
- The trapezoidal wing area in ft must be between 500 and 2000 square feet.
- The zero fuel weight must be between 5000 and 50000 kg.
- The upper dimension of wing must be between 5 and 20 meters.
- The right dimension side of wing must be between 5 and 20 meters.
- The left dimension side of wing must be between 5 and 20 meters.
- The wing span must be between 10 and 50 meters.
- The root chord must be between 1 and 5 meters.
- The length must be between 10 and 50 meters.
- The moment must be between 1000 and 50000 Nm.
- The gross weight of aircraft must be between 10000 and 100000 kg.
- The maximum demonstrated level airspeed must be between 200 and 1000 m/s.
- The stalling speed must be between 50 and 200 m/s.
- The stalling speed with flaps retracted must be between 100 and 500 m/s.
- The gust alleviation factor must be between 0.5 and 1.5.
- The reference gust velocity must be between 5 and 50 m/s.
- The design cruise speed must be between 200 and 1000 m/s.
- The pi number must be 3.14.
- The vertical gust velocity must be between -10 and 10 m/s.
ceq = [];
end
[sol,fval,exitflag,output] = solve(prob,...
Solver="gamultiobj",...
Options=options);
sol = solve(prob);
paretoplot(sol)
% Plot Pareto front
pareto(fval(:,1:nobj/2), -fval(:,nobj/2+1:end));
xlabel('Objective 1');
ylabel('Objective 2');
zlabel('Objective 3');
I've been following this two examples but it's still quite confusing for me since I'm new to matlab.
https://www.mathworks.com/help/gads/multiobjective-optimization-welded-beam.html
or
https://www.mathworks.com/help/gads/solving-a-mixed-integer-engineering-design-problem-using-the-genetic-algorithm.html#d124e20023
Could someone give me a hand?
Examples in the documentation and forum are not simple enough for me to understand, I just found this code that I understand minimally..
King regards
1 个评论
Kevin Holly
2023-4-26
There is a free self-paced course, Optimization Onramp, that you could take. If you want a more in-depth course, there is a paid training course offered called Optimization Techniques in MATLAB.
回答(4 个)
Alan Weiss
2023-4-14
You are confusing many things here.
The first thing you have to do is decide if you are using optimization variables, meaning the problem-based approach, or if you are using the solver-based approach. Generally, you cannot mix the two. In your code you call gamultiobj, meaning you are using the solver-based approach. Yet you use optimvar and optimproblem, which are problem-based calls. So really, before you write code, you have to decide on an approach and stick with it. I suggest that you use the problem-based approach, as it is easier for most people, but whatever you do, stick with just one.
Then you have to stop treating bounds and nonlinear constraints as the same thing. You have the "nonlinear" constraint
prob.Constraints.con1 = vars(1) <= 2000;
which is exactly the same as the line
vars = optimvar('vars', 4, 'LowerBound', [0, 0, 0, 0], 'UpperBound', [2000, 800, 30, 10]);
when applied to vars(1). Don't include that as a "nonlinear" constraint. You have already expressed it as a bound.
You seem to be trying to maximize all your objective functions. That is fine. You just have to tell the solver that is what you are trying to do.
prob.ObjectiveSense = "max";
But maybe I am wrong and you are trying to minimize a few objectives as well as maximize some. In that case look at https://www.mathworks.com/help/gads/multiobjective-optimization-problem-based.html to see how to do that.
I don't see where you are specifying your objectives. I mean, you have a line
f(1) = specific_fuel_consumption(x(1), x(2), x(3), x(4));
but I both do not see where specific_fuel_consumption is defined, nor am I sure that you can just call it like that. You very likely will need to call fcn2optimexpr at several places. If you do not know what this means, take a look at some examples, such as here or here.
Well, it seems that you are trying to do a challenging problem as your first introduction to MATLAB. Perhaps you should take your time and spend a bit of effort learning the basics first.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 个评论
Alan Weiss
2023-4-17
OK, it seems that you have decided to use the solver-based approach, which is just fine.
You set some nondefault options. I am not sure why you do this. Is there something wrong with the default options? I suggest that you do not change any options unless you need to.
The next thing you need to learn is how to write functions in MATLAB. A statement such as
myCon1 = @(x) f=>1; % f= fuel to air ratio
is problematic on several fronts. First of all, the expression @(x) f is not going to compute the value of the fuel to air ratio. You need to write a function to do that, unless this parameter is passed in your variables. Secondly, writing an inequality constraint function in the solver-based approach is different from writing one in the problem-based approach. The syntax for nonlinear inequality constraints is to write a function mycon(x) which returns two outputs, c(x) and ceq(x) as described in Nonlinear Constraints. You seem to have quite a number of nonlinear constraints, so your nonlinear constraint function will need to return a large vector of constraints, with one entry for each constraint. The documentation I just linked shows c(1) and c(2) for two constraints. If you have 50 constraints then your vector would have 50 entries.
So ask yourself the question, for each of your objectives and constraints, how do I write a function to perform this calculation? Write and test these functions one at a time before putting them into your overall problem.
Now for the last thing. You say that you want to plot a 3-D Pareto front. Which objectives will be plotted in this front? You can have only three objectives in a 3-D Pareto plot.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
7 个评论
Torsten
2023-4-18
编辑:Torsten
2023-4-18
I mean: What does x^2 mean if x is a vector with 55 elements ?
I cannot set up your problem because I don't understand your problem.
As @Alan Weiss said: Decide whether you want to use the solver-based or problem-based approach, study examples MATLAB provides and restart setting up your problem.
Maybe an online introduction to MATLAB could also be helpful:
Alan Weiss
2023-4-19
I am sorry to say that I think that you need more help than we can give on this forum. If you want to have a productive interaction with members of this forum, I strongly suggest that you work through the Get Started material in at least Optimization Toolbox documentation. Then work through the examples in the Multiobjective Optimization documentation.
I will no longer respond to this thread.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!