jacobi module¶
A Jacobi algorithm for solving MDAs.
- class gemseo.mda.jacobi.MDAJacobi(disciplines, max_mda_iter=10, name=None, n_processes=2, acceleration='', tolerance=1e-06, linear_solver_tolerance=1e-12, use_threading=True, warm_start=False, use_lu_fact=False, grammar_type=GrammarType.JSON, coupling_structure=None, log_convergence=False, linear_solver='DEFAULT', linear_solver_options=None, acceleration_method=AccelerationMethod.ALTERNATE_2_DELTA, over_relaxation_factor=1.0)[source]
Bases:
BaseMDASolver
Perform an MDA using the Jacobi algorithm.
This algorithm is a fixed point iteration method to solve systems of non-linear equations of the form,
\[\begin{split}\left\{ \begin{matrix} F_1(x_1, x_2, \dots, x_n) = 0 \\ F_2(x_1, x_2, \dots, x_n) = 0 \\ \vdots \\ F_n(x_1, x_2, \dots, x_n) = 0 \end{matrix} \right.\end{split}\]Beginning with \(x_1^{(0)}, \dots, x_n^{(0)}\), the iterates are obtained as the solution of the following \(n\) independent non-linear equations:
\[\begin{split}\left\{ \begin{matrix} r_1\left( x_1^{(i+1)} \right) = F_1(x_1^{(i+1)}, x_2^{(i)}, \dots, x_n^{(i)}) = 0 \\ r_2\left( x_2^{(i+1)} \right) = F_2(x_1^{(i)}, x_2^{(i+1)}, \dots, x_n^{(i)}) = 0 \\ \vdots \\ r_n\left( x_n^{(i+1)} \right) = F_n(x_1^{(i)}, x_2^{(i)}, \dots, x_n^{(i+1)}) = 0 \end{matrix} \right.\end{split}\]Initialize self. See help(type(self)) for accurate signature.
- Parameters:
disciplines (Sequence[MDODiscipline]) – The disciplines from which to compute the MDA.
max_mda_iter (int) –
The maximum iterations number for the MDA algorithm.
By default it is set to 10.
name (str | None) – The name to be given to the MDA. If
None
, use the name of the class.n_processes (int) –
The maximum simultaneous number of threads if
use_threading
is set to True, otherwise processes, used to parallelize the execution.By default it is set to 2.
acceleration (str) –
Deprecated, please consider using the
MDA.acceleration_method
instead. The type of acceleration to be used to extrapolate the residuals and save CPU time by reusing the information from the last iterations, eitherNone
,"m2d"
, or"secant"
,"m2d"
is faster but uses the 2 last iterations.By default it is set to “”.
tolerance (float) –
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.
By default it is set to 1e-06.
linear_solver_tolerance (float) –
The tolerance of the linear solver in the adjoint equation.
By default it is set to 1e-12.
use_threading (bool) –
Whether to use threads instead of processes to parallelize the execution. Processes will copy (serialize) all the disciplines, while threads will share all the memory. If one wants to execute the same discipline multiple times then multiprocessing should be prefered.
By default it is set to True.
warm_start (bool) –
Whether the second iteration and ongoing start from the previous coupling solution.
By default it is set to False.
use_lu_fact (bool) –
Whether to store a LU factorization of the matrix when using adjoint/forward differentiation. to solve faster multiple RHS problem.
By default it is set to False.
grammar_type (MDODiscipline.GrammarType) –
The type of the input and output grammars.
By default it is set to “JSONGrammar”.
coupling_structure (MDOCouplingStructure | None) – The coupling structure to be used by the MDA. If
None
, it is created from disciplines.log_convergence (bool) –
Whether to log the MDA convergence, expressed in terms of normed residuals.
By default it is set to False.
linear_solver (str) –
The name of the linear solver.
By default it is set to “DEFAULT”.
linear_solver_options (Mapping[str, Any] | None) – The options passed to the linear solver factory.
acceleration_method (AccelerationMethod) –
The acceleration method to be used to improve the convergence rate of the fixed point iteration method.
By default it is set to “Alternate2Delta”.
over_relaxation_factor (float) –
The over-relaxation factor.
By default it is set to 1.0.
- execute_all_disciplines(input_local_data)[source]
Execute all the disciplines, possibly in parallel.
- Parameters:
input_local_data (Mapping[str, NDArray]) – The input data of the disciplines.
- Return type:
None
- get_expected_workflow()[source]
Return the expected execution sequence.
This method is used for the XDSM representation.
The default expected execution sequence is the execution of the discipline itself.
See also
MDOFormulation.get_expected_workflow
- Returns:
The expected execution sequence.
- Return type:
- M2D_ACCELERATION: ClassVar[str] = 'm2d'
- SECANT_ACCELERATION: ClassVar[str] = 'secant'
- property acceleration: AccelerationMethod
The acceleration method.
- assembly: JacobianAssembly
- cache: AbstractCache | None
The cache containing one or several executions of the discipline according to the cache policy.
- coupling_structure: MDOCouplingStructure
The coupling structure to be used by the MDA.
- 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}}
.
- lin_cache_tol_fact: float
The tolerance factor to cache the Jacobian.
- linear_solver: str
The name of the linear solver.
- linear_solver_options: Mapping[str, Any]
The options of the linear solver.
- linear_solver_tolerance: float
The tolerance of the linear solver in the adjoint equation.
- matrix_type: JacobianAssembly.JacobianType
The type of the matrix.
- name: str
The name of the discipline.
- normed_residual: float
The normed residual.
- output_grammar: BaseGrammar
The output grammar.
- re_exec_policy: ReExecutionPolicy
The policy to re-execute the same discipline.
- reset_history_each_run: bool
Whether to reset the history of MDA residuals before each run.
- 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.
- scaling: ResidualScaling
The scaling method applied to MDA residuals for convergence monitoring.
- tolerance: float
The tolerance of the iterative direct coupling solver.
- use_lu_fact: bool
Whether to store a LU factorization of the matrix.
- warm_start: bool
Whether the second iteration and ongoing start from the previous solution.