Class NodeDistributionExpressions
- java.lang.Object
-
- java.util.AbstractMap<NodeDistributionKey,DistributionExpression>
-
- com.bayesserver.NodeDistributionExpressions
-
- All Implemented Interfaces:
Map<NodeDistributionKey,DistributionExpression>
public final class NodeDistributionExpressions extends AbstractMap<NodeDistributionKey,DistributionExpression>
Represents any distribution expressions assigned to aNode
. 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NodeDistributionExpressions.DistributionExpressionOrder
Identifies a distribution expression and its temporal order.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Map.Entry<NodeDistributionKey,DistributionExpression>>
entrySet()
DistributionExpression
findForTime(int time)
Finds the temporal distribution expression that is suitable for the time specified.DistributionExpression
findForTime(int time, NodeDistributionKind kind)
Finds the temporal distribution that is suitable for the time specified.NodeDistributionExpressions.DistributionExpressionOrder
findForTimeWithOrder(int time)
Finds the temporal distribution expression that is suitable for the time specified.NodeDistributionExpressions.DistributionExpressionOrder
findForTimeWithOrder(int time, NodeDistributionKind kind)
Finds the temporal distribution expression that is suitable for the time specified.DistributionExpression
get(int temporalOrder)
Gets a distribution expression at a particular temporal order.DistributionExpression
get(NodeDistributionKey key)
Gets a distribution expression with particular properties, such as temporal order.DistributionExpression
get(NodeDistributionKey key, NodeDistributionKind kind)
Gets a distribution expression with particular properties, such as temporal order.DistributionExpression
get(NodeDistributionKey key, NodeDistributionKind kind, ExpressionDistribution expressionDistribution)
Gets a distribution expression with particular properties, such as temporal order.DistributionExpression
get(NodeDistributionKind kind)
Gets a particular kind of distribution expression on the node.Collection<NodeDistributionKey>
getKeys()
Gets the collection of node distribution keys that require distributions.int
getMaxTemporalOrder()
Gets the current maximum temporal order.Node
getNode()
Gets the node that this instance belongs to.void
set(int temporalOrder, DistributionExpression value)
Sets a distribution expression at a particular temporal order.void
set(NodeDistributionKey key, DistributionExpression value)
Sets a distribution expression with particular properties, such as temporal order.void
set(NodeDistributionKey key, NodeDistributionKind kind, DistributionExpression value)
Sets a distribution expression with particular properties, such as temporal order.void
set(NodeDistributionKey key, NodeDistributionKind kind, ExpressionDistribution expressionDistribution, DistributionExpression value)
Sets a distribution expression with particular properties, such as temporal order.void
set(NodeDistributionKind kind, DistributionExpression value)
Sets a particular kind of distribution expression on the node.int
size()
Gets the number of distributions in the container.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.-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
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.
-
getKeys
public Collection<NodeDistributionKey> getKeys()
Gets the collection of node distribution keys that require distributions.
-
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 ExperienceexpressionDistribution
- 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 ExperienceexpressionDistribution
- 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.
-
size
public int size()
Gets the number of distributions in the container.- Specified by:
size
in interfaceMap<NodeDistributionKey,DistributionExpression>
- Overrides:
size
in classAbstractMap<NodeDistributionKey,DistributionExpression>
-
entrySet
public Set<Map.Entry<NodeDistributionKey,DistributionExpression>> entrySet()
- Specified by:
entrySet
in interfaceMap<NodeDistributionKey,DistributionExpression>
- Specified by:
entrySet
in classAbstractMap<NodeDistributionKey,DistributionExpression>
-
-