gemseo.utils.testing.opt_lib_test_base module#
Common tools for testing opt libraries.
- class OptLibraryTestBase[source]#
Bases:
objectMain testing class.
- static create_test(problem, algo_name, settings)[source]#
Create a function to run and test an optimization algorithm.
- Parameters:
problem (OptimizationProblem) -- The optimization problem.
algo_name (str) -- The name of the optimization algorithm.
settings (dict[str, Any]) -- The settings of the optimization algorithm.
- Returns:
The error message if the optimizer cannot find the solution, otherwise
None.
- static generate_error_test(opt_lib_name, algo_name, **settings)[source]#
Solve the Power 2 problem with an optimization library.
This optimization problem has constraints.
This problem raises an error when calling the objective.
- Parameters:
opt_lib_name -- The name of the optimization library.
algo_name -- The name of the optimization algorithm.
**settings -- The settings of the optimization algorithm.
- Returns:
An optimization library after the resolution of the Rosenbrock problem.
- static generate_one_test(algo_name, **settings)[source]#
Solve the Power 2 problem with an optimization library.
This optimization problem has equality constraints.
- Parameters:
algo_name (str) -- The name of the optimization algorithm.
**settings (Any) -- The settings of the optimization algorithm.
- Returns:
An optimization library after the resolution of the Power 2 problem.
- Return type:
- static generate_one_test_unconstrained(opt_lib_name, algo_name, **settings)[source]#
Solve the Rosenbrock problem with an optimization library.
This optimization problem has no constraints.
- Parameters:
opt_lib_name -- The name of the optimization library.
algo_name -- The name of the optimization algorithm.
**settings -- The settings of the optimization algorithm.
- Returns:
An optimization library after the resolution of the Rosenbrock problem.
- generate_test(opt_lib_name, get_settings=None, get_problem_options=None)[source]#
Generates the tests for an opt library Filters algorithms adapted to the benchmark problems.
- Parameters:
opt_lib_name -- The name of the optimization library.
get_settings -- A function to get the settings of the algorithm.
get_problem_options -- A function to get the options of the problem.
- Returns:
The test methods to be attached to an unitest class.
- static get_pb_instance(pb_name, pb_options=None)[source]#
Return an optimization problem.
- Parameters:
- Raises:
ValueError -- When the problem is not available.
- Return type:
- static run_and_test_problem(problem, algo_name, **settings)[source]#
Run and test an optimization algorithm.
- Parameters:
problem (OptimizationProblem) -- The optimization problem.
algo_name (str) -- The name of the optimization algorithm.
**settings (Any) -- The settings of the optimization algorithm.
- Returns:
The error message if the optimizer cannot find the solution, otherwise
None.- Return type:
str | None