gemseo

api module

Introduction

Here is the Application Programming Interface (API) of GEMSEO, a set of high level functions for ease of use.

Make GEMSEO ever more accessible

The aim of this API is to provide high level functions that are sufficient to use GEMSEO in most cases, without requiring a deep knowledge of GEMSEO.

Besides, these functions shall change much less often than the internal classes, which is key for backward compatibility, which means ensuring that your current scripts using GEMSEO will be usable with the future versions of GEMSEO.

Connect GEMSEO to your favorite tools

The API also facilitates the interfacing of GEMSEO with a platform or other software.

To interface a simulation software with GEMSEO, please refer to: Interfacing simulation software.

Extending GEMSEO

GEMSEO features can be extended with external python modules. All kinds of additional features can be implemented: disciplines, algorithms, formulations, post-processings, surrogate models, … There are 2 ways to extend GEMSEO with a directory that contains the python modules:

  • by adding the directory to the PYTHONPATH if the directory name starts with gemseo_,

  • by setting the environment variable GEMSEO_PATH to the directory path, multiple directories can be separated by :.

Table of contents

Algorithms

Cache

Configuration

Coupling

Design space

Disciplines

Formulations

MDA

Post-processing

Scalable

Scenario

Surrogates

API functions

Functions:

configure_logger([logger_name, level, …])

Configure GEMSEO logging.

create_cache(cache_type[, name])

Return a cache.

create_dataset(name, data[, variables, …])

Create a dataset from a numpy array or a file.

create_design_space()

Create an empty instance of a DesignSpace.

create_discipline(discipline_name, **options)

Create disciplines that are known to GEMSEO.

create_mda(mda_name, disciplines, **options)

Create an MDA.

create_parameter_space()

Create an empty instance of a ParameterSpace.

create_scalable(name, data[, sizes])

Create a scalable discipline.

create_scenario(disciplines, formulation, …)

Create a scenario.

create_surrogate(surrogate[, data, …])

Create a surrogate discipline.

execute_algo(opt_problem, algo_name[, algo_type])

Solve an optimization problem using either a DOE or an Optimization algorithm.

execute_post(to_post_proc, post_name, **options)

Execute a post-processing method.

export_design_space(design_space, output_file)

Export a design space to a text or HDF file.

generate_coupling_graph(disciplines[, …])

Generate a graph of the couplings for the disciplines list.

generate_n2_plot(disciplines[, file_path, …])

Generate a N2 plot for the disciplines list.

get_algorithm_options_schema(algorithm_name)

Get the options schema as a JSON Schema string or dictionary for a given algorithm.

get_all_inputs(disciplines[, recursive])

List all the inputs of the disciplines.

get_all_outputs(disciplines[, recursive])

List all the outputs of the disciplines.

get_available_caches()

Return available caches.

get_available_disciplines()

List the available disciplines names in the present configuration.

get_available_doe_algorithms()

List the available Design of Experiments algorithms names in the present configuration.

get_available_formulations()

List the available formulations in the current configuration.

get_available_mdas()

List the available MDAs.

get_available_opt_algorithms()

List the available optimization algorithms names in the present configuration.

get_available_post_processings()

List the available optimization post-processings.

get_available_scenario_types()

List the available scenario types.

get_available_surrogates()

List the available surrogate model names in the present configuration.

get_discipline_inputs_schema(discipline[, …])

Get the inputs schema of a discipline.

get_discipline_options_defaults(discipline_name)

Get the default values of the options of a discipline.

get_discipline_options_schema(discipline_name)

Get the options schema of a discipline.

get_discipline_outputs_schema(discipline[, …])

Get the outputs schema of a discipline.

get_formulation_options_schema(formulation_name)

Get the options schema of a MDO formulation.

get_formulation_sub_options_schema(…[, …])

Get the sub-options schema of a MDO formulation.

get_formulations_options_defaults(…)

Get the default values of the options of a formulation.

get_formulations_sub_options_defaults(…)

Get the default values of the sub options of a formulation.

get_mda_options_schema(mda_name[, …])

Get the options schema of a MDA.

get_post_processing_options_schema(…[, …])

List the options schema of a post-processing.

get_scenario_differenciation_modes()

