public final class Node extends Object implements Cloneable
To specify a distribution for a node, see the getDistribution()
property.
To add a directed link between two nodes, it must be added through the Network.Links
property.
Constructor and Description |
---|
Node()
Initializes a new instance of the
Node class, with no variables, and no name. |
Node(String name,
int states)
|
Node(String name,
List<Variable> variables)
Initializes a new instance of the
Node class with a specified name and a number of variables. |
Node(String name,
State... states)
|
Node(String name,
String[] states)
|
Node(String name,
Variable... variables)
Initializes a new instance of the
Node class with a specified name and a number of variables. |
Node(String name,
VariableValueType valueType)
Initializes a new instance of the
Node class with the specified [name]. |
Node(String name,
VariableValueType valueType,
VariableKind kind)
Initializes a new instance of the
Node class with the specified [name]. |
Node(Variable variable)
|
Modifier and Type | Method and Description |
---|---|
Node |
copy()
Makes a copy of this instance.
|
Bounds |
getBounds()
Gets the size and location of the node.
|
CausalObservability |
getCausalObservability()
The
CausalObservability of the node. |
CustomPropertyCollection |
getCustomProperties()
Gets custom properties associated with this instance.
|
String |
getDescription()
An optional description for the node.
|
Distribution |
getDistribution()
Returns the distribution currently associated with the
Node . |
NodeDistributionOptions |
getDistributionOptions()
Options that apply to all distributions of this instance.
|
NodeDistributions |
getDistributions()
Returns the distributions associated with this instance with NodeDistributionKind = Probability.
|
NodeGroupCollection |
getGroups()
Gets the groups this node belongs to.
|
int |
getIndex()
The Index of this instance in the collection of nodes belonging to a network, or -1 if the node does not belong to a network.
|
NodeLinkCollection |
getLinks()
Collection of both incoming and outgoing links (parent and child nodes).
|
NodeLinkCollection |
getLinksIn()
Collection of incoming links (linking to parent nodes).
|
NodeLinkCollection |
getLinksOut()
Collection of outgoing links (linking to child nodes).
|
String |
getName()
The name of the node.
|
Network |
getNetwork()
The
Network the node belongs to. |
TemporalType |
getTemporalType()
The
TemporalType of the node. |
NodeVariableCollection |
getVariables()
Collection of variables represented by the node.
|
Distribution |
newDistribution()
Creates a new distribution suitable for the node, however does not assign it to the node's
getDistribution() property. |
Distribution |
newDistribution(int temporalOrder)
Creates a new distribution suitable for the requested temporal order, however it is not assigned to the node.
|
Distribution |
newDistribution(NodeDistributionKey key)
Creates a new distribution suitable for the requested temporal order/related node, however it is not assigned to the node.
|
Distribution |
newDistribution(NodeDistributionKey key,
NodeDistributionKind kind)
Creates a new distribution suitable for the requested temporal order/related node, however it is not assigned to the node.
|
Distribution |
newDistribution(NodeDistributionKey key,
NodeDistributionKind kind,
DistributionExpression expression)
Creates a new distribution from an expression suitable for the requested temporal order/related node, however it is not assigned to the node, and neither is the expression.
|
Distribution |
newDistribution(NodeDistributionKind kind)
Creates a new distribution with the given kind, however it is not assigned to the node.
|
void |
setBounds(Bounds value)
Sets the size and location of the node.
|
void |
setCausalObservability(CausalObservability value)
The
CausalObservability of the node. |
void |
setDescription(String value)
An optional description for the node.
|
void |
setDistribution(Distribution value)
Returns the distribution currently associated with the
Node . |
void |
setName(String value)
The name of the node.
|
void |
setTemporalType(TemporalType value)
The
TemporalType of the node. |
String |
toString()
Returns the name of the node, or an empty string if the name is null.
|
public Node()
Node
class, with no variables, and no name.public Node(Variable variable)
Node
class with a specified Variable
and assigns the name of the variable to the node.variable
- A single variable for the node.public Node(String name, VariableValueType valueType, VariableKind kind)
Node
class with the specified [name]. A Variable
is automatically created for the node and assigned the same name as the node with the VariableValueType
specified.name
- The name to give the node and variable, which can be null or empty.valueType
- The VariableValueType
of the node variable, e.g. discrete or continuous.kind
- The kind of variable, e.g. Probability (standard), Decision or Utility.public Node(String name, VariableValueType valueType)
Node
class with the specified [name]. A Variable
is automatically created for the node and assigned the same name as the node with the VariableValueType
specified.name
- The name to give the node and variable, which can be null or empty.valueType
- The VariableValueType
of the node variable, e.g. discrete or continuous.public Node(String name, int states)
Node
class with the specified [name] and automatically adds a discrete Variable
with the number of states specified in [states].name
- The name to give the node and variable, which can be null or empty.states
- The number of states to add to the automatically created Variable
. States will be given default names.IllegalArgumentException
- Raised when the [states] parameter is less than zero.public Node(String name, String[] states)
Node
class, with the name of the node, automatically creating an associated discrete Variable
and adds the states specified in [states] to that variable.name
- The name of the node and variable.states
- The states to add to the associated Variable
, specified by their names.NullPointerException
- Raised when [states] is null.public Node(String name, State... states)
Node
class, with the name of the node, automatically creating an associated discrete Variable
and adds the states specified in [states] to that variable.name
- The name of the node and variable.states
- The states to add to the associated Variable
.NullPointerException
- Raised when [states] is null.public Node(String name, Variable... variables)
Node
class with a specified name and a number of variables.name
- The name for the node.variables
- The variable(s) represented by the node.public Node copy()
public CustomPropertyCollection getCustomProperties()
public NodeGroupCollection getGroups()
public TemporalType getTemporalType()
TemporalType
of the node. The default value is TemporalType.CONTEMPORAL
.IllegalStateException
- Raised if the node belongs to a network, in which case the TemporalType cannot be changed.
spublic void setTemporalType(TemporalType value)
TemporalType
of the node. The default value is TemporalType.CONTEMPORAL
.IllegalStateException
- Raised if the node belongs to a network, in which case the TemporalType cannot be changed.
spublic CausalObservability getCausalObservability()
CausalObservability
of the node. The default value is CausalObservability.OBSERVABLE
.public void setCausalObservability(CausalObservability value)
CausalObservability
of the node. The default value is CausalObservability.OBSERVABLE
.public NodeDistributionOptions getDistributionOptions()
public Bounds getBounds()
public void setBounds(Bounds value)
value
- The size and location of the node.public String toString()
public Distribution newDistribution(int temporalOrder)
getDistributions()
to perform the assignment.
See NodeDistributions
for more information.
Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.
temporalOrder
- The order for the requested distribution.NodeDistributions
public Distribution newDistribution(NodeDistributionKey key)
getDistributions()
to perform the assignment.
See NodeDistributions
for more information.
Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.
A noisy node is specified using multiple distributions, one for each parent and a leak distribution. Set the related node property to a parent, or set it to the current node to set the leak distribution. Each distribution corresponding to a parent of the noisy node has a number of constrained values which are not parameters. These are automatically set by newDistribution (see the help for noisy nodes in the main documentation for more detail).
key
- Identifies the order/related node for the requested distribution.NodeDistributions
public Distribution newDistribution(NodeDistributionKind kind)
getDistributions()
to perform the assignment. For temporal or noisy nodes us a different overload.
See NodeDistributions
for more information.
Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.
kind
- The kind of distribution to create.NodeDistributions
public Distribution newDistribution(NodeDistributionKey key, NodeDistributionKind kind)
getDistributions()
to perform the assignment.
See NodeDistributions
for more information.
Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.
Experience table entries are also initialized to 1.
A noisy node is specified using multiple distributions, one for each parent and a leak distribution. Set the related node property to a parent, or set it to the current node to set the leak distribution. Each distribution corresponding to a parent of the noisy node has a number of constrained values which are not parameters. These are automatically set by newDistribution (see the help for noisy nodes in the main documentation for more detail).
key
- Identifies the order/related node for the requested distribution.kind
- The kind of distribution to create.NodeDistributions
public Distribution newDistribution(NodeDistributionKey key, NodeDistributionKind kind, DistributionExpression expression)
com.bayesserver.node.Distributions#getExpressions
to perform the assignment from an expression.
See com.bayesserver.nodedistributions.Expressions
for more information. *key
- Identifies the order/related node for the requested distribution.kind
- The kind of distribution to create.expression
- The expression that should be used to generate the distribution.com.bayesserver.nodedistributions.Expressions
public Distribution newDistribution()
getDistribution()
property.
This method is useful for creating distributions appropriate for a node. However, the returned distribution cannot be set to getDistribution()
until the distribution has been correctly specified.
Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.
This is a helper function that creates a distribution of the required shape for a node, given its parents (and other factors such as whether it is a noisy node etc�). You do not have to use newDistribution. Instead you can create the distribution manually, however newDistribution is usually the preferred approach. In its most simple form, calling newDistribution on a node A, simply creates a Table containing the variables in A conditioned on the variables in all the parents of A (or a CLGaussian if any continuous variables are involved). You then need to specify all the parameters before assigning it to A. For noisy nodes, use one of the other overloads for NewDistribution, as noisy nodes require multiple distributions, and a key is used to specify which one is being set.IllegalArgumentException
- Raised if the node or one of it's parents has zero states.public Distribution getDistribution()
Node
. The distribution cannot be modified when it is assigned to a node. It is also automatically set to null, when certain structural changes occur (see remarks).
If a structural change occurs to the network that invalidates the current distribution, it is automatically set to null. This occurs in the following situations:getLinksIn()
collection changes. I.e. adding or removing a parent node. Note that if a node is removed from a network, all of its links are automatically removed also.IllegalArgumentException
- Raised when the distribution is invalid.public void setDistribution(Distribution value)
Node
. The distribution cannot be modified when it is assigned to a node. It is also automatically set to null, when certain structural changes occur (see remarks).
If a structural change occurs to the network that invalidates the current distribution, it is automatically set to null. This occurs in the following situations:getLinksIn()
collection changes. I.e. adding or removing a parent node. Note that if a node is removed from a network, all of its links are automatically removed also.IllegalArgumentException
- Raised when the distribution is invalid.public NodeDistributions getDistributions()
public String getName()
public void setName(String value)
public String getDescription()
public void setDescription(String value)
public Network getNetwork()
Network
the node belongs to. Value will be null unless the node has been added to a network.public NodeLinkCollection getLinks()
public NodeVariableCollection getVariables()
public NodeLinkCollection getLinksIn()
public NodeLinkCollection getLinksOut()
public int getIndex()
Copyright © 2023. All rights reserved.