initialization_chain module¶
MDA input data initialization.
- class gemseo.mda.initialization_chain.MDOInitializationChain(disciplines, name=None, grammar_type=GrammarType.JSON, available_data_names=())[source]
Bases:
MDOChain
An initialization process for a set of disciplines.
This MDOChain subclass computes the initialization for the computation of a set of disciplines. It is particularly useful in the case of MDAs when not all default_inputs are available, and the execution order is not obvious to compute initial values for all couplings.
From the default inputs of the disciplines, use a greedy algorithm to detect sequentially the disciplines that can be executed, and records the execution order.
The couplings are ignored, and therefore, a true MDA must be used afterwards to ensure consistency.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
disciplines (list[MDODiscipline]) – The disciplines.
name (str | None) – The name of the discipline. If
None
, use the class name.grammar_type (MDODiscipline.GrammarType) –
The type of the input and output grammars.
By default it is set to “JSONGrammar”.
available_data_names (Iterable[str]) –
The data names that are assumed to be available at runtime, in addition to the default_inputs.
By default it is set to ().
- cache: AbstractCache | None
The cache containing one or several executions of the discipline according to the cache policy.
- data_processor: DataProcessor
A tool to pre- and post-process discipline data.
- exec_for_lin: bool
Whether the last execution was due to a linearization.
- input_grammar: BaseGrammar
The input grammar.
- jac: MutableMapping[str, MutableMapping[str, ndarray | csr_array | JacobianOperator]]
The Jacobians of the outputs wrt inputs.
The structure is
{output: {input: matrix}}
.
- name: str
The name of the discipline.
- output_grammar: BaseGrammar
The output grammar.
- re_exec_policy: ReExecutionPolicy
The policy to re-execute the same discipline.
- residual_variables: dict[str, str]
The output variables mapping to their inputs, to be considered as residuals; they shall be equal to zero.
- run_solves_residuals: bool
Whether the run method shall solve the residuals.
- gemseo.mda.initialization_chain.order_disciplines_from_default_inputs(disciplines, raise_error=True, available_data_names=())[source]
Order disciplines such that all their input values are defined.
It is particularly useful in the case of MDAs when not all default_inputs are available, and the execution order is not obvious to compute initial values for all couplings.
From the default inputs of the disciplines, use a greedy algorithm to detect sequentially the disciplines that can be executed, and records the execution order.
- Raises:
ValueError – When not all the disciplines can be initialized.
- Parameters:
disciplines (list[MDODiscipline]) – The disciplines to compute the initialization of.
raise_error (bool) –
Whether to raise an exception when the algorithm fails.
By default it is set to True.
available_data_names (Iterable[str]) –
The data names that are assumed to be available at runtime, in addition to the default_inputs.
By default it is set to ().
- Returns:
The ordered disciplines when the algorithm succeeds, or, if raise_error=False, the inputs that are missing.
- Return type:
list[MDODiscipline] | list[str]