gemseo.core.chains.additive_chain module#
Additive discipline chain.
- class MDOAdditiveChain(disciplines, outputs_to_sum, name='', use_threading=True, n_processes=None)[source]#
Bases:
MDOParallelChain
Execute disciplines in parallel and sum specified outputs across disciplines.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
disciplines (Sequence[Discipline]) -- The disciplines.
outputs_to_sum (Iterable[str]) -- The names of the outputs to sum.
name (str) --
The name of the discipline. If
None
, use the class name.By default it is set to "".
use_threading (bool) --
Whether to use threads instead of processes to parallelize the execution; multiprocessing will copy (serialize) all the disciplines, while threading will share all the memory. This is important to note if you want to execute the same discipline multiple times, you shall use multiprocessing.
By default it is set to True.
n_processes (int | None) -- The maximum simultaneous number of threads, if
use_threading
is True, or processes otherwise, used to parallelize the execution. IfNone
, uses the number of disciplines.
Notes
The actual number of processes could be lower than
n_processes
if there are less thann_processes
disciplines.n_processes
can be lower than the total number of CPUs on the machine. Each discipline may itself run on several CPUs.