Note
Go to the end to download the full example code
Save a scenario for post-processing¶
from __future__ import annotations
from gemseo import create_design_space
from gemseo import create_discipline
from gemseo import create_scenario
We consider a minimization problem over the interval \([0,1]\) of the \(f(x)=x^2\) objective function:
discipline = create_discipline("AnalyticDiscipline", expressions={"y": "x**2"})
design_space = create_design_space()
design_space.add_variable("x", l_b=0.0, u_b=1.0)
scenario = create_scenario([discipline], "DisciplinaryOpt", "y", design_space)
We solve this optimization problem with the gradient-free algorithm COBYLA:
scenario.execute({"algo": "NLOPT_COBYLA", "max_iter": 10})
Then, we save the results to an HDF5 file for future post-processing:
scenario.save_optimization_history("my_results.hdf")
See also