DSL_nodeVal

<< Click to Display Table of Contents >>

Navigation:  Reference Manual > Node values >

DSL_nodeVal

Header file: nodeval.h

DSL_nodeVal is an abstract base class in node definition class hierarchy. Various (public) virtual DSL_nodeVal class methods called internally by DSL_network to manage its nodes are not listed in this section, because they should never be called by code that is not part of SMILE library.

Objects of classes derived from DSL_nodeVal are created and destroyed by their parent DSL_node. Never use delete on a node definition pointer.

Use DSL_node::Val method to obtain a pointer to node's definition.


template <class T> T* As();

template <class T> const T* As() const;

Statically cast this to the specified type T. Note that there is no runtime type checking. DSL_node::Val()->As<T> is equivalent to DSL_node::Val<T>().


const DSL_network* Network() const;

Returns a pointer to a network that contains value's node.


int Handle() const;

Returns a handle of value's node. The handle does not change during the lifetime of the node value.


virtual int GetType() const = 0;

Returns the numeric type identifier of the value object.


const DSL_intArray& GetIndexingParents() const;

Returns the reference to the DSL_intArray object with handles of the parents indexing the value. This array is non-empty only for influence diagrams. Indexing parents are are unobserved decision nodes that precede the current node or unobserved chance nodes that should have been observed.


int IsValueValid() const;

Returns non-zero if node's value is valid.


virtual const DSL_Dmatrix* GetMatrix() const;
int GetValue(const DSL_Dmatrix** m) const;

Returns the const pointer to the DSL_Dmatrix object with calculated node value. Call only if IsValueValid returns non-zero.


void SetValueValid();

void SetValueInvalid();

Make the node value valid or invalid. These methods should only be called by inference algorithms.


virtual DSL_Dmatrix* GetWriteableMatrix();

Returns the pointer to a writable DSL_Dmatrix object representing the calculated node value (posterior probabilities or expected utilities). This method should only be called by inference algorithms.


virtual int GetMean(double& mean) const;

Writes the mean value for the node in the mean output parameter. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int GetStdDev(double& stddev) const;

Writes the standard deviation for the node in the stddev output parameter. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


int IsEvidence() const;

Returns non-zero if the node has evidence set.


int IsRealEvidence() const;

Returns non-zero if the node has evidence set and the evidence is not a propagated evidence.


int IsPropagatedEvidence() const;

Returns non-zero if the node has a propagated evidence set.


int IsVirtualEvidence() const;

Returns non-zero if the node has a virtual evidence set.


virtual int GetEvidence() const;

Retrieves node's discrete evidence. Returns non-negative outcome index on success, or a negative error code on failure. Default implementation returns DSL_WRONG_NODE_TYPE.

Overridden in DSL_discVal.


virtual const char* GetEvidenceId() const;

If the node has discrete evidence set, returns the outcome id of the evidence outcome. Returns NULL otherwise. Default implementation returns NULL.

Overridden in DSL_discVal.


virtual int GetEvidence(double &evidence) const;

Returns node's continuous evidence in its output evidence parameter. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int SetEvidence(int evidence);

Sets the evidence as an integer index of node's outcome. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int SetEvidence(const char* outcomeId);

Sets the evidence as an integer index of node's outcome. The outcome index is determined by comparing the outcomeId with node outcome identifiers. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal.


virtual int SetEvidence(double evidence);

Sets the evidence as a continuous number. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int GetVirtualEvidence(std::vector<double> &evidence) const;

virtual int GetVirtualEvidence(DSL_doubleArray &evidence) const;

Retrieves node's virtual evidence. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_beliefVector.


virtual int SetVirtualEvidence(const std::vector<double>& evidence);

virtual int SetVirtualEvidence(const DSL_doubleArray &evidence);

int SetVirtualEvidence(std::initializer_list<double> evidence);

Set node's virtual evidence. The last overload creates DSL_doubleArray from std::inititalizer list and calls the SetVirtualEvidence(DSL_doubleArray). Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_beliefVector.


virtual int ClearEvidence();

Removes all types of evidence from the node. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int ClearPropagatedEvidence();

If node is set to propagated evidence, removes the evidence from the node. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal and DSL_equationEvaluation.


virtual int ClearVirtualEvidence();

If node is set to virtual evidence, removes the evidence from the node. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_beliefVector.


bool HasTemporalEvidence() const;

Returns true if node has any temporal evidence (regardless of the slice)


bool IsTemporalEvidence(int slice) const;

Returns true if node has a temporal evidence in the specified slice.


int GetTemporalEvidence(int slice) const;

Retrieves node's discrete temporal evidence for the specified slice. Returns non-negative outcome index on success, or a negative error code on failure.


int GetTemporalEvidence(int slice, std::vector<double> &evidence) const;
int GetTemporalEvidence(int slice, DSL_doubleArray &evidence) const;

Retrieves node's virtual temporal evidence for the specified slice. Returns DSL_OKAY on success, or a negative error code on failure.


int SetTemporalEvidence(int slice, int evidence);

Sets the temporal evidence for the specified slice as an integer index of node's outcome. Returns DSL_OKAY on success, or a negative error code on failure.


int SetTemporalEvidence(int slice, const std::vector<double> &evidence);

Sets the temporal virtual evidence for the specified slice. Returns DSL_OKAY on success, or a negative error code on failure.


int ClearTemporalEvidence(int slice);

Clears the temporal evidence for the specified slice. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int GetTemporalMeanStdDev(

 DSL_doubleArray& temporalMean, 

 DSL_doubleArray& temporalStdDev) const;

virtual int GetTemporalMeanStdDev(

 std::vector<double>& temporalMean, 

 std::vector<double>& temporalStdDev) const;

For a plate node in a DBN, retrieve temporal mean and standard deviation. Returns DSL_OKAY on success, or a negative error code on failure. The default implementation in DSL_nodeVal returns DSL_WRONG_NODE_TYPE to indicate that operation is not supported.

Overridden in DSL_discVal.