Optimization algorithms

In this example, we will discover the different high-levels functions related to optimization algorithms.

from __future__ import annotations

from gemseo import configure_logger
from gemseo import get_algorithm_options_schema
from gemseo import get_available_opt_algorithms

configure_logger()
<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

get_available_opt_algorithms()
['Augmented_Lagrangian_order_0', 'Augmented_Lagrangian_order_1', 'MMA', 'MNBI', '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', 'PYMOO_GA', 'PYMOO_NSGA2', 'PYMOO_NSGA3', 'PYMOO_UNSGA3', 'PYMOO_RNSGA3', 'DUAL_ANNEALING', 'SHGO', 'DIFFERENTIAL_EVOLUTION', 'LINEAR_INTERIOR_POINT', 'REVISED_SIMPLEX', 'SIMPLEX', 'HIGHS_INTERIOR_POINT', 'HIGHS_DUAL_SIMPLEX', 'HIGHS', 'Scipy_MILP', 'SLSQP', 'L-BFGS-B', 'TNC', 'NELDER-MEAD']

Get options schema

For a given optimization algorithm, e.g. "NLOPT_SLSQP", we can get the options; e.g.

get_algorithm_options_schema("NLOPT_SLSQP")
{'$schema': 'http://json-schema.org/draft-04/schema', 'additionalProperties': False, 'type': 'object', 'properties': {'normalize_design_space': {'description': 'If ``True``,\nnormalize the design variables between 0 and 1.', 'type': 'boolean'}, 'round_ints': {'type': 'boolean'}, 'use_database': {'type': 'boolean'}, 'reset_iteration_counters': {'type': 'boolean'}, 'xtol_rel': {'minimum': 0.0, 'description': 'The relative tolerance on the design parameters.', 'type': 'number'}, 'xtol_abs': {'minimum': 0.0, 'description': 'The absolute tolerance on the design parameters.', 'type': 'number'}, 'ftol_rel': {'minimum': 0.0, 'description': 'The relative tolerance on the objective function.', 'type': 'number'}, 'ftol_abs': {'minimum': 0.0, 'description': 'The absolute tolerance on the objective function.', 'type': 'number'}, 'stop_crit_n_x': {'anyOf': [{'description': 'The minimum number of design vectors to take into account in\nthe stopping criteria.', 'type': 'null'}, {'minimum': 2, 'description': 'The minimum number of design vectors to take into account in\nthe stopping criteria.', 'type': 'integer'}]}, 'max_iter': {'minimum': 1, 'description': 'The maximum number of iterations.', 'type': 'integer'}, 'max_time': {'minimum': 0.0, 'description': 'The maximum runtime in seconds.\nThe value 0 means no runtime limit.', 'type': 'number'}, 'stopval': {'anyOf': [{'description': 'The objective value at which the optimization will stop.\nStop minimizing when an objective value :math:`\\leq` stopval is\nfound, or stop maximizing when a value :math:`\\geq` stopval\nis found. If ``None``, this termination condition will not be active.', 'type': 'null'}, {'description': 'The objective value at which the optimization will stop.\nStop minimizing when an objective value :math:`\\leq` stopval is\nfound, or stop maximizing when a value :math:`\\geq` stopval\nis found. If ``None``, this termination condition will not be active.', 'type': 'number'}]}, 'ctol_abs': {'minimum': 0.0, 'description': 'The absolute tolerance on the constraints.', 'type': 'number'}, 'eq_tolerance': {'minimum': 0.0, 'description': 'The tolerance on the equality constraints.', 'type': 'number'}, 'ineq_tolerance': {'minimum': 0.0, 'description': 'The tolerance on the inequality constraints.', 'type': 'number'}, 'init_step': {'minimum': 0.0, 'description': 'The initial step size :math:`r` for derivative-free algorithms.\nIncreasing the initial step size\nwill make the initial DOE of size :math:`d+1`\ntake wider steps in the design variables.\nIn details,\ngiven a :math:`d`-length design vector initialized to :math:`x_0`,\nthe first value of the design vector will be\nthe initial one :math:`x^{(1)}=x_0`,\nthe second one will be\n:math:`x^{(2)}=x^{(1)}+(r(\\max(x_1)-\\min(x_1)),0,\\ldots,0)`,\n...,\nthe :math:`d+1`-th one will be\n:math:`x^{(d+1)}=x^{d}+(0,\\ldots,0,r(\\max(x_d)-\\min(x_d)))`.\nNote that in a normalized design space,\n:math:`\\min(x_i)=0` and :math:`\\max(x_i)=1`.', 'type': 'number'}, 'inner_maxeval': {'minimum': 0, 'type': 'integer'}, 'kkt_tol_abs': {'anyOf': [{'description': 'The absolute tolerance on the KKT residual norm.\nIf ``None`` this criterion is not activated.', 'type': 'null'}, {'minimum': 0.0, 'description': 'The absolute tolerance on the KKT residual norm.\nIf ``None`` this criterion is not activated.', 'type': 'number'}]}, 'kkt_tol_rel': {'anyOf': [{'description': 'The relative tolerance on the KKT residual norm.\nIf ``None`` this criterion is not activated.', 'type': 'null'}, {'minimum': 0.0, 'description': 'The relative tolerance on the KKT residual norm.\nIf ``None`` this criterion is not activated.', 'type': 'number'}]}, 'scaling_threshold': {'oneOf': [{'type': 'number', 'minimum': 0}, {'type': 'null'}]}}, 'required': ['max_iter']}

Total running time of the script: (0 minutes 0.005 seconds)

Gallery generated by Sphinx-Gallery