gemseo / formulations

mdf module

The Multi-disciplinary Design Feasible (MDF) formulation.

Classes:

MDF(disciplines, objective_name, design_space)

The Multidisciplinary Design Feasible (MDF) formulation.

class gemseo.formulations.mdf.MDF(disciplines, objective_name, design_space, maximize_objective=False, main_mda_class='MDAChain', sub_mda_class='MDAJacobi', **mda_options)[source]

Bases: gemseo.core.formulation.MDOFormulation

The Multidisciplinary Design Feasible (MDF) formulation.

This formulation draws an optimization architecture where:

  • the coupling of strongly coupled disciplines is made consistent by means of a Multidisciplinary Design Analysis (MDA),

  • the optimization problem with respect to the local and global design variables is made at the top level.

Note that the multidisciplinary analysis is made at a each optimization iteration.

Initialize self. See help(type(self)) for accurate signature.

Parameters
  • disciplines – The disciplines.

  • objective_name – The name of the objective function.

  • design_space – The design space.

  • maximize_objective – If True, the objective function is maximized.

  • **options – The options of the formulation.

  • main_mda_class – The name of the class used for the main MDA, typically the MDAChain, but one can force to use MDAGaussSeidel for instance.

  • sub_mda_class – The name of the class used for the sub-MDA.

  • **mda_options – The options passed to the MDA at construction.

Attributes:

NAME

design_space

The design space on which the formulation is applied.

Methods:

add_constraint(output_name[, …])

Add a user constraint.

add_observable(output_names[, …])

Add an observable to the optimization problem.

check_disciplines(disciplines)

Check that the disciplines are provided as a list.

get_default_sub_options_values(**options)

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

get_expected_dataflow()

Get the expected data exchange sequence.

get_expected_workflow()

Get the expected sequence of execution of the disciplines.

get_optim_variables_names()

Get the optimization unknown names to be provided to the optimizer.

get_sub_disciplines()

Accessor to the sub-disciplines.

get_sub_options_grammar(**options)

Get the sub-options grammar.

get_sub_scenarios()

List the disciplines that are actually scenarios.

get_top_level_disc()

Return the disciplines which inputs are required to run the scenario.

get_x_names_of_disc(discipline)

Get the design variables names of a given discipline.

mask_x(masking_data_names, x_vect[, …])

Mask a vector from a subset of names, with respect to a set of names.

mask_x_swap_order(masking_data_names, x_vect)

Mask a vector from a subset of names, with respect to a set of names.

unmask_x(masking_data_names, x_masked[, …])

Unmask a vector from a subset of names, with respect to a set of names.

unmask_x_swap_order(masking_data_names, x_masked)

Unmask a vector from a subset of names, with respect to a set of names.

NAME = 'MDOFormulation'
add_constraint(output_name, constraint_type='eq', constraint_name=None, value=None, positive=False)

Add a user constraint.

A user constraint is a design constraint in addition to the formulation specific constraints such as the targets (a.k.a. consistency constraints) in IDF.

The strategy of repartition of constraints is defined in the formulation class.

Parameters
  • output_name (str) – The name of the output to be used as a constraint. For instance, if g_1 is given and constraint_type=”eq”, g_1=0 will be added as a constraint to the optimizer.

  • constraint_type (str) – The type of constraint, either “eq” for equality constraint or “ineq” for inequality constraint.

  • constraint_name (Optional[str]) – The name of the constraint to be stored, If None, the name is generated from the output name.

  • value (Optional[float]) – The value of activation of the constraint. If None, the value is equal to 0.

  • positive (bool) – If True, the inequality constraint is positive.

Return type

None

add_observable(output_names, observable_name=None, discipline=None)

Add an observable to the optimization problem.

The repartition strategy of the observable is defined in the formulation class.

Parameters
  • output_names (Union[str, Sequence[str]]) – The name(s) of the output(s) to observe.

  • observable_name (Optional[str]) – The name of the observable.

  • discipline (Optional[gemseo.core.discipline.MDODiscipline]) – The discipline computing the observed outputs. If None, the discipline is detected from inner disciplines.

Return type

None

static check_disciplines(disciplines)

Check that the disciplines are provided as a list.

Parameters

disciplines (Any) – The disciplines.

Return type

None

property design_space

The design space on which the formulation is applied.

classmethod get_default_sub_options_values(**options)[source]

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

When some options of the formulation depend on higher level options, the default values of these sub-options may be obtained here, mainly for use in the API.

Parameters
  • **options – The options required to deduce the sub-options grammar.

  • options (str) –

Returns

Either None or the sub-options default values.

Return type

Dict

get_expected_dataflow()[source]

Get the expected data exchange sequence.

This method is used for the XDSM representation and can be overloaded by subclasses.

