Class NodeDistributionExpressions

  • All Implemented Interfaces:
    Map<NodeDistributionKey,​DistributionExpression>

    public final class NodeDistributionExpressions
    extends AbstractMap<NodeDistributionKey,​DistributionExpression>
    Represents any distribution expressions assigned to a Node. Temporal nodes and noisy nodes may require more than one distribution to be fully specified. In a Dynamic Bayesian Network (DBN) a node may require more than one distribution to be specified. This occurs when a temporal node has incoming links of order greater than zero. I.e. Has links from past time slices. For example, if a temporal node has an incoming link of order 1, then it will require a distribution at time t=0, and an additional distribution at t=1. This is because at time t=0 there is no previous time slice, but at time t=1 there is. For times greater than 1, in this example the distribution specified at time t=1 is still valid. However, if a new incoming link of order 12 was added, then an additional distribution would need to be specified at time t=12, valid for times t>=12.
    • Method Detail

      • validateExpression

        public void validateExpression​(DistributionExpression expression,
                                       NodeDistributionKey key,
                                       NodeDistributionKind kind)
        Determines whether an expression is valid for the given key and kind, without having to assign it to a node.
        Parameters:
        expression - The expression to test.
        key - The key which identifies the distribution to test, given that some nodes require multiple distributions.
        kind - The kind of distribution to test, such as probability, experience, etc...
      • findForTimeWithOrder

        public NodeDistributionExpressions.DistributionExpressionOrder findForTimeWithOrder​(int time)
        Finds the temporal distribution expression that is suitable for the time specified.
        Parameters:
        time - The time.
        Returns:
        The distribution expression and order that is appropriate for the given time. Can return a null expression, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate expression could not be found.
      • findForTime

        public DistributionExpression findForTime​(int time,
                                                  NodeDistributionKind kind)
        Finds the temporal distribution that is suitable for the time specified.
        Parameters:
        time - The time.
        kind - The kind of distribution to retrieve.
        Returns:
        The distribution and order that is appropriate for the given time. Can return a null distribution, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution could not be found.
      • findForTime

        public DistributionExpression findForTime​(int time)
        Finds the temporal distribution expression that is suitable for the time specified.
        Parameters:
        time - The time.
        Returns:
        The expression that is appropriate for the given time. Can return a null Expression, if the appropriate Expression has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate Expression could not be found.
      • findForTimeWithOrder

        public NodeDistributionExpressions.DistributionExpressionOrder findForTimeWithOrder​(int time,
                                                                                            NodeDistributionKind kind)
        Finds the temporal distribution expression that is suitable for the time specified.
        Parameters:
        time - The time.
        kind - The kind of distribution expressionto retrieve.
        Returns:
        The distribution expression that is appropriate for the given time. Can return a null expression, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution expression could not be found.
      • getNode

        public Node getNode()
        Gets the node that this instance belongs to.
      • getMaxTemporalOrder

        public int getMaxTemporalOrder()
        Gets the current maximum temporal order.
      • get

        public DistributionExpression get​(int temporalOrder)
        Gets a distribution expression at a particular temporal order.
        Parameters:
        temporalOrder - The required temporal order.
        Returns:
        The requested expression, which can be null if the node does not support the requested temporal order, or if a distribution expression has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - [temporalOrder] must be non negative.
      • set

        public void set​(int temporalOrder,
                        DistributionExpression value)
        Sets a distribution expression at a particular temporal order.
        Parameters:
        temporalOrder - The required temporal order.
        Throws:
        IllegalArgumentException - [temporalOrder] must be non negative.
      • get

        public DistributionExpression get​(NodeDistributionKey key)
        Gets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        Returns:
        The requested distribution expression, which can be null if the node does not support the requested temporal order, or if a distribution has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • set

        public void set​(NodeDistributionKey key,
                        DistributionExpression value)
        Sets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • get

        public DistributionExpression get​(NodeDistributionKind kind)
        Gets a particular kind of distribution expression on the node.

        For temporal or noisy nodes, use the overload which accepts both a key and kind.

      • set

        public void set​(NodeDistributionKind kind,
                        DistributionExpression value)
        Sets a particular kind of distribution expression on the node.

        For temporal or noisy nodes, use the overload which accepts both a key and kind.

      • get

        public DistributionExpression get​(NodeDistributionKey key,
                                          NodeDistributionKind kind,
                                          ExpressionDistribution expressionDistribution)
        Gets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        kind - The kind of distribution expression we are getting or setting. This allows setting other distribution expression types than Probability, such as Experience
        expressionDistribution - Options that affect whether a distribution is generated or not.
        Returns:
        The requested distribution expression, which can be null if the node does not support the requested temporal order, or if a distribution expression has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • set

        public void set​(NodeDistributionKey key,
                        NodeDistributionKind kind,
                        ExpressionDistribution expressionDistribution,
                        DistributionExpression value)
        Sets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        kind - The kind of distribution expression we are getting or setting. This allows setting other distribution expression types than Probability, such as Experience
        expressionDistribution - Options that affect whether a distribution is generated or not.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • get

        public DistributionExpression get​(NodeDistributionKey key,
                                          NodeDistributionKind kind)
        Gets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        kind - The kind of distribution expression we are getting or setting. This allows setting other distribution expression types than Probability, such as Experience
        Returns:
        The requested distribution expression, which can be null if the node does not support the requested temporal order, or if a distribution expression has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • set

        public void set​(NodeDistributionKey key,
                        NodeDistributionKind kind,
                        DistributionExpression value)
        Sets a distribution expression with particular properties, such as temporal order.

        For noisy nodes, multiple distribution expressions can be set, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution expression, such as temporal order.
        kind - The kind of distribution expression we are getting or setting. This allows setting other distribution expression types than Probability, such as Experience
        Throws:
        IllegalArgumentException - Temporal order must be non negative.