Driver: options use_database, round_ints and normalized_design_space are ignored
What
-
DOELibrary
does not recognize the options"use_database"
,"round_ints"
and"normalize_design_space"
. -
OptimizationLibrary
does not recognize"use_database"
and"round_ints"
.
Why
This options are absent from the JSON grammars, e.g. "OT_HALSON_options.json"
and "SLSQP_options.json"
Fix
Define a base grammar with "use_database"
, "round_ints"
and "normalize_design_space"
and update it with a specific one, when defining DriverLib.opt_grammar
.
We could introduce this mechanism in the base class AlgoLib
with a class attribute AlgoLib._COMMON_GRAMMAR
, that would be enriched in subclasses.
Reproducer
Code
from gemseo.algos.doe.lib_openturns import OpenTURNS
from gemseo.algos.opt.lib_scipy import ScipyOpt
from gemse.api import configure_logger
from gemseo.problems.analytical.rosenbrock import Rosenbrock
configure_logger()
problem = Rosenbrock()
doe_library = OpenTURNS()
doe_library.algo_name = "OT_MONTE_CARLO"
doe_library.execute(
problem,
n_samples=2,
use_database=False,
round_ints=True,
normalize_design_space=True,
)
problem = Rosenbrock()
doe_library = ScipyOpt()
doe_library.algo_name = "SLSQP"
doe_library.execute(
problem,
max_iter=2,
use_database=False,
round_ints=True,
normalize_design_space=True,
)
Log
WARNING - 18:06:38: Driver OT_MONTE_CARLO has no option use_database, option is ignored.
WARNING - 18:06:38: Driver OT_MONTE_CARLO has no option round_ints, option is ignored.
WARNING - 18:06:38: Driver OT_MONTE_CARLO has no option normalize_design_space, option is ignored.
INFO - 18:06:38: Optimization problem:
INFO - 18:06:38: minimize rosen(x) = sum(100*(x[1:] - x[:-1]**2)**2 + (1 - x[:-1])**2
INFO - 18:06:38: with respect to x
INFO - 18:06:38: over the design space:
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | name | lower_bound | value | upper_bound | type |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | x[0] | -2 | 0 | 2 | float |
INFO - 18:06:38: | x[1] | -2 | 0 | 2 | float |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: Solving optimization problem with algorithm OT_MONTE_CARLO:
INFO - 18:06:38: ... 0%| | 0/2 [00:00<?, ?it]
INFO - 18:06:38: ... 100%|██████████| 2/2 [00:00<00:00, 2240.55 it/sec, obj=381]
INFO - 18:06:38: Optimization result:
INFO - 18:06:38: Optimizer info:
INFO - 18:06:38: Status: None
INFO - 18:06:38: Message: None
INFO - 18:06:38: Number of calls to the objective function by the optimizer: 2
INFO - 18:06:38: Solution:
INFO - 18:06:38: Objective: 380.99363888353275
INFO - 18:06:38: Design space:
INFO - 18:06:38: +------+-------------+--------------------+-------------+-------+
INFO - 18:06:38: | name | lower_bound | value | upper_bound | type |
INFO - 18:06:38: +------+-------------+--------------------+-------------+-------+
INFO - 18:06:38: | x[0] | -2 | 0.9390243011882795 | 2 | float |
INFO - 18:06:38: | x[1] | -2 | -1.07012967267065 | 2 | float |
INFO - 18:06:38: +------+-------------+--------------------+-------------+-------+
WARNING - 18:06:38: Driver SLSQP has no option use_database, option is ignored.
WARNING - 18:06:38: Driver SLSQP has no option round_ints, option is ignored.
INFO - 18:06:38: Optimization problem:
INFO - 18:06:38: minimize rosen(x) = sum(100*(x[1:] - x[:-1]**2)**2 + (1 - x[:-1])**2
INFO - 18:06:38: with respect to x
INFO - 18:06:38: over the design space:
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | name | lower_bound | value | upper_bound | type |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | x[0] | -2 | 0 | 2 | float |
INFO - 18:06:38: | x[1] | -2 | 0 | 2 | float |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: Solving optimization problem with algorithm SLSQP:
INFO - 18:06:38: ... 0%| | 0/2 [00:00<?, ?it]
INFO - 18:06:38: ... 100%|██████████| 2/2 [00:00<00:00, 2004.45 it/sec, obj=1.6e+3]
INFO - 18:06:38: Optimization result:
INFO - 18:06:38: Optimizer info:
INFO - 18:06:38: Status: None
INFO - 18:06:38: Message: Maximum number of iterations reached. GEMSEO Stopped the driver
INFO - 18:06:38: Number of calls to the objective function by the optimizer: 4
INFO - 18:06:38: Solution:
INFO - 18:06:38: Objective: 1.0
INFO - 18:06:38: Design space:
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | name | lower_bound | value | upper_bound | type |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
INFO - 18:06:38: | x[0] | -2 | 0 | 2 | float |
INFO - 18:06:38: | x[1] | -2 | 0 | 2 | float |
INFO - 18:06:38: +------+-------------+-------+-------------+-------+
Edited by Matthias De Lozzo