Returns

The expected sequence of data exchange where the i-th item is described by the starting discipline, the ending discipline and the coupling variables.

Return type

List[Tuple[gemseo.core.discipline.MDODiscipline, gemseo.core.discipline.MDODiscipline, List[str]]]

get_expected_workflow()[source]

Get the expected sequence of execution of the disciplines.

This method is used for the XDSM representation and can be overloaded by subclasses.

For instance:

  • [A, B] denotes the execution of A, then the execution of B

  • (A, B) denotes the concurrent execution of A and B

  • [A, (B, C), D] denotes the execution of A, then the concurrent execution of B and C, then the execution of D.

Returns

A sequence of elements which are either an ExecutionSequence or a tuple of ExecutionSequence for concurrent execution.

Return type

List[ExecutionSequence, Tuple[ExecutionSequence]]

get_optim_variables_names()

Get the optimization unknown names to be provided to the optimizer.

This is different from the design variable names provided by the user, since it depends on the formulation, and can include target values for coupling for instance in IDF.

Returns

The optimization variable names.

Return type

List[str]

get_sub_disciplines()

Accessor to the sub-disciplines.

This method lists the sub scenarios’ disciplines.

Returns

The sub-disciplines.

Return type

List[gemseo.core.discipline.MDODiscipline]

classmethod get_sub_options_grammar(**options)[source]

Get the sub-options grammar.

When some options of the formulation depend on higher level options, the schema of the sub-options may be obtained here, mainly for use in the API.

Parameters
  • **options – The options required to deduce the sub-options grammar.

  • options (str) –

Returns

Either None or the sub-options grammar.

Return type

gemseo.core.grammars.json_grammar.JSONGrammar

get_sub_scenarios()

List the disciplines that are actually scenarios.

Returns

The scenarios.

Return type

List[Scenario]

get_top_level_disc()[source]

Return the disciplines which inputs are required to run the scenario.

A formulation seeks to evaluate objective function and constraints from inputs. It structures the optimization problem into multiple levels of disciplines. The disciplines directly depending on these inputs are called top level disciplines.

By default, this method returns all disciplines. This method can be overloaded by subclasses.

Returns

The top level disciplines.

Return type

List[gemseo.core.discipline.MDODiscipline]

get_x_names_of_disc(discipline)

Get the design variables names of a given discipline.

Parameters

discipline (gemseo.core.discipline.MDODiscipline) – The discipline.

Returns

The names of the design variables.

Return type

List[str]

mask_x(masking_data_names, x_vect, all_data_names=None)

Mask a vector from a subset of names, with respect to a set of names.

Parameters
  • masking_data_names (Iterable[str]) – The names of data to keep.

  • x_vect (numpy.ndarray) – The vector of float to mask.

  • all_data_names (Optional[Iterable[str]]) – The set of all names. If None, use the design variables stored in the design space.

Returns

A boolean mask with the same shape as the input vector.

Return type

numpy.ndarray

mask_x_swap_order(masking_data_names, x_vect, all_data_names=None)

Mask a vector from a subset of names, with respect to a set of names.

This method eventually swaps the order of the values if the order of the data names is inconsistent between these sets.

Parameters
  • masking_data_names (Iterable[str]) – The names of the kept data.

  • x_vect (numpy.ndarray) – The vector to mask.

  • all_data_names (Optional[Iterable[str]]) – The set of all names. If None, use the design variables stored in the design space.

Returns

The masked version of the input vector.

Return type

numpy.ndarray

unmask_x(masking_data_names, x_masked, all_data_names=None, x_full=None)

Unmask a vector from a subset of names, with respect to a set of names.

Parameters
  • masking_data_names (Iterable[str]) – The names of the kept data.

  • x_masked (numpy.ndarray) – The boolean vector to unmask.

  • all_data_names (Optional[Iterable[str]]) – The set of all names. If None, use the design variables stored in the design space.

  • x_full (Optional[numpy.ndarray]) – The default values for the full vector. If None, use the zero vector.

Returns

The vector related to the input mask.

Return type

numpy.ndarray

unmask_x_swap_order(masking_data_names, x_masked, all_data_names=None, x_full=None)

Unmask a vector from a subset of names, with respect to a set of names.

This method eventually swaps the order of the values if the order of the data names is inconsistent between these sets.

Parameters
  • masking_data_names (Iterable[str]) – The names of the kept data.

  • x_masked (numpy.ndarray) – The boolean vector to unmask.

  • all_data_names (Optional[Iterable[str]]) – The set of all names. If None, use the design variables stored in the design space.

  • x_full (Optional[numpy.ndarray]) – The default values for the full vector. If None, use the zero vector.

Returns

The vector related to the input mask.

Return type

numpy.ndarray