List the available differenciation modes of a scenario.

get_scenario_inputs_schema(scenario[, …])

Get the schema of the inputs of a scenario.

get_scenario_options_schema(scenario_type[, …])

Get the options schema of a scenario.

get_surrogate_options_schema(surrogate_name)

Lists the available options for a surrogate discipline.

load_dataset(dataset, **options)

Create a dataset from an existing subclass of Dataset.

monitor_scenario(scenario, observer)

Adds an observer to a scenario The observer must have an “update(atom)” method that handles the execution status change of atom update(atom) is called everytime an atom execution changes.

print_configuration()

Print the configuration with successfully loaded modules and failed imports with the reason.

read_design_space(file_path[, header])

Read a file containing a design space and return a DesignSpace object.

gemseo.api.configure_logger(logger_name=None, level=20, date_format='%H:%M:%S', message_format='%(levelname)8s - %(asctime)s: %(message)s', filename=None, filemode='a')[source]

Configure GEMSEO logging.

Parameters
  • logger_name (str) – Name of the logger to configure, default: None, i.e. the root logger.

  • level (str) – Logging level among ‘DEBUG’, ‘INFO’, ‘WARNING’ or ‘CRITICAL’s, default: ‘INFO’.

  • date_format (str) – Logging date format, default: %H:%M:%S.

  • message_format (str) – logging message format, default: %(levelname)8s - %(asctime)s: %(message)s.

  • filename (str) – File path if outputs must be written in a file, default: None.

  • filemode (str) – Logging output file mode, ‘w’ (overwrite) or ‘a’ (append), default: ‘a’.

Examples

>>> import logging
>>> configure_logger(logging.WARNING)
gemseo.api.create_cache(cache_type, name=None, **options)[source]

Return a cache.

Parameters
  • cache_type (str) – type of cache.

  • name (str) – name of the cache. If None, use cache_type.

  • options – options specific to cache_type

Examples

>>> from gemseo.api import create_cache
>>> cache = create_cache('MemoryFullCache')
>>> print(cache)
+--------------------------------+
|        MemoryFullCache         |
+--------------+-----------------+
|   Property   |      Value      |
+--------------+-----------------+
|     Type     | MemoryFullCache |
|  Tolerance   |       0.0       |
| Input names  |       None      |
| Output names |       None      |
|    Length    |        0        |
+--------------+-----------------+
gemseo.api.create_dataset(name, data, variables=None, sizes=None, groups=None, by_group=True, delimiter=',', header=True, default_name=None)[source]

Create a dataset from a numpy array or a file.

Parameters
  • name (str) – dataset name.

  • data (array or str) – array dataset or file path.

  • variables (list(str)) – list of variables names.

  • sizes (dict(int)) – list of variables sizes.

  • groups (dict(str)) – list of variables groups.

  • by_group (bool) – if True, store the data by group. Otherwise, store them by variables. Default: True.

  • delimiter (str) – field delimiter. Default: ‘,’.

  • header (bool) – if True and data is a string, read the variables names on the first line of the file. Default: True.

  • default_name (str) – default variable name.

See also

load_dataset

gemseo.api.create_design_space()[source]

Create an empty instance of a DesignSpace.

Returns

Empty design space

Return type

DesignSpace

Examples

>>> from gemseo.api import create_design_space
>>> design_space = create_design_space()
>>> design_space.add_variable('x', l_b=-1, u_b=1, value=0.)
>>> print(design_space)
Design Space:
+------+-------------+-------+-------------+-------+
| name | lower_bound | value | upper_bound | type  |
+------+-------------+-------+-------------+-------+
| x    |      -1     |   0   |      1      | float |
+------+-------------+-------+-------------+-------+
gemseo.api.create_discipline(discipline_name, **options)[source]

Create disciplines that are known to GEMSEO.

GEMSEO knows the disciplines located in the following directories:

  • the directories listed in the environment variable GEMSEO_PATH,

  • the directories located in the problems package,

Parameters
  • discipline_name (MDODiscipline) – Name of the discipline, or list of names.

  • options – Additional options to be passed to the discipline constructor.

Returns

Disciplines.

Return type

list(MDODiscipline)

