gemseo / utils

xdsmizer module

Generate XDSMjs input json file

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

Bases: object

Class to build the XDSM diagram of a scenario

Generates input json for XDSMjs javascript library https://github.com/OneraHub/XDSMjs

See : Martins, Joaquim RRA, and Andrew B. Lambe. “Multidisciplinary design optimization: a survey of architectures.” AIAA journal 51.9 (2013): 2049-2075.

Constructor

Parameters
  • scenario – the MDO scenario to be represented as a XDSM diagram

  • hashref – key used in the final XDSM json structure to reference {nodes, edges, workflow, optpb} data structure. Default to ‘root’

  • level – level number corresponding to scenario depth. Root scenario is level 0.

get_all_sub_xdsmizers()[source]

Retrieves all sub xdsmizers corresponding to sub Scenario objects

Returns

the array of XDSMizer objects

initialize(workflow=None)[source]

Initialize from a given workflow or use self.scenario’ one, create sub XDSM diagram accordingly.

Parameters

workflow – composite execution sequence

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

Monitors GEMSEO discipline execution by generating XDSM json file on discipline status update.

Parameters
  • outdir (str) – the directory where XDSM json file is generated

  • outfilename (str) – the file name of the generated XDSM json file (default: xdsm.json)

  • print_statuses (bool) – print the statuses in the console at each update (default: False)

  • latex_output (bool) – generate tikz, tex and pdf output (default: False)

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

Generates a XDSM diagram from the process. By default, a self contined HTML file is generated, that can be viewed in a browser.

Parameters
  • outdir – the directory where XDSM json file is generated. if None, current working dir is used. If open_browser is True and outdir is None, generates a temporary directory to store the file

  • outfilename – the file name of the generated XDSM json file (default: xdsm.json).

  • latex_output – produces .tex, .tikz and .tex files if True If outdir is not set the XDSM json is printed on the standard output.

  • open_browser – if True, opens the web browser with the XDSM

  • html_output – if True, outputs a self contained HTML file

  • json_output – if True, outputs a JSON file for XDSMjs

Returns

XDSM json either in a file when outdir is set, ouput on the console otherwise.

update(atom)[source]

Callback function that generate new XDSM regarding the given atom status update :param atom: discipline which status has been updated

xdsmize(algoname='Optimizer')[source]

Builds the Python data structure to be used to generate JSON format compatible with XDSMjs viewer.

Parameters

algoname – Default value = “Optimizer”)

Returns

the Python object containing relevant information for XDSM representation

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

Expands 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]}] :param wks: the workflow structure :param to_id: the mapping dict from object to id :returns: the ids structure valid to be used as XDSM json chains