for my parameter estimation, I would like to save the solution and plot of only the last and final optimization generation. (I am currently getting a lot of pareto results, and saving them all for all optimization generations would result in much data being saved). What would be the ideal way to do it? I am currently using a callback function with frequency set to the n_max_gen of the optimizer. But, since it’s called n_max_gen, could the case happen that the optimizer finishes the optimization before reaching n_max_gen? Then, I would probably have to re-simulate all my results to plot them, and I would like to avoid that.
Also, another question: Is there a way to get the number of the current iteration step, and use it in a callback function? That could help me organizing my data, by using the iteration step in file or folder names, if I want to save files for single optimization steps.
It is great to see you exploring CADET-Process optimization. At this stage it can also help to look at the code, since that often makes the internal structure easier to understand.
Regarding n_max_gen: this parameter is part of the U_NSGA3 algorithm from pymoo that CADET-Process interfaces with. It sets the maximum number of generations after which the algorithm stops whether it has converged or not. In practice it will usually stop earlier if your problem is solved to the termination criteria.
Do you have a specific reason to capture results with a callback rather than reading them from the OptimizationResults object at the end? During the run the optimizer should prune poor candidates and update the Pareto front when it finds better solutions. If you need to persist intermediate results, you would need to add your own logic in a callback to decide when to save or cache a result.
For your last question: callback objects typically expose a current_iteration attribute that you can read as well!
Since CADET-Process is open source, if you are missing a feature, please feel free to open a pull request and add it.