Examples

>>> from gemseo.api import create_discipline
>>> discipline = create_discipline('Sellar1')
>>> discipline.execute()
{'x_local': array([0.+0.j]),
 'x_shared': array([1.+0.j, 0.+0.j]),
 'y_0': array([0.89442719+0.j]),
 'y_1': array([1.+0.j])}
gemseo.api.create_mda(mda_name, disciplines, **options)[source]

Create an MDA.

Parameters
  • mda_name (str) – Name of the MDA (its classname).

  • disciplines (list(MDODiscipline)) – List of the disciplines.

  • options – Additional options specific to the MDA.

Returns

MDA instance.

Return type

MDA

Examples

>>> from gemseo.api import create_discipline, create_mda
>>> disciplines = create_discipline(['Sellar1', 'Sellar2'])
>>> mda = create_mda('MDAGaussSeidel', disciplines)
>>> mda.execute()
{'x_local': array([0.+0.j]),
 'x_shared': array([1.+0.j, 0.+0.j]),
 'y_0': array([0.79999995+0.j]),
 'y_1': array([1.79999995+0.j])}
gemseo.api.create_parameter_space()[source]

Create an empty instance of a ParameterSpace.

Returns

Empty parameter space

Return type

ParameterSpace

gemseo.api.create_scalable(name, data, sizes=None, **parameters)[source]

Create a scalable discipline.

Parameters
  • name (str) – scalable model class name.

  • data (Dataset) – learning dataset.

  • sizes (dict) – sizes of input and output variables.

  • parameters – model parameters

gemseo.api.create_scenario(disciplines, formulation, objective_name, design_space, name=None, scenario_type='MDO', maximize_objective=False, **options)[source]

Create a scenario.

Parameters
  • disciplines (list(MDODiscipline)) – Disciplines of the scenario.

  • formulation (str) – Formulation name.

  • objective_name (str) – Objective function name.

  • design_space (DesignSpace or str) – Design space object or a file that contains the design space.

  • name (str) – scenario name

  • scenario_type (str) – Type of scenario, e.g. “DOE” or “MDO”.

  • maximize_objective (bool) – Maximize function objective.

  • options – Options passed to the MDO formulation.

Returns

Scenario.

Return type

Scenario

Examples

>>> from gemseo.api import create_discipline, create_scenario
>>> from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace
>>> disciplines = create_discipline(['Sellar1', 'Sellar2', 'SellarSystem'])
>>> design_space = SellarDesignSpace()
>>> scenario = create_scenario(disciplines, 'MDF', 'obj', design_space,
>>>                            'SellarMDFScenario', 'MDO')
gemseo.api.create_surrogate(surrogate, data=None, transformer={'inputs': <gemseo.mlearning.transform.scaler.min_max_scaler.MinMaxScaler object>, 'outputs': <gemseo.mlearning.transform.scaler.min_max_scaler.MinMaxScaler object>}, disc_name=None, default_inputs=None, input_names=None, output_names=None, **parameters)[source]

Create a surrogate discipline.

Parameters
  • surrogate (str or MLRegressionAlgo) – name of the surrogate model algorithm.

  • data (Dataset) – dataset to train the surrogate. If None, assumes that the surrogate is trained. Default: None.

  • transformer (dict(Transformer)) – transformation strategy for data groups. If None, do not scale data. Default: MLRegressionAlgo.DEFAULT_SCALER, which is a min/max scaler applied to the inputs and a min/max scaler applied to the outputs.

  • disc_name (str) – Surrogate discipline name.

  • default_inputs (dict) – default inputs. If None, use the center of the learning input space. Default: None.

  • input_names (list(str)) – list of input names. If None, use all inputs. Default: None.

  • output_names (list(str)) – list of output names. If None, use all outputs. Default: None.

  • parameters – Additional parameters to be passed to the surrogate for its construction.

Returns

Surrogate discipline instance.

Return type

SurrogateDiscipline

gemseo.api.execute_algo(opt_problem, algo_name, algo_type='opt', **options)[source]

Solve an optimization problem using either a DOE or an Optimization algorithm.

