BMI wrapper for PySB-assembled models (indra.assemblers.pysb.bmi_wrapper
)
This module allows creating a Basic Modeling Interface (BMI) model from and automatically assembled PySB model. The BMI model can be instantiated within a simulation workflow system where it is simulated together with other models.
- class indra.assemblers.pysb.bmi_wrapper.BMIModel(model, inputs=None, stop_time=1000, outside_name_map=None)[source]
This class represents a BMI model wrapping a model assembled by INDRA.
- Parameters
model (pysb.Model) – A PySB model assembled by INDRA to be wrapped in BMI.
inputs (Optional[list[str]]) – A list of variable names that are considered to be inputs to the model meaning that they are read from other models. Note that designating a variable as input means that it must be provided by another component during the simulation.
stop_time (int) – The stopping time for this model, controlling the time units up to which the model is simulated.
outside_name_map (dict) – A dictionary mapping outside variables names to inside variable names (i.e. ones that are in the wrapped model)
- export_into_python()[source]
Write the model into a pickle and create a module that loads it.
The model basically exports itself as a pickle file and a Python file is then written which loads the pickle file. This allows importing the model in the simulation workflow.
- get_attribute(att_name)[source]
Return the value of a given attribute.
Atrributes include: model_name, version, author_name, grid_type, time_step_type, step_method, time_units
- get_current_time()[source]
Return the current time point that the model is at during simulation
- Returns
time – The current time point
- Return type
- get_start_time()[source]
Return the initial time point of the model.
- Returns
start_time – The initial time point of the model.
- Return type
- get_time_step()[source]
Return the time step associated with model simulation.
- Returns
dt – The time step for model simulation
- Return type
- get_time_units()[source]
Return the time units of the model simulation.
- Returns
units – The time unit of simulation as a string
- Return type
- initialize(cfg_file=None, mode=None)[source]
Initialize the model for simulation, possibly given a config file.
- Parameters
cfg_file (Optional[str]) – The name of the configuration file to load, optional.
- make_repository_component()[source]
Return an XML string representing this BMI in a workflow.
This description is required by EMELI to discover and load models.
- Returns
xml – String serialized XML representation of the component in the model repository.
- Return type