.. 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 Click :ref:`here ` 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 30-48 .. code-block:: default from __future__ import absolute_import, division, print_function, unicode_literals from future import standard_library from gemseo.api import ( configure_logger, get_available_formulations, get_formulation_options_schema, get_formulation_sub_options_schema, get_formulations_options_defaults, get_formulations_sub_options_defaults, ) configure_logger() standard_library.install_aliases() .. GENERATED FROM PYTHON SOURCE LINES 49-54 Get available formulations -------------------------- The :meth:`~gemseo.api.get_available_formulations` function returns the list of MDO formulations available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: default print(get_available_formulations()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ['BiLevel', 'DisciplinaryOpt', 'IDF', 'MDF'] .. GENERATED FROM PYTHON SOURCE LINES 57-63 Get formulation schemas for (sub-)options ----------------------------------------- For a given MDO formulation, e.g. :code:`"MDF"`, we can: - get the options of a MDO formulation using the :meth:`~gemseo.api.get_formulation_options_schema` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. code-block:: default print(get_formulation_options_schema("MDF")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'type': 'object', 'properties': {'maximize_objective': {'type': 'boolean', 'description': 'if True, the objective function\nis maximized, by default, a minimization is performed.\n:type maximize_objective: bool\n'}, 'main_mda_class': {'type': 'string', 'description': 'classname of the main MDA, typically the\nMDAChain, but one can force to use MDAGaussSeidel for instance\n:type main_mda_class: str\n'}, 'sub_mda_class': {'type': 'string', 'description': 'the type of MDA to be used,\nshall be the class name. (default MDAJacobi)\n:type sub_mda_class: str\n'}}, 'required': ['main_mda_class', 'maximize_objective', 'sub_mda_class']} .. GENERATED FROM PYTHON SOURCE LINES 66-68 - get the default option values using the :meth:`~gemseo.api.get_formulations_options_defaults` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 68-70 .. code-block:: default print(get_formulations_options_defaults("MDF")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'maximize_objective': False, 'main_mda_class': 'MDAChain', 'sub_mda_class': 'MDAJacobi'} .. GENERATED FROM PYTHON SOURCE LINES 71-73 - get sub-options of a MDO formulation using the :meth:`~gemseo.api.get_formulation_sub_options_schema` function; e.g. .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. code-block:: default print(get_formulation_sub_options_schema("MDF", main_mda_class="MDAGaussSeidel")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'type': 'object', 'properties': {'name': {'description': 'the name of the chain\n:type name: str\n'}, 'max_mda_iter': {'type': 'integer', 'description': 'maximum number of iterations\n:type max_mda_iter: int\n'}, 'grammar_type': {'type': 'string', 'description': 'the type of grammar to use for IO declaration\neither JSON_GRAMMAR_TYPE or SIMPLE_GRAMMAR_TYPE\n:type grammar_type: str\n'}, 'tolerance': {'type': 'number', 'description': 'tolerance of the iterative direct coupling solver,\nnorm of the current residuals divided by initial residuals norm\nshall be lower than the tolerance to stop iterating\n:type tolerance: float\n'}, 'linear_solver_tolerance': {'type': 'number', 'description': 'Tolerance of the linear solver\nin the adjoint equation\n:type linear_solver_tolerance: float\n'}, 'warm_start': {'type': 'boolean', 'description': 'if True, the second iteration and ongoing\nstart from the previous coupling solution\n:type warm_start: bool\n'}, 'use_lu_fact': {'type': 'boolean', 'description': 'if True, when using adjoint/forward\ndifferenciation, store a LU factorization of the matrix\nto solve faster multiple RHS problem\n:type use_lu_fact: bool\n'}, 'norm0': {'description': 'reference value of the norm of the residual to compute\nthe decrease stop criteria.\nIterations stops when norm(residual)/norm0` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_formulation.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_