.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/api/plot_optimization.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_api_plot_optimization.py: Optimization algorithms ======================= In this example, we will discover the different functions of the API related to optimization algorithms. .. GENERATED FROM PYTHON SOURCE LINES 29-36 .. code-block:: default from gemseo.api import configure_logger from gemseo.api import get_algorithm_options_schema from gemseo.api import get_available_opt_algorithms configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 37-42 Get available optimization algorithms ------------------------------------- The :meth:`~gemseo.api.get_available_opt_algorithms` function returns the list of optimization algorithms available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: default print(get_available_opt_algorithms()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ['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', 'SLSQP', 'L-BFGS-B', 'TNC', 'SNOPTB'] .. GENERATED FROM PYTHON SOURCE LINES 45-49 Get options schema ------------------ For a given optimization algorithm, e.g. :code:`"NLOPT_SLSQP"`, we can get the options; e.g. .. GENERATED FROM PYTHON SOURCE LINES 49-50 .. code-block:: default print(get_algorithm_options_schema("NLOPT_SLSQP")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'$schema': 'http://json-schema.org/draft-04/schema', 'additionalProperties': False, 'type': 'object', 'properties': {'xtol_rel': {'minimum': 0.0, 'description': 'The relative tolerance on the design parameters.', 'type': 'number'}, 'normalize_design_space': {'description': 'If True, normalize the design variables between 0 and 1.', 'type': 'boolean'}, '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'}, 'max_iter': {'minimum': 1, 'description': 'The maximum number of iterations.', 'type': 'integer'}, 'max_time': {'minimum': 0.0, 'description': 'The maximum runtime in seconds. The value 0 means no runtime limit.', 'type': 'number'}, 'stopval': {'anyOf': [{'description': 'The objective value at which the optimization will stop. Stop minimizing when an objective value :math:`\\leq` stopval is found, or stop maximizing when a value :math:`\\geq` stopval is found. If None, this termination condition will not be active.', 'type': 'null'}, {'description': 'The objective value at which the optimization will stop. Stop minimizing when an objective value :math:`\\leq` stopval is found, or stop maximizing when a value :math:`\\geq` stopval is 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 for derivative-free algorithms. Increasing init_step will make the initial DOE in COBYLA take wider steps in the design variables. By default, each variable is set to x0 plus a perturbation given by 0.25*(ub_i-x0_i) for i=0, …, len(x0)-1.', 'type': 'number'}, 'inner_maxeval': {'minimum': 0, 'type': 'integer'}}, 'required': ['max_iter']} .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.003 seconds) .. _sphx_glr_download_examples_api_plot_optimization.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_optimization.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_optimization.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_