opt_lib_test_base module¶
Common tools for testing opt libraries.
- class gemseo.utils.testing.opt_lib_test_base.OptLibraryTestBase[source]¶
Bases:
object
Main testing class.
- static create_test(problem, opt_library, algo_name, options)[source]¶
Create a function to run and test an optimization algorithm.
- Parameters:
problem (OptimizationProblem) – The optimization problem.
opt_library (str) – The name of the optimization library.
algo_name (str) – The name of the optimization algorithm.
options (dict[str, Any]) – The options 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, **options)[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.
**options – The options of the optimization algorithm.
- Returns:
An optimization library after the resolution of the Rosenbrock problem.
- static generate_one_test(opt_lib_name, algo_name, **options)[source]¶
Solve the Power 2 problem with an optimization library.
This optimization problem has equality constraints.
- Parameters:
- Returns:
An optimization library after the resolution of the Power 2 problem.
- Return type:
- static generate_one_test_unconstrained(opt_lib_name, algo_name, **options)[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.
**options – The options of the optimization algorithm.
- Returns:
An optimization library after the resolution of the Rosenbrock problem.
- generate_test(opt_lib_name, get_options=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_options – A function to get the options of the algorithm.
get_problem_options – A function to get the options of the problem.
- Returns!
The test methods to be attached to a 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, opt_library, algo_name, **options)[source]¶
Run and test an optimization algorithm.
- Parameters:
problem (OptimizationProblem) – The optimization problem.
opt_library (str) – The name of the optimization library.
algo_name (str) – The name of the optimization algorithm.
**options (Any) – The options of the optimization algorithm.
- Returns:
The error message if the optimizer cannot find the solution, otherwise
None
.- Return type:
str | None