<< Click to Display Table of Contents >> Navigation: Reference Manual > Node values > DSL_beliefVector |
Header file: valbeliefvector.h
class DSL_beliefVector : public DSL_discVal
DSL_beliefVector class is derived from DSL_discVal. It provides a value implementation for all discrete chance and deterministic nodes.
In addition to discrete and continuous evidence supported by DSL_discVal, DSL_beliefVector implements the SetVirtualEvidence and GetVirtualEvidence methods declared in DSL_nodeVal. The virtual evidence is specified as a probability distribution over the node outcomes.
DSL_beliefVector also provides methods for controlling the value. Controlling means that the value has been set from the outside. SMILE's implementation of controlling the value follows the so called arc-cutting semantics, which means that the incoming arcs of the controlled node become inactive (nothing inside the model influences the node, as its value is set from the outside).
virtual int GetType() const;
Overridden method from DSL_nodeVal. Returns DSL_BELIEFVECTOR.
const DSL_Dmatrix& GetBeliefs() const;
Returns a reference to the matrix of posterior probabilities. Note that you do not need to cast DSL_nodeVal pointer obtained from DSL_node::Val to DSL_beliefVector in order to get the posteriors. The methods GetMatrix and GetValue (declared in DSL_nodeVal) will return a pointer to the same DSL_Dmatrix object. GetBeliefs is defined to provide a method with a name closely reflecting the Bayesian network terminology.
The matrix can be multi-dimensional if the node has value indexing parents. Indexing parents are unobserved decision nodes that precede the current node or unobserved chance nodes that should have been observed. The size of the last dimension of the matrix (or its only dimension, if there are no value indexing parents) is always equal to the number of node outcomes.
If the node is a plate node in a DBN, the matrix is two-dimensional. The first dimension size is equal to the number of DBN timeslices, the second dimension size is equal to the number of node outcomes.
Otherwise, the matrix is one-dimensional, and the size of its only dimension is equal to the number of the node outcomes.
int ControlValue(int outcomeIndex);
Controls node's value by specifying the outcome index. Returns DSL_OKAY on success, or a negative error code on failure.
int ClearControlledValue();
Makes node's value non-controlled. Returns DSL_OKAY on success, or a negative error code on failure.
int GetControlledValue() const;
Returns the outcome index set by ControlValue, or a negative error code if node value was not controlled.
int IsControlled() const;
Returns non-zero value if the node value is controlled.
bool IsControllable() const;
Returns true if the node value can be controlled. A node is controllable if no evidence is set in any of its descendants.
virtual int GetVirtualEvidence(std::vector<double> &evidence) const;
virtual int GetVirtualEvidence(DSL_doubleArray &evidence) const;
Overridden method from DSL_nodeVal. Retrieves node's virtual evidence. Returns DSL_OKAY on success, or a negative error code on failure.
virtual int SetVirtualEvidence(const std::vector<double>& evidence);
virtual int SetVirtualEvidence(const DSL_doubleArray &evidence);
Overridden method from DSL_nodeVal. Set node's virtual evidence. Returns DSL_OKAY on success, or a negative error code on failure. Fail when the size of the evidence array/vector is not equal to the number of node outcomes.
virtual int ClearVirtualEvidence();
Overridden method from DSL_nodeVal. If the node is set to virtual evidence, removes the evidence from the node. Returns DSL_OKAY on success, or a negative error code on failure.