Coordination loop and execution#
MDO#
- class DMDO.MDO#
The multidisciplinary design optimization process: the coordinator, the subproblems, the variable copies and the records of a run (
fmin,hmin,tab_incwith the maximum inconsistency of every outer iteration,stopwith the stopping reason). Built bybuild_mdo()or directly with the Python API (The Sellar problem).- MDO.run(file=None, resume=False, mode='Serial', executor=None, sweep=None, max_workers=None, observers=None)#
Run the coordination loop to the end.
- Parameters:
mode –
"serial"(default sweep Gauss-Seidel, in-process) or"parallel"(default sweep Jacobi, process pool with one worker per subproblem).executor – an
Executorinstance or a registered executor name ("inprocess","process"or a plugin) that runs the subproblem solves; overrides the one implied bymode.sweep –
"gauss_seidel"or"jacobi"; overrides the one implied bymode.max_workers – worker count for executors created from a name (default: number of subproblems).
observers –
RunObserverobjects notified during the run, after DMDO’s own observers.
To drive the loop step by step, or to solve the subproblems yourself (ask/tell), use
DMDO.Session.
- MDO.coordinate(file=None, resume=False, mode='Serial', sweep=None, observers=None, should_stop=None)#
The coordination loop as a generator;
run()andDMDO.Sessiondrive it.It yields two kinds of items:
a list of
SubproblemTask: solve them andsendback the list ofSubproblemResult(any order;solve_task()solves one task);an
IterationEndwhen an outer iteration is complete (send(None)to continue).
- Parameters:
should_stop – called after each outer iteration; returning True ends the run there.
Tasks#
- class DMDO.SubproblemTask(index, subproblem, v, w, iteration, file=None)#
Bases:
objectOne subproblem solve:
subproblem.solve(v, w, file=file, iter=iteration).- Parameters:
index (int)
subproblem (Any)
v (Any)
w (Any)
iteration (int)
file (str | None)
- class DMDO.SubproblemResult(index, subproblem, output)#
Bases:
objectThe solved subproblem (its state and its coordinator copy after the solve) and the solver’s raw output.
- Parameters:
index (int)
subproblem (Any)
output (Any)
- DMDO.solve_task(task)#
Solve one subproblem task. Module-level so executors can ship it to other processes or machines.
- Parameters:
task (SubproblemTask)
- Return type:
Executors#
- class DMDO.InProcessExecutor(max_workers=None)#
Bases:
objectRuns tasks one after another in the calling process (no copies: tasks are solved in place).
- Parameters:
max_workers (Optional[int])
- class DMDO.ProcessExecutor(max_workers=None)#
Bases:
objectRuns tasks in a pool of worker processes; the pool is created lazily and reused across outer iterations.
Tasks and results are pickled, so blackboxes must be importable (module-level) callables. On Windows/macOS the calling script needs the usual
if __name__ == "__main__":guard.- Parameters:
max_workers (Optional[int])