Extracting optimization history from custom DOE

Hi!

I’m using the CustomDOE to execute an optimization problem with the following structure:

At the top level (outer_scenario) I have my custom DOE with iterates through each day of the year. Within each day (inner_scenario), I perform a 2D optimization.

I would like to grab the optimization history from each inner_scenario to analyze performance at the day level as the outer_scenario only stores the best performance across the full year. However, as far as I can tell, the object inner_scenario only stores the last performed optimization.

Is there a way to store individual inner_scenario results during the execution of the outer DOE while retaining my custom DOE structure?

Hello Joe!

Are you using a BiLevel formulation or are you using an MDOScenarioAdapter?

For both strategies the way to store the sub optimizations is the same, but the way to access the “wrapped” scenarios is different.

If you are using a BiLevel formulation, use the settings keep_opt_history and save_opt_history (see more info here). There is also an example on how to explore the databases in memory here when keep_opt_history=True.

If you used an MDOScenarioAdapter directly then you can use its attributes to define what you wish to keep and how. The most relevant ones are keep_opt_history, save_opt_history and maybe opt_history_file_prefix.

I hope this helps!

Hi Gilberto,

This is very helpful thank you.

I am using a BiLevel formulation and a HPC so have saved the sub optimization history using the solution you provided: keep_opt_history = False, save_opt_history = True, naming = "UUID".

This works well and is saving the .h files for each day level optimization, which I am then able to use in post processing as intended. However it also leads to my new issue.

The .h files have what appear to be randomly generate file names. I am wanting to rename them to their corresponding day of the year but can’t seem to find a method to match the “day”, which is a design variable in the outer scenario and therefore not included in the inner level optimization design space, to the files themself.

Is there a method for doing so?

Thanks

Hi,

Yes, the "UUID" naming creates unique pseudo-random names for the databases. This is useful if the scenario is being executed in parallel to avoid concurrent access from two different sub processes. You can use "NUMBERED" instead and the files will be named sequentially, following the same order of the samples in your CustomDOE.

Hi,

I am executing the scenario in parallel so using “UUID" is the only possible naming system when creating the .h files.

Is there a method to pass the outer scenario design variables (day of the year) into the inner scenario design space so I can access there values within each .h file

Thanks

I am not sure I follow. A BiLevel formulation sets the starting point of the design space in the inner scenario using some or all of the values of the design variables of the outer scenario. The way to identify each database file is to look at the starting point of each of them and look at the value of the variable or variables that were set from the outer scenario. If the days are not the variable that changes, then there should be some other variable that changes in the inner design space at each outer scenario iteration.

For now there is no automatic way to do this in GEMSEO. We are working in a DirectoryManager that create file structure on the disk that mirrors the workflow of the scenario that is running. It should be ready by the next major GEMSEO release.