Parameters
  • opt_problem (OptimizationProblem) – the OptimizationProblem to be solved.

  • algo_name (str) – Name of the algorithm to be used to solve the problem.

  • algo_type (str) – “opt” or “doe” to use an optimization or a Design of Experiments algorithm

  • options – algorithm options

Examples

>>> from gemseo.api import execute_algo
>>> from gemseo.problems.analytical.rosenbrock import Rosenbrock
>>> opt_problem = Rosenbrock()
>>> opt_result = execute_algo(opt_problem, 'SLSQP')
>>> opt_result
Optimization result:
|_ Design variables: [0.99999787 0.99999581]
|_ Objective function: 5.054173713127532e-12
|_ Feasible solution: True
gemseo.api.execute_post(to_post_proc, post_name, **options)[source]

Execute a post-processing method.

Parameters
  • to_post_proc (MDOScenario, DOEScenario, OptimizationProblem, or str) – MDO or DOE scenario, or an optimization problem, or a path to a HDF file containing a saved OptimizationProblem.

  • post_name (str) – Post processing name.

  • options – Post-processing options.

Examples

>>> from gemseo.api import create_discipline, create_scenario, execute_post
>>> from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace
>>> disciplines = create_discipline(['Sellar1', 'Sellar2', 'SellarSystem'])
>>> design_space = SellarDesignSpace()
>>> scenario = create_scenario(disciplines, 'MDF', 'obj', design_space,
>>>                            'SellarMDFScenario', 'MDO')
>>> scenario.execute({'algo': 'NLOPT_SLSQP', 'max_iter': 100})
>>> execute_post(scenario, 'OptHistoryView', show=False, save=True)
gemseo.api.export_design_space(design_space, output_file, export_hdf=False, fields=None, header_char='', **table_options)[source]

Export a design space to a text or HDF file.

Parameters
  • design_space (DesignSpace) – Design space.

  • export_hdf (bool) – Export to a HDF file (True, default) or a txt file (False).

  • output_file (str) – Output file path.

  • fields (list(str)) – List of fields to export, by default all.

  • header_char (str) – Header to use when exporting to a text file. Default: “”.

Examples

>>> from gemseo.api import create_design_space, export_design_space
>>> design_space = create_design_space()
>>> design_space.add_variable('x', l_b=-1, u_b=1, value=0.)
>>> export_design_space(design_space, 'file.txt')
gemseo.api.generate_coupling_graph(disciplines, file_path='coupling_graph.pdf', full=True)[source]

Generate a graph of the couplings for the disciplines list.

Parameters
  • disciplines (list(MDODiscipline)) – List of disciplines to analyze.

  • file_path (str) – File path of the figure.

  • full (bool) – If True, generate the full coupling graph. Otherwise, generate the condensed one.

Examples

>>> from gemseo.api import create_discipline, generate_coupling_graph
>>> disciplines = create_discipline(['Sellar1', 'Sellar2', 'SellarSystem'])
>>> generate_coupling_graph(disciplines)
gemseo.api.generate_n2_plot(disciplines, file_path='n2.pdf', show_data_names=True, save=True, show=False, figsize=(15, 10), open_browser=False)[source]

Generate a N2 plot for the disciplines list.

Parameters
  • disciplines (list(MDODiscipline)) – List of disciplines to analyze.

  • file_path (str) – File path of the figure.

  • show_data_names (bool) – If true, the names of the coupling data is shown otherwise, circles are drawn, which size depend on the number of coupling names.

  • save (bool) – If True, saved the figure to file_path.

  • show (bool) – If True, shows the plot.

  • figsize (tuple(float)) – Size of the figure.

  • open_browser (bool) – If True, open the browser and display the N2.

Examples

>>> from gemseo.api import create_discipline, generate_n2_plot
>>> disciplines = create_discipline(['Sellar1', 'Sellar2', 'SellarSystem'])
>>> generate_n2_plot(disciplines)
gemseo.api.get_algorithm_options_schema(algorithm_name, output_json=False, pretty_print=False)[source]

Get the options schema as a JSON Schema string or dictionary for a given algorithm.

Parameters
  • algorithm_name (str) – Name of the algorithm

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – print the schema in a pretty table.

Returns

the option schema (string) of the algorithm

Examples

