.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/api/plot_formulation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_api_plot_formulation.py: Formulation =========== In this example, we will discover the different functions of the API related to MDO formulations: their names, their options and their sub-options. .. GENERATED FROM PYTHON SOURCE LINES 28-41 .. code-block:: Python from __future__ import annotations from gemseo import configure_logger from gemseo import get_available_formulations from gemseo import get_formulation_options_schema from gemseo import get_formulation_sub_options_schema from gemseo import get_formulations_options_defaults from gemseo import get_formulations_sub_options_defaults configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 42-47 Get available formulations -------------------------- The :func:`.get_available_formulations` function returns the list of MDO formulations available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python get_available_formulations() .. rst-class:: sphx-glr-script-out .. code-block:: none ['BiLevel', 'DisciplinaryOpt', 'IDF', 'MDF'] .. GENERATED FROM PYTHON SOURCE LINES 50-56 Get formulation schemas for (sub-)options ----------------------------------------- For a given MDO formulation, e.g. ``"MDF"``, we can: - get the options of an MDO formulation using the :func:`.get_formulation_options_schema` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python get_formulation_options_schema("MDF") .. rst-class:: sphx-glr-script-out .. code-block:: none {'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'maximize_objective': {'description': 'Whether to maximize the objective.', 'type': 'boolean'}, 'grammar_type': {'description': 'The type of the input and output grammars.', 'type': 'string'}, 'main_mda_name': {'description': 'The name of the class used for the main MDA, typically the :class:`.MDAChain`, but one can force to use :class:`.MDAGaussSeidel` for instance.', 'type': 'string'}, 'inner_mda_name': {'description': 'The name of the class used for the inner-MDA of the main MDA, if any; typically when the main MDA is an :class:`.MDAChain`.', 'type': 'string'}}} .. GENERATED FROM PYTHON SOURCE LINES 59-61 - get the default option values using the :func:`.get_formulations_options_defaults` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 61-63 .. code-block:: Python get_formulations_options_defaults("MDF") .. rst-class:: sphx-glr-script-out .. code-block:: none {'maximize_objective': False, 'grammar_type': , 'main_mda_name': 'MDAChain', 'inner_mda_name': 'MDAJacobi'} .. GENERATED FROM PYTHON SOURCE LINES 64-66 - get sub-options of an MDO formulation using the :func:`.get_formulation_sub_options_schema` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python get_formulation_sub_options_schema("MDF", main_mda_name="MDAGaussSeidel") .. rst-class:: sphx-glr-script-out .. code-block:: none {'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'name': {'description': 'The name to be given to the MDA. If ``None``, use the name of the class.', 'type': 'null'}, 'max_mda_iter': {'description': 'The maximum iterations number for the MDA algorithm.', 'type': 'integer'}, 'grammar_type': {'description': 'The type of the input and output grammars.', 'type': 'string'}, 'tolerance': {'description': 'The tolerance of the iterative direct coupling solver; the norm of the current residuals divided by initial residuals norm shall be lower than the tolerance to stop iterating.', 'type': 'number'}, 'linear_solver_tolerance': {'description': 'The tolerance of the linear solver in the adjoint equation.', 'type': 'number'}, 'warm_start': {'description': 'Whether the second iteration and ongoing start from the previous coupling solution.', 'type': 'boolean'}, 'use_lu_fact': {'description': 'Whether to store a LU factorization of the matrix when using adjoint/forward differentiation. to solve faster multiple RHS problem.', 'type': 'boolean'}, 'over_relax_factor': {'description': 'Deprecated, please consider using :attr:`MDA.over_relaxation_factor` instead. The relaxation coefficient, used to make the method more robust, if ``0, 'tolerance': 1e-06, 'linear_solver_tolerance': 1e-12, 'warm_start': False, 'use_lu_fact': False, 'over_relax_factor': None, 'coupling_structure': None, 'log_convergence': False, 'linear_solver': 'DEFAULT', 'linear_solver_options': None, 'acceleration_method': , 'over_relaxation_factor': 1.0} .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.004 seconds) .. _sphx_glr_download_examples_api_plot_formulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_formulation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_formulation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_