Iterative Display (gamultiobj)

6 views (last 30 days)
Ludvík Hladký
Ludvík Hladký on 24 May 2023
Commented: Torsten on 25 May 2023
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
Ludvík Hladký
Ludvík Hladký on 25 May 2023
Edited: Ludvík Hladký on 25 May 2023
Hello Torsten,
it kind of did, but I suppose now it only shows genetic algorithm process as shown bellow:
---------------------------------------------------------------------------------------------------------------------------------------------------------------
I would love to achieve something like what is shown on the 2nd picture, where I would have "Iteration" and then corresponding values for objetive functions (p, v0), optimization variables (omega, e1) and time it took to find the optimal solution.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
I think I did not explain what I want clearly but can you please elaborate on how to solve this problem at hand because from the link you provided, it is not obvious to me, what the code must consist of in order to achieve what I have just described.
Thank you so much and take care
Torsten
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:

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!