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_inc with the maximum inconsistency of every outer iteration, stop with the stopping reason). Built by build_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 Executor instance or a registered executor name ("inprocess", "process" or a plugin) that runs the subproblem solves; overrides the one implied by mode.

  • sweep – "gauss_seidel" or "jacobi"; overrides the one implied by mode.

  • max_workers – worker count for executors created from a name (default: number of subproblems).

  • observers – RunObserver objects 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() and DMDO.Session drive it.

It yields two kinds of items:

  • a list of SubproblemTask: solve them and send back the list of SubproblemResult (any order; solve_task() solves one task);

  • an IterationEnd when 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: object

One 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: object

The 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:

SubproblemResult

Executors#

class DMDO.InProcessExecutor(max_workers=None)#

Bases: object

Runs 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: object

Runs 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])

DMDO.create_executor(spec, max_workers=None)#

An executor from an instance (returned as is), a registered name, or a factory.

Parameters:
  • spec (Any)

  • max_workers (int | None)

Return type:

Executor