public final class Variable extends Object implements Comparable<Variable>, Cloneable
A Node
in a Bayesian network can contain one or more variables.
Although a discrete variable can contain a different number of states
, a continuous variable always contains a single state.
Constructor and Description |
---|
Variable()
Initializes a new instance of the
Variable class, with VariableValueType discrete and zero states. |
Variable(String name)
Initializes a new instance of the
Variable class, with VariableValueType discrete, zero states, and the specified name. |
Variable(String name,
int states)
Initializes a new instance of the
Variable class, with VariableValueType discrete and the specified [name] and adds the number of states specified in [states]. |
Variable(String name,
State... states)
Initializes a new instance of the
Variable class, with VariableValueType discrete and the specified name and adds the states specified in [states]. |
Variable(String name,
String[] states)
Initializes a new instance of the
Variable class, with VariableValueType discrete and the specified name and adds the states specified in [states]. |
Variable(String name,
VariableValueType valueType)
Initializes a new instance of the
Variable class with the specified name and value type. |
Variable(String name,
VariableValueType valueType,
VariableKind kind)
Initializes a new instance of the
Variable class with the specified name, kind and value type. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Variable other) |
Variable |
copy()
Copies this instance.
|
State |
findStateByValue(Object value)
Finds a state based on a state value.
|
CustomPropertyCollection |
getCustomProperties()
Gets custom properties associated with this instance.
|
String |
getDescription()
An optional description for the variable.
|
String |
getExpressionAlias()
Gets a c-style name for a variable that can be used as an alias in expressions.
|
QueryExpression |
getFunction()
Gets an expression, which is evaluated during a query, and can be based on other queries and expressions.
|
int |
getIndex()
The Index of this instance in the collection of variables belonging to a network, or -1 if the variable does not belong to a node and hence a network.
|
VariableKind |
getKind()
Gets the kind of variable, such as Probability, Decision, Utility or Function.
|
String |
getName()
Gets the name of the variable.
|
Node |
getNode()
Gets the
Node this instance belongs to, if any. |
StateCollection |
getStates()
Returns the collection of states belonging to the variable.
|
StateValueType |
getStateValueType()
Gets the type of value that states belonging to this variable can represent.
|
VariableValueType |
getValueType()
Gets the variable's value type, e.g.
|
void |
setDescription(String value)
An optional description for the variable.
|
void |
setExpressionAlias(String value)
Sets a c-style name for a variable that can be used as an alias in expressions.
|
void |
setFunction(QueryExpression value)
Sets an expression, which is evaluated during a query, and can be based on other queries and expressions.
|
void |
setName(String value)
Sets the name of the variable.
|
void |
setStateValueType(StateValueType value)
Sets the type of value that states belonging to this variable can represent.
|
String |
toString()
Returns the name of the variable, or an empty string if the name is null.
|
public Variable()
Variable
class, with VariableValueType
discrete and zero states.public Variable(String name)
Variable
class, with VariableValueType
discrete, zero states, and the specified name.name
- The name of the variable. Can be null.public Variable(String name, VariableValueType valueType, VariableKind kind)
Variable
class with the specified name, kind and value type. If discrete, no states are added.name
- The name of the variable. Can be null.valueType
- The value type, e.g. continuous or discrete.kind
- The kind of Variable, e.g. Probability, Decision or Utility.public Variable(String name, VariableValueType valueType)
Variable
class with the specified name and value type. If discrete, no states are added.name
- The name of the variable. Can be null.valueType
- The value type, e.g. continuous or discrete.public Variable(String name, int states)
Variable
class, with VariableValueType
discrete and the specified [name] and adds the number of states specified in [states].name
- The name to give the Variable, which can be null or empty.states
- The number of states to add to the Variable. States will be given default names.IllegalArgumentException
- Raised when the [states] parameter is less than zero.public Variable(String name, String[] states)
Variable
class, with VariableValueType
discrete and the specified name and adds the states specified in [states].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.IllegalArgumentException
- Raised when the names in [states] are not unique, or are null or empty.public Variable(String name, State... states)
Variable
class, with VariableValueType
discrete and the specified name and adds the states specified in [states].name
- The name of the node and variable.states
- The states to add to the associated Variable
.NullPointerException
- Raised when [states] is null.IllegalArgumentException
- Raised when the names in [states] are not unique, or are null or empty.public State findStateByValue(Object value)
value
- The value to test against state values. Type will depend on StateValueType. e.g. pass a double if the state value type is a double interval.public int compareTo(Variable other)
compareTo
in interface Comparable<Variable>
public StateValueType getStateValueType()
public void setStateValueType(StateValueType value)
public CustomPropertyCollection getCustomProperties()
public String getDescription()
public void setDescription(String value)
public QueryExpression getFunction()
public void setFunction(QueryExpression value)
public VariableValueType getValueType()
public VariableKind getKind()
public StateCollection getStates()
State
public String toString()
public Node getNode()
Node
this instance belongs to, if any.public String getExpressionAlias()
public void setExpressionAlias(String value)
public String getName()
public void setName(String value)
public int getIndex()
Copyright © 2021. All rights reserved.