Note
Click here to download the full example code
Optimization algorithms¶
In this example, we will discover the different functions of the API related to optimization algorithms.
from __future__ import division, unicode_literals
from gemseo.api import (
configure_logger,
get_algorithm_options_schema,
get_available_opt_algorithms,
)
configure_logger()
Out:
<RootLogger root (INFO)>
Get available optimization algorithms¶
The get_available_opt_algorithms()
function returns the list
of optimization algorithms available in GEMSEO or in external modules
print(get_available_opt_algorithms())
Out:
['NLOPT_MMA', 'NLOPT_COBYLA', 'NLOPT_SLSQP', 'NLOPT_BOBYQA', 'NLOPT_BFGS', 'NLOPT_NEWUOA', 'PDFO_COBYLA', 'PDFO_BOBYQA', 'PDFO_NEWUOA', 'PSEVEN', 'PSEVEN_FD', 'PSEVEN_MOM', 'PSEVEN_NCG', 'PSEVEN_NLS', 'PSEVEN_POWELL', 'PSEVEN_QP', 'PSEVEN_SQP', 'PSEVEN_SQ2P', 'DUAL_ANNEALING', 'SHGO', 'DIFFERENTIAL_EVOLUTION', 'LINEAR_INTERIOR_POINT', 'REVISED_SIMPLEX', 'SIMPLEX', 'SLSQP', 'L-BFGS-B', 'TNC', 'SNOPTB']
Get options schema¶
For a given optimization algorithm, e.g. "NLOPT_SLSQP"
,
we can get the options; e.g.
print(get_algorithm_options_schema("NLOPT_SLSQP"))
Out:
{'$schema': 'http://json-schema.org/draft-04/schema', 'additionalProperties': False, 'type': 'object', 'properties': {'xtol_rel': {'minimum': 0.0, 'description': 'Relative design parameter tolerance :type xtol_rel: float', 'type': 'number'}, 'normalize_design_space': {'description': 'If True, scales variables in [0, 1] :type normalize_design_space: bool', 'type': 'boolean'}, 'xtol_abs': {'minimum': 0.0, 'description': 'Design parameter tolerance :type xtol_abs: float', 'type': 'number'}, 'ftol_rel': {'minimum': 0.0, 'description': 'Relative objective function tolerance :type ftol_rel: float', 'type': 'number'}, 'ftol_abs': {'minimum': 0.0, 'description': 'Objective function tolerance :type ftol_abs: float', 'type': 'number'}, 'max_iter': {'minimum': 1, 'description': 'maximum number of iterations :type max_iter: int', 'type': 'integer'}, 'max_time': {'minimum': 0.0, 'description': 'maximum runtime in seconds, disabled if 0 (Default value = 0) :type max_time: float', 'type': 'number'}, 'stopval': {'description': 'Stop when an objective value of at least stopval is found: stop minimizing when an objective value :math:`\\leq` stopval is found, or stop maximizing a value :math:`\\geq` stopval is found. :type stopval: float', 'type': 'number'}, 'ctol_abs': {'minimum': 0.0, 'description': 'Absolute tolerance for constraints :type ctol_abs: float', 'type': 'number'}, 'eq_tolerance': {'minimum': 0.0, 'description': 'equality tolerance :type eq_tolerance: float', 'type': 'number'}, 'ineq_tolerance': {'minimum': 0.0, 'description': 'inequality tolerance :type ineq_tolerance: float', 'type': 'number'}, 'init_step': {'minimum': 0.0, 'description': 'initial step size for derivavtive free algorithms increasing init_step will make the initial DOE in COBYLA wider steps in the design variables. By defaults, each variable is set to x0 + a perturbation that worths 0.25*(ub_i-x0_i) for i in xrange(len(x0)) :type init_step: float', 'type': 'number'}}, 'required': ['max_iter']}
Total running time of the script: ( 0 minutes 0.003 seconds)