Saving GAmultiobj results calculated in the algorithm mid-way, without stopping the code run.
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rohit Sachdeva
el 11 de Nov. de 2024 a las 13:24
Respondida: Swastik Sarkar
el 21 de Nov. de 2024 a las 7:09
I am running a GAmultiobj optimization code with 2 objective functions and 21 input variables. The code takes a long time to run and crashes in between (due to some bug which I am trying to fix).
I am plotting the Pareto-Front of the 2 objectives with default settings. I am able to see the points on the Pareto-Front which tell me the values of the 2 objectives (fval) if I pause my code (say 20 such points). However, I want to also know the variable (xval) values for those points on the Pareto-Front (20-by-21 array), even when the optimization algorithm has not completed. This way atleast some of the variable values will be available to me even if the code crashes later.
I have kept the 'UseParallel' setting to 'true'. What I have tried so far:
- Include an 'OutputFcn' command to keep storing the 'Population' and respective 'Scores'. However, those values do not correspond to the points currently being displayed on the Pareto-Front.
- Tried the solution posted in this thread but I am unable to find the results (xval and fval) which have been calculated so far in any of the debugger files. Is this because I am using Parallel setting which is causing the input space to get split up ?
Any help would be really appreciated!
0 comentarios
Respuestas (1)
Swastik Sarkar
el 21 de Nov. de 2024 a las 7:09
I was able to use OutputFcn to display the Pareto-front values fval and corresponding x, achieving this with the following output function:
function [state, options, optchanged] = dispParetoFront(options, state, flag)
optchanged = false;
if isequal(flag, 'iter')
topRankedIdx = state.Rank == 1;
fval = state.Score(topRankedIdx,:);
x = state.Population(topRankedIdx,:);
disp(fval);
disp(x);
end
end
In the code above, fval corresponds to the values being plotted. Below is the corresponding plot:
Please refer to the below plot for one such iteration:
Following is the output of the OutputFcn for that iteration:
Average Average
Generation Func-count Pareto distance Pareto spread
1 100 1 1
175.7636 213.0926
222.3589 202.6253
207.0830 206.5507
Columns 1 through 12
5.3488 0.6370 0.1491 -0.5133 0.2020 -1.0246 2.5131 0.3995 -0.9634 -5.1355 3.5102 2.6572
-1.5666 1.8390 -4.4555 0.8624 -4.0777 4.5399 4.5765 -2.3334 1.2334 2.1562 3.3867 -3.2181
4.9653 -0.0933 -3.4053 3.1967 -0.6689 3.4599 -0.0144 -5.6348 -1.9415 -0.6209 2.1915 0.5244
Columns 13 through 21
1.5702 -4.9496 -2.0260 -1.5951 -0.1794 -6.9090 -1.8514 -1.9264 1.9222
1.6208 1.9597 -0.6533 2.3225 0.6406 -2.3525 7.0044 0.8590 6.0227
-1.0549 4.7118 0.7702 -0.2536 -0.7465 -4.6771 0.1338 7.3640 2.5598
Hope this works for you.
0 comentarios
Ver también
Categorías
Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!