>>> from gemseo.api import get_algorithm_options_schema
>>> schema = get_algorithm_options_schema('NLOPT_SLSQP', pretty_print=True)
gemseo.api.get_all_inputs(disciplines, recursive=False)[source]

List all the inputs of the disciplines.

Merge the input data from the disciplines grammars.

Parameters
  • disciplines (list(MDODiscipline)) – List of disciplines to search for inputs.

  • recursive (bool) – If True, searches for the inputs of the sub disciplines (when some disciplines are scenarios).

Returns

List of input data.

Examples

>>> from gemseo.api import create_discipline, get_all_inputs
>>> disciplines = create_discipline(['Sellar1', 'Sellar2'])
>>> get_all_inputs(disciplines)
['y_0', 'x_shared', 'y_1', 'x_local']
gemseo.api.get_all_outputs(disciplines, recursive=False)[source]

List all the outputs of the disciplines.

Merge the output data from the disicplines grammars.

Parameters
  • disciplines (list(MDODiscipline)) – List of disciplines to search for outputs.

  • recursive (bool) – If True, searches for the outputs of the sub disciplines (when some disciplines are scenarios).

Returns

List of input data

Examples

>>> from gemseo.api import create_discipline, get_all_outputs
>>> disciplines = create_discipline(['Sellar1', 'Sellar2'])
>>> get_all_outputs(disciplines)
['y_1', 'y_0']
gemseo.api.get_available_caches()[source]

Return available caches.

Returns

list of available caches.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_caches
>>> get_available_caches()
['AbstractFullCache', 'HDF5Cache', 'MemoryFullCache', 'SimpleCache']
gemseo.api.get_available_disciplines()[source]

List the available disciplines names in the present configuration.

Returns

list of available disciplines.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_disciplines
>>> print(get_available_disciplines())
['RosenMF', 'SobieskiAerodynamics', 'ScalableKriging', 'DOEScenario',
'MDOScenario', 'SobieskiMission', 'SobieskiBaseWrapper', 'Sellar1',
'Sellar2', 'MDOChain', 'SobieskiStructure', 'AutoPyDiscipline',
'Structure', 'SobieskiPropulsion', 'Scenario', 'AnalyticDiscipline',
'MDOScenarioAdapter', 'ScalableDiscipline', 'SellarSystem', 'Aerodynamics',
'Mission', 'PropaneComb1', 'PropaneComb2', 'PropaneComb3',
'PropaneReaction', 'MDOParallelChain']
gemseo.api.get_available_doe_algorithms()[source]

List the available Design of Experiments algorithms names in the present configuration.

Returns

list of available DOE algorithms.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_doe_algorithms
>>> get_available_doe_algorithms()
gemseo.api.get_available_formulations()[source]

List the available formulations in the current configuration.

Returns

list of available MDO formulations.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_formulations
>>> get_available_formulations()
gemseo.api.get_available_mdas()[source]

List the available MDAs.

Returns

list of available MDAs.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_mdas
>>> get_available_mdas()
gemseo.api.get_available_opt_algorithms()[source]

List the available optimization algorithms names in the present configuration.

Returns

list of available optimization algorithms.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_opt_algorithms
>>> get_available_opt_algorithms()
gemseo.api.get_available_post_processings()[source]

List the available optimization post-processings.

Returns

List of available post-processings.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_post_processings
>>> print(get_available_post_processings())
['ScatterPlotMatrix', 'VariableInfluence', 'ConstraintsHistory',
'RadarChart', 'Robustness', 'Correlations', 'SOM', 'KMeans',
'ParallelCoordinates', 'GradientSensitivity', 'OptHistoryView',
'BasicHistory', 'ObjConstrHist', 'QuadApprox']
gemseo.api.get_available_scenario_types()[source]

List the available scenario types.

Returns

list of available scenario types.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_scenario_types
>>> get_available_scenario_types()
gemseo.api.get_available_surrogates()[source]

List the available surrogate model names in the present configuration.

Returns

list of available surrogate disciplines.

Return type

list(str)

Examples

>>> from gemseo.api import get_available_surrogates
>>> print(get_available_surrogates())
['RBFRegression', 'GaussianProcessRegression', 'LinearRegression', 'PCERegression']
gemseo.api.get_discipline_inputs_schema(discipline, output_json=False, pretty_print=False)[source]

