# How to plot only results of last optimization step/Get number of current optimization step?

**URL:** <https://forum.cadet-web.de/t/how-to-plot-only-results-of-last-optimization-step-get-number-of-current-optimization-step/1328>\
**Category:** Chromatography Modeling\
**Created:** [October 9, 2025, 7:42am UTC](https://forum.cadet-web.de/t/how-to-plot-only-results-of-last-optimization-step-get-number-of-current-optimization-step/1328 "2025-10-09T07:42:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AN\_IA](https://forum.cadet-web.de/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@AN\_IA](https://forum.cadet-web.de/u/AN_IA)\
**Post date:** [October 9, 2025, 7:42am UTC](https://forum.cadet-web.de/t/how-to-plot-only-results-of-last-optimization-step-get-number-of-current-optimization-step/1328/1 "2025-10-09T07:42:09Z")

</div>

Hello,

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.

Thanks for any help.

Greetings, AN\_IA

---

<div class="post-metadata">

**Author:** ![h.lanzrath](https://forum.cadet-web.de/user_avatar/forum.cadet-web.de/h.lanzrath/32/1186_2.png) [@h.lanzrath](https://forum.cadet-web.de/u/h.lanzrath)\
**Post date:** [October 13, 2025, 7:51am UTC](https://forum.cadet-web.de/t/how-to-plot-only-results-of-last-optimization-step-get-number-of-current-optimization-step/1328/2 "2025-10-13T07:51:44Z")

</div>

Hi AN\_IA,

Thanks for your post.

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.

Hope this already helps. 🙂

All the best,  
Hannah

---

<div class="post-metadata">

**Author:** ![system](https://forum.cadet-web.de/uploads/default/original/2X/4/4ec43a357aeb35dcb4e6620649f54e8e6591b258.png) [@system](https://forum.cadet-web.de/u/system)\
**Post date:** [March 5, 2026, 7:48am UTC](https://forum.cadet-web.de/t/how-to-plot-only-results-of-last-optimization-step-get-number-of-current-optimization-step/1328/3 "2026-03-05T07:48:12Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
