gemseo / utils

xdsmizer module

Creation of a XDSM diagram from a scenario.

The XDSMizer generates a JSON file.

The latter is used by the XDSMjs javascript library to produce an interactive web XDSM and by the pyxdsm python library to produce TIKZ and PDF versions of the XDSM.

For more information, see: A. B. Lambe and J. R. R. A. Martins, “Extensions to the Design Structure Matrix for the Description of Multidisciplinary Design, Analysis, and Optimization Processes”, Structural and Multidisciplinary Optimization, vol. 46, no. 2, p. 273-284, 2012.

class gemseo.utils.xdsmizer.XDSMizer(scenario, hashref='root', level=0, expected_workflow=None)[source]

Bases: object

Build the XDSM diagram of a scenario as a JSON structure.

Parameters:
  • scenario (Scenario) – The scenario to be represented as an XDSM diagram.

  • hashref (str) –

    The keyword used in the JSON structure to reference the dictionary data structure whose keys are “nodes”, “edges”, “workflow” and “optpb”.

    By default it is set to “root”.

  • level (int) –

    The depth of the scenario. Root scenario is level 0.

    By default it is set to 0.

  • expected_workflow (CompositeExecSequence | None) – The expected workflow, describing the sequence of execution of the different disciplines (MDODiscipline, Scenario, MDA, etc.)

get_all_sub_xdsmizers()[source]

Retrieve all the sub-xdsmizers corresponding to the sub-scenarios.

Returns:

The sub-xdsmizers.

Return type:

list[gemseo.utils.xdsmizer.XDSMizer]

initialize(workflow=None)[source]

Initialize the XDSM from a workflow.

The initialization also creates sub-XDSM diagram accordingly.

Parameters:

workflow (CompositeExecSequence | None) – The composite execution sequence. If None, use the scenario’s one.

Return type:

None

monitor(outdir='.', outfilename='xdsm.json', print_statuses=False, latex_output=False)[source]

Monitor the discipline execution by generating XDSM json file on discipline status update.

Parameters:
  • outdir (str | None) –

    The name of the directory to store the different files. If None, the current working directory is used.

    By default it is set to “.”.

  • outfilename (str) –

    The name of the JSON file.

    By default it is set to “xdsm.json”.

  • print_statuses (bool) –

    If True, print the statuses in the console at each update.

    By default it is set to False.

  • latex_output (bool) –

    If True, save the XDSM to tikz, tex and pdf files.

    By default it is set to False.

Return type:

None

run(output_directory_path=None, latex_output=False, outfilename='xdsm.html', html_output=True, json_output=False, open_browser=False)[source]

Generate a XDSM diagram from the process.

By default, a self contained HTML file is generated, that can be viewed in a browser.

Parameters:
  • output_directory_path (str | None) – The name of the directory to store the JSON file. If None, the current working directory is used. If open_browser is True and outdir is None, the file is stored in a temporary directory.

  • outfilename (str) –

    The name of the JSON file.

    By default it is set to “xdsm.html”.

  • latex_output (bool) –

    If True, save the XDSM to tikz, tex and pdf files.

    By default it is set to False.

  • open_browser (bool) –

    If True, open the web browser and display the XDSM.

    By default it is set to False.

  • html_output (bool) –

    If True, save the XDSM in a self-contained HTML file

    By default it is set to True.

  • json_output (bool) –

    If True, save the JSON file.

    By default it is set to False.

Returns:

The XDSM structure expressed as a dictionary whose keys are “nodes”, “edges”, “workflow” and “optpb”.

Return type:

XdsmType

update(atom)[source]

Generate a new XDSM regarding the atom status update.

Parameters:

atom (AtomicExecSequence) – The discipline which status is monitored.

Return type:

None

xdsmize(algoname='Optimizer')[source]

Build the data structure to be used to generate the JSON file.

Parameters:

algoname (str) –

The name under which a scenario appears in an XDSM.

By default it is set to “Optimizer”.

Returns:

The XDSM structure expressed as a dictionary whose keys are “nodes”, “edges”, “workflow” and “optpb”.

Return type:

dict[str, Any]

gemseo.utils.xdsmizer.expand(wks, to_id)[source]

Expand the workflow structure as an ids structure using to_id mapping.

The expansion preserve the structure while replacing the object by its id in all case except when a tuple is encountered as cdr then the expansion transforms loop[A, (B,C)] in [idA, {‘parallel’: [idB, idC]}].

Parameters:
Returns:

The ids structure valid to be used as XDSM json chains.

Return type:

Any