OptimizationProblem: the observables are not evaluated during the second evaluation
Summary
An OptimizationProblem
is executed with a DOELibrary
once, then its current_iter
is reset and it is executed for a second time. The database contains the evaluations of the objective and constraints related to the 2 DOEs as expected, but does not contain the evaluation of the observables related to the second DOE.
Gemseo version
develop
Platform info
Windows
Environment info
venv / py39
Steps to reproduce
from gemseo.algos.design_space import DesignSpace
from gemseo.algos.opt_problem import OptimizationProblem
from gemseo.api import execute_algo
from gemseo.core.mdofunctions.mdo_function import MDOFunction
design_space = DesignSpace()
design_space.add_variable("x", l_b=0.0, u_b=1.0, value=0.5)
problem = OptimizationProblem(design_space)
problem.objective = MDOFunction(lambda x: x, "obj")
problem.add_observable(MDOFunction(lambda x: x, "obs"))
problem.add_constraint(MDOFunction(lambda x: x, "cstr", f_type="ineq"))
execute_algo(problem, "OT_MONTE_CARLO", algo_type="doe", n_samples=2, seed=1)
problem.reset(
database=False,
design_space=False,
function_calls=False,
preprocessing=False,
)
execute_algo(problem, "OT_MONTE_CARLO", algo_type="doe", n_samples=3, seed=2)
assert len(problem.database.get_func_history("obj")) == 5
assert len(problem.database.get_func_history("cstr")) == 5
assert len(problem.database.get_func_history("obs")) == 2
What is the current bug behavior?
len(problem.database.get_func_history("obs"))
is equal to 2, the size of the first DOE.
What is the expected correct behavior?
len(problem.database.get_func_history("obs"))
should be equal to 5, the sum of the size of the two DOEs..
Possible fixes
I do not have the fix but I think the correction must be done in OptimizationProblem.__preprocess_func
which handles the observables in a specific way.
Edited by Matthias De Lozzo