gemseo / utils

Show inherited members

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[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(directory_path='.', file_name='xdsm', log_workflow_status=False, save_pdf=False)[source]

Generate XDSM json file on discipline status update.

Parameters:
  • directory_path (str | Path) –

    The path of the directory to save the files.

    By default it is set to “.”.

  • file_name (str) –

    The file name to be suffixed by a file extension.

    By default it is set to “xdsm”.

  • log_workflow_status (bool) –

    Whether to log the evolution of the workflow’s status.

    By default it is set to False.

  • save_pdf (bool) –

    Whether to save the XDSM as a PDF file.

    By default it is set to False.

Return type:

None

run(directory_path='.', file_name='xdsm', show_html=False, save_html=True, save_json=False, save_pdf=False, pdf_build=True, pdf_cleanup=True, pdf_batchmode=True)[source]

Generate a XDSM diagram of the scenario.

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

Parameters:
  • directory_path (str | Path) –

    The path of the directory to save the files.

    By default it is set to “.”.

  • file_name (str) –

    The file name to be suffixed by a file extension.

    By default it is set to “xdsm”.

  • show_html (bool) –

    Whether to open the web browser and display the XDSM.

    By default it is set to False.

  • save_html (bool) –

    Whether to save the XDSM as a HTML file.

    By default it is set to True.

  • save_json (bool) –

    Whether to save the XDSM as a JSON file.

    By default it is set to False.

  • save_pdf (bool) –

    Whether to save the XDSM as a PDF file.

    By default it is set to False.

  • pdf_build (bool) –

    Whether the standalone pdf of the XDSM will be built.

    By default it is set to True.

  • pdf_cleanup (bool) –

    Whether pdflatex built files will be cleaned up after build is complete.

    By default it is set to True.

  • pdf_batchmode (bool) –

    Whether pdflatex is run in batchmode.

    By default it is set to True.

Returns:

A XDSM diagram.

Return type:

XDSM

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:

IdsType