Modeling

ASKEM AMR Petri net generation(mira.modeling.askenet.petrinet)

This module implements generation into Petri net models which are defined at https://github.com/DARPA-ASKEM/Model-Representations/tree/main/petrinet.

class AskeNetPetriNetModel(model)[source]

Bases: object

A class representing a PetriNet model.

Instantiate a petri net model from a generic transition model.

Parameters:

model (Model) – The pre-compiled transition model

to_json(name=None, description=None, model_version=None)[source]

Return a JSON dict structure of the Petri net model.

to_json_str(**kwargs)[source]

Return a JSON string representation of the Petri net model.

to_json_file(fname, name=None, description=None, model_version=None, **kwargs)[source]

Write the Petri net model to a JSON file

Parameters:
  • fname (str) – The file name to write to.

  • name (str, optional) – The name of the model.

  • description (str, optional) – A description of the model.

  • model_version (str, optional) – The version of the model.

  • kwargs – Additional keyword arguments to pass to json.dump().

ASKEM AMR Regulatory net generation (mira.modeling.askenet.regnet)

This module implements generation into Petri net models which are defined at https://github.com/DARPA-ASKEM/Model-Representations/tree/main/petrinet.

class AskeNetRegNetModel(model)[source]

Bases: object

A class representing a PetriNet model.

Instantiate a petri net model from a generic transition model.

Parameters:

model (Model) – The pre-compiled transition model

to_json(name=None, description=None, model_version=None)[source]

Return a JSON dict structure of the Petri net model.

to_json_str(**kwargs)[source]

Return a JSON string representation of the Petri net model.

to_json_file(fname, name=None, description=None, model_version=None, **kwargs)[source]

Write the Petri net model to a JSON file.

Model visualization (mira.modeling.viz)

Visualization of transition models.

class GraphicalModel(model)[source]

Bases: object

Create a graphical representation of a transition model.

classmethod from_template_model(template_model)[source]

Get a graphical model from a template model.

Return type:

GraphicalModel

write(path, prog='dot', args='', format=None)[source]

Write the graphical representation to a file.

Parameters:
  • path (Union[str, Path]) – The path to the output file

  • prog (str) – The graphviz layout program to use, such as “dot”, “neato”, etc.

  • format (Optional[str]) – Set the file format explicitly

  • args (str) – Additional arguments to pass to the graphviz bash program

Return type:

None

classmethod for_jupyter(template_model, name='model.png', **kwargs)[source]

Display in jupyter.

ODE model generation and simulation (mira.modeling.ode)

class OdeModel(model)[source]

Bases: object

A class representing an ODE model.

set_parameters(params)[source]

Set the parameters of the model.

get_rhs()[source]

Return the right-hand side of the ODE system.

simulate_ode_model(ode_model, initials, parameters, times)[source]

Simulate an ODE model given initial conditions, parameters and a time span.

Parameters:
  • ode_model (OdeModel) – An ODE model constructed from metamodel templates

  • initials – A one-dimensional array describing the initial values for the agents in the ODE model

  • parameters – A dictionary of keys for parameters to their values

  • times – A one-dimensional array of time values, typically from a linear space like numpy.linspace(0, 25, 100)

Returns:

  • A two-dimensional array with the first axis being time

  • and the second axis being the agents in the ODE model.

ACSets Petri net model generation (mira.modeling.petri)

This module implements generation into Petri net models which are defined through a set of states, transitions, and the input and output connections between them.

Once the model is created, it can be exported into JSON following the conventions in https://github.com/AlgebraicJulia/ASKEM-demos/tree/master/data.

class PetriNetModel(model)[source]

Bases: object

A class representing a PetriNet model.

Instantiate a petri net model from a generic transition model.

Parameters:

model (Model) – The pre-compiled transition model

to_json()[source]

Return a JSON dict structure of the Petri net model.

to_json_str()[source]

Return a JSON string representation of the Petri net model.

to_json_file(fname, **kwargs)[source]

Write the Petri net model to a JSON file.

Bilayer model generation (mira.modeling.bilayer)

This module can generate a bilayer structure from a MIRA transition model.

class BilayerModel(model)[source]

Bases: object

Class to generate a bilayer model from a transition model.

static make_bilayer(model)[source]

Generate a bilayer structure and return as a JSON dict.

save_bilayer(fname)[source]

Save the generated bilayer into a JSON file.