Get the inputs schema of a discipline.

Parameters
  • discipline (MDODiscipline) – MDODiscipline instance.

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Option schema of the discipline inputs.

Return type

string

Examples

>>> from gemseo.api import create_discipline, get_discipline_inputs_schema
>>> discipline = create_discipline('Sellar1')
>>> schema = get_discipline_inputs_schema(discipline, pretty_print=True)
gemseo.api.get_discipline_options_defaults(discipline_name)[source]

Get the default values of the options of a discipline.

Parameters

discipline_name (str) – Name of the discipline.

Returns

Default option values of a discipline.

Examples

>>> from gemseo.api import get_discipline_options_defaults
>>> get_discipline_options_defaults('Sellar1')
gemseo.api.get_discipline_options_schema(discipline_name, output_json=False, pretty_print=False)[source]

Get the options schema of a discipline.

Parameters
  • discipline_name (str) – Name of the discipline.

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – print the schema in a pretty table.

Returns

Options schema of the discipline

Examples

>>> from gemseo.api import get_discipline_options_schema
>>> schema = get_discipline_options_schema('Sellar1', pretty_print=True)
gemseo.api.get_discipline_outputs_schema(discipline, output_json=False, pretty_print=False)[source]

Get the outputs schema of a discipline.

Parameters
  • discipline (MDODiscipline) – MDODiscipline instance

  • output_json (bool) – If True, return a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

  • pretty_print – Print the schema in a pretty table.

Returns

Schema of the discipline outputs

Return type

string

Examples

>>> from gemseo.api import get_discipline_outputs_schema, create_discipline
>>> discipline = create_discipline('Sellar1')
>>> get_discipline_outputs_schema(discipline, pretty_print=True)
gemseo.api.get_formulation_options_schema(formulation_name, output_json=False, pretty_print=False)[source]

Get the options schema of a MDO formulation.

Parameters
  • formulation_name (str) – Name of the MDO formulation.

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Option schema (string) of the MDO formulation.

Examples

>>> from gemseo.api import get_formulation_options_schema
>>> schema = get_formulation_options_schema('MDF', pretty_print=True)
gemseo.api.get_formulation_sub_options_schema(formulation_name, output_json=False, pretty_print=False, **formulation_options)[source]

Get the sub-options schema of a MDO formulation.

Parameters
  • formulation_name (str) – Name of the MDO formulation

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

  • formulation_options – Options to be passed to the formulation; this is required to instantiate it.

Returns

Sub-option schema of the MDO formulation

Examples

>>> from gemseo.api import get_formulation_sub_options_schema
>>> schema = get_formulation_sub_options_schema('MDF',
>>>                                             main_mda_class='MDAJacobi',
>>>                                             pretty_print=True)
gemseo.api.get_formulations_options_defaults(formulation_name)[source]

Get the default values of the options of a formulation.

Parameters

formulation_name (str) – Name of the discipline.

Returns

Default values of the options of the MDO formulation.

Examples

>>> from gemseo.api import get_formulations_options_defaults
>>> get_formulations_options_defaults('MDF')
{'main_mda_class': 'MDAChain',
 'maximize_objective': False,
 'sub_mda_class': 'MDAJacobi'}
gemseo.api.get_formulations_sub_options_defaults(formulation_name, **formulation_options)[source]

Get the default values of the sub options of a formulation.

Parameters
  • formulation_name (str) – Name of the discipline.

  • formulation_options – Options to be passed to the formulation; this is required to instantiate it.

Returns

Default values of the sub-options of the MDO formulation.

Examples

>>> from gemseo.api import get_formulations_sub_options_defaults
>>> get_formulations_sub_options_defaults('MDF',
>>>                                       main_mda_class='MDAJacobi')
gemseo.api.get_mda_options_schema(mda_name, output_json=False, pretty_print=False)[source]

Get the options schema of a MDA.

Parameters
  • mda_name (str) – Name of the MDA.

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

MDA options schema

Return type

dict or str

Examples

>>> from gemseo.api import get_mda_options_schema
>>> get_mda_options_schema('MDAJacobi')
gemseo.api.get_post_processing_options_schema(post_proc_name, output_json=False, pretty_print=False)[source]

List the options schema of a post-processing.

Parameters
  • post_proc_name (str) – Post processing name.

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Option schema of the post processing

Examples

>>> from gemseo.api import get_post_processing_options_schema
>>> schema = get_post_processing_options_schema('OptHistoryView',
>>>                                             pretty_print=True)
gemseo.api.get_scenario_differenciation_modes()[source]

List the available differenciation modes of a scenario.

Returns

List of differenciation modes.

Return type

list(str)

Examples

>>> from gemseo.api import get_scenario_differenciation_modes
>>> get_scenario_differenciation_modes()
gemseo.api.get_scenario_inputs_schema(scenario, output_json=False, pretty_print=False)[source]

Get the schema of the inputs of a scenario.

Parameters
  • scenario (Scenario) – Scenario instance

  • output_json (bool) – If True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Schema of the scenario inputs

Examples

>>> from gemseo.api import create_discipline, create_scenario,
get_scenario_inputs_schema
>>> from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace
>>> design_space = SellarDesignSpace()
>>> disciplines = create_discipline(['Sellar1','Sellar2','SellarSystem'])
>>> scenario = create_scenario(disciplines, 'MDF', 'obj', design_space,
'my_scenario', 'MDO')
>>> get_scenario_inputs_schema(scenario)
gemseo.api.get_scenario_options_schema(scenario_type, output_json=False, pretty_print=False)[source]

Get the options schema of a scenario.

Parameters
  • scenario_type (str) – Type of scenario (DOE, MDO…)

  • output_json (bool) – True, returns a JSON string, return a dict otherwise.

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Options schema of the scenario

Examples

>>> from gemseo.api import get_scenario_options_schema
>>> get_scenario_options_schema('MDO')
gemseo.api.get_surrogate_options_schema(surrogate_name, output_json=False, pretty_print=False)[source]

Lists the available options for a surrogate discipline.

Parameters
  • surrogate_name (str) – Name of the surrogate discipline

  • output_json (bool) – Apply json format for the schema

  • pretty_print (bool) – Print the schema in a pretty table.

Returns

Option schema (string) of the surrogate discipline

Examples

>>> from gemseo.api import get_surrogate_options_schema
>>> tmp = get_surrogate_options_schema('LinRegSurrogateDiscipline',
>>>                                    pretty_print=True)
gemseo.api.load_dataset(dataset, **options)[source]

Create a dataset from an existing subclass of Dataset. Typically, benchmark datasets can be found in gemseo.problems.dataset.

Parameters

dataset (str) – dataset name (its classname).

See also

create_dataset

gemseo.api.monitor_scenario(scenario, observer)[source]

Adds an observer to a scenario The observer must have an “update(atom)” method that handles the execution status change of atom update(atom) is called everytime an atom execution changes.

Parameters
  • scenario (Scenario) – Scenario to monitor

  • observer – Observer that handles an update of status

gemseo.api.print_configuration()[source]

Print the configuration with successfully loaded modules and failed imports with the reason.

Examples

>>> from gemseo.api import print_configuration
>>> print_configuration()
gemseo.api.read_design_space(file_path, header=None)[source]

Read a file containing a design space and return a DesignSpace object.

Parameters
  • file_path (str) – Path to the text file shall contain a CSV with a row for each variable and at least the bounds of the variable.

  • header (list(str)) – Fields list, or by default, read in the file

Returns

Design space

Return type

DesignSpace

Examples

>>> from gemseo.api import (create_design_space, export_design_space,
>>>     read_design_space)
>>> source_design_space = create_design_space()
>>> source_design_space.add_variable('x', l_b=-1, value=0., u_b=1.)
>>> export_design_space(source_design_space, 'file.txt')
>>> read_design_space = read_design_space('file.txt')
>>> print(read_design_space)
Design Space:
+------+-------------+-------+-------------+-------+
| name | lower_bound | value | upper_bound | type  |
+------+-------------+-------+-------------+-------+
| x    |      -1     |   0   |      1      | float |
+------+-------------+-------+-------------+-------+