Sessions and problem building#
from DMDO import Session, RunResult, load_setup, build_mdo, main
Session#
- class DMDO.Session(mdo, *, mode='serial', sweep=None, executor=None, max_workers=None, observers=(), resume=False, file=None)#
Bases:
objectBuild and drive one DMDO coordination run.
- Parameters:
mdo (MDO) – the problem (built with
from_yaml(),from_dict(),from_checkpoint()or by hand).mode (str) –
"serial"(Gauss-Seidel, in-process) or"parallel"(Jacobi, process pool) defaults.sweep (str | None) –
"gauss_seidel"or"jacobi", overridingmode.executor (Any) – executor used by
run()andstep()(anExecutoror a registered name); not used by ask/tell.max_workers (int | None) – worker count for executors created from a name.
observers (Iterable[Any]) – extra
RunObserverobjects.resume (bool) – continue a checkpointed run (see
from_checkpoint()).file (str | None)
- classmethod from_dict(data, *, working_dir='.', mdo_name='MDO', blackboxes=None, **options)#
Build from a problem definition dictionary (the content of a DMDO YAML file).
blackboxesmaps theblackbox:/opt:names of the definition to callables orDisciplineobjects (names can also come fromDMDO.register_blackbox()or be"module:attr"import paths). Outputs go to<working_dir>/<mdo_name>_post.- Parameters:
data (Mapping[str, Any])
working_dir (str)
mdo_name (str)
blackboxes (Mapping[str, Any] | None)
- Return type:
- classmethod from_yaml(setup_file, *, working_dir='.', mdo_name=None, blackboxes=None, **options)#
Build from a DMDO YAML (or JSON) problem file;
mdo_namedefaults to the file name.- Parameters:
setup_file (str)
working_dir (str)
mdo_name (str | None)
blackboxes (Mapping[str, Any] | None)
- Return type:
- classmethod from_checkpoint(checkpoint_file, **options)#
Resume from a
coord_chk.pklcheckpoint written by a previous run.- Parameters:
checkpoint_file (str)
- Return type:
- property iteration: int#
Number of completed outer iterations (including those before a resumed checkpoint).
- request_stop()#
End the run after the current outer iteration (thread-safe).
- Return type:
None
- ask()#
The subproblem tasks to solve next ([] once the run is over).
Tasks of one batch are independent (Jacobi: every subproblem; Gauss-Seidel: one subproblem at a time). Calling
askagain beforetellreturns the same batch.- Return type:
List[SubproblemTask]
- tell(results)#
Hand back the results of the last
ask()batch (any order).Returns the
IterationRecordwhen these results completed an outer iteration, else None.- Parameters:
results (Sequence[SubproblemResult])
- Return type:
IterationRecord | None
- step()#
Run one outer iteration with the session’s executor; None when the run is already over.
- Return type:
IterationRecord | None
- run()#
Run (or continue) to the end of the coordination and return the result.
- Return type:
- close()#
Stop the run (if still going) and release the executor.
- Return type:
None
- class DMDO.RunResult(status, stop_reason, iterations, objective, max_inconsistency, feasible, variables, history=<factory>, post_dir=None)#
Bases:
objectOutcome of a session: final design, objective, consistency and the per-iteration history.
- Parameters:
status (str)
stop_reason (str)
iterations (int)
objective (Any)
max_inconsistency (float)
feasible (bool)
variables (Dict[str, Any])
history (List[IterationRecord])
post_dir (str | None)
- exception DMDO.SessionError#
Bases:
RuntimeErrorA session method was called in a state that does not allow it.
Building problems#
- DMDO.load_setup(setup_file, log=None)#
Read a DMDO problem definition (
.yaml/.yml/.json) into a dictionary.- Parameters:
setup_file (str)
log (logger)
- Return type:
Dict[str, Any]
- DMDO.build_mdo(data, working_dir='.', mdo_name='MDO', blackboxes=None, log=None, post_dir=None)#
Build an
MDOfrom a problem definition dictionary (the content of a DMDO YAML file).Outputs go to
<working_dir>/<mdo_name>_postunlesspost_diris given. The problem definition is not modified.- Parameters:
data (Dict[str, Any])
working_dir (str)
mdo_name (str)
blackboxes (Dict)
log (logger)
post_dir (str)
- Return type:
MDO
- DMDO.main(options)#
Build and run a problem from a YAML file, as in earlier releases.
optionsis a dictionary with the keyssetup_file,mdo_name,working_dir, and optionallyrun_mode("run"or"build"),exec_mode("serial"or"parallel"),is_resumewithrestart_file(resume from a checkpoint), andblackboxes(name -> callable or discipline). Returns theMDOobject.mdo = main({"setup_file": "problem.yaml", "mdo_name": "wing", "working_dir": "runs", "blackboxes": {"A1": aero, "A2": structures}})