gamultiobj constraints without any mathematical relation with variables

Hi everyone, I am carrying out Multi-objective design optimisation using gamultiobj of Global Optimization Toolbox, is there any way to stop the optimiser from computing the result (or to not consider that pearticular iteration) for a partcular iteration after performing a part of the code and fulfilling certain conditions?
For example, My fitness function is like this,
............................
..............code involving calcuating the area using some external software
area = extractBetween(lines_2(12),7,13);
area_number = str2num(area);
...........
y(1) = 1/max_l_d;
y(2) = overpressure;
END OF FITNESS FUNCTION
Now, I just want the optimiser to stop a particular iteration when area_number > 150 m^2. Also, this area is not directly mathematically related to the variables(else I would have used nonlcon or linear constraints), its calculation is done from some external software and we will not be getting this value until a part of fitness function code is executed, for every iteration. SO, hence the question is that it needs to stop executing that particular iteration when this condition is fulfilled.

Answers (1)

Use an output function "OutputFcn" specified in the options structure of the solver.
Within this function, you can calculate "area_number" and decide how to proceed further.
From the documentation:
OutputFcn
Functions that ga calls at each iteration. Specify as a function handle or a cell array of function handles. See Output Function Options.
For an options structure, use OutputFcns.
Function handle or cell array of function handles | {[]}

3 Comments

Thank you for answering the question Torsten. I have been trying to find the right syntax for the output functions, as they seem to be different for different optimization algorithms. Also, just for explaining in simpler terms, I just do not want to include the solutions(of objective funcs) of particular iterations in which the area_num variable > 150.
So, i was wondering if that would be possible with this output function option, as it only seems to have the facility to completely stop the iterations and algorithm. Please let me know if there's any possibility. Thank you.
As to my knowledge, you can do both in the OutputFunction: write out the iterates and stop the optimization.
Thank you so much Torsten, I will try to solve it with this output function then. It seems to have very less documentation regarding its usage for writing out the iterations.

Sign in to comment.

Asked:

on 6 Dec 2022

Edited:

on 10 Dec 2022

Community Treasure Hunt

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

Start Hunting!