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.

Classes:

XDSMizer(scenario[, hashref, level, ...])

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

Functions:

expand(wks, to_id)

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

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 (Optional[CompositeExecSequence]) –

    The expected workflow, describing the sequence of execution of the different disciplines (MDODiscipline, Scenario, MDA, etc.)

    By default it is set to None.

Return type

None

Methods:

get_all_sub_xdsmizers()

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

initialize([workflow])

Initialize the XDSM from a workflow.

monitor([outdir, outfilename, ...])

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

run([output_directory_path, latex_output, ...])

Generate a XDSM diagram from the process.

update(atom)

Generate a new XDSM regarding the atom status update.

xdsmize([algoname])

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

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 (Optional[gemseo.core.execution_sequence.CompositeExecSequence]) –

The composite execution sequence. If None, use the scenario’s one.

By default it is set to None.

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 (Optional[str]) –

    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 (Optional[str]) –

    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.

    By default it is set to None.

  • 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

Dict[str, Any]

update(atom)[source]

Generate a new XDSM regarding the atom status update.

Parameters

atom (gemseo.core.execution_sequence.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