mxfusion.components.model_component

Members

class mxfusion.components.model_component.ModelComponent

Bases: object

The building block of a Model in MXFusion.

ModelComponents exist in one of two modes.

Mode 1 - Bi-directional mode

If a node is not attached to a FactorGraph, it maintains a list of all of its predecessors and successors directly. These are stored in the self._predecessors and self._successors methods.

Mode 2 - Graph mode

If a node is attached to a FactorGraph, it does not store direct references to its successors and predecessors. When accessed, the predecessors/successors properties directly query the graph they are attached to to find out what the respective neighbor nodes are.

uuid

Return the UUID of this graph

graph

Return the object’s graph

successors

Return a list of nodes pointed to by the edges of this node.

predecessors

Return a list of nodes whose edges point into this node.

Parameters:predecessors (List of tuples of name to node e.g. [('random_variable': Variable y)]) – List of tuples of name to node e.g. [(‘random_variable’: Variable y)]
replicate(var_map=None, replication_function=None)

Replicates this component and its neighbors based on the replication_function logic passed in.

Parameters:
  • var_map ({original_node: new_node}) – A mapping from the original model’s components to the replicated components. This is used to track which components have already been replicated in a dynamic programming style.
  • replication_function (function) – A function that takes in a ModelComponent and returns an answer for how to replicate that node’s predecessors and successors.