Iterative Display (gamultiobj)
6 views (last 30 days)
Show older comments
Hello guys,
I have recently created a optimization algorithm, which uses "gamultiobj" as a solver of internal ballistics problem.
The last thing I would like to achieve with this is to have a Iterative display, which would show for every iteration the current value of objective functions (p, v0) as well as the values of coresponding optimization variables (omega, e1) and ofcourse the time it takes to find the optimal solution.
I do not have any experience in this so I very much appreciate your time and thank you for any kind of help in advance !
Ludvik Hladky
clc,clear,close
% PROBLEM DESCRIPTION
prob = optimproblem("Description",['Optimizing the mass of propellant charge ' ...
'and thickness of powder grain']);
% VARIABLES
omega = optimvar('omega',1,'LowerBound',2.7e-3,'UpperBound',3.3e-3);
e1 = optimvar('e1',1,'LowerBound',0.21e-3,'UpperBound',0.26e-3);
% DEFINITION OF OBJECTIVE FUNCTION
f = fcn2optimexpr(@internal_ballistics,omega,e1);
p = f(1);
v0 = f(2);
prob.Objective.first = p;
prob.ObjectiveSense = "min";
prob.Objective.second = v0;
prob.ObjectiveSense = "max";
% CONSTRAINTS
prob.Constraints.vazba1 = p<=300e6;
prob.Constraints.vazba2 = v0>=750;
prob.Constraints.vazba3 = omega<=5.72e-3;
% PROBLEM SOLUTION
x0.omega = 2.71e-3;
x0.e1 = 0.21e-3;
[sol,optimval,exitflag,output] = solve(prob,x0);
% DISPLAY OF CALCULATION RESULTS
disp(strcat('Optimized mass of propellant charge omega=',num2str(sol.omega(1,1)),'kg'))
disp(strcat('Optimized thickness of powder grain e1=',num2str(sol.e1(1,1)),'m'))
disp(strcat('Resulting chamber pressure p=',num2str(optimval(1,1)*1e-6),'MPa'))
disp(strcat('Resulting velocity v0=',num2str(optimval(2,1)),'m/s'))
3 Comments
Torsten
on 25 May 2023
This is the output you automatically get from "gamultiobj". If you want advanced output, you will have to define an "OutputFcn" function and program it on your own, I guess.
The syntax to the "OutputFcn" function for "gamultiobj" is described here:
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!