DSL_sensitivity

<< Click to Display Table of Contents >>

DSL_sensitivity

Header file: sensitivity.h

DSL_sensitivity performs sensitivity calculation on a specified network and stores the results. Given a set of target nodes, the algorithm calculates a complete set of derivatives of the posterior probability distributions over the target nodes over each of the numerical parameters of the Bayesian network.

Any non-target node will have multiple coefficients calculated, one for each combination of target node and its outcome. To represent a node/outcome pair, the following typedef is provided in the DSL_sensitivity class.

typedef std::pair<int, int> Target;


void GetTargets(std::vector<Target> &targets) const;

Returns information about targets in the network. The Target typedef is defined as

typedef std::pair<int, int> Target;

The first element of the pair is a target node handle, the second is its outcome index. Any non-target node will have multiple coefficients calculated, one for each combination of a target node and its outcome. Each target node will have all its outcomes represented in the targets vector.


int Calculate(DSL_network &net, bool relevance=true);

Calculates sensitivity coefficients, taking current evidence in net into account. If net is not an influence diagram, it must have at least one explicit target node. The relevance flag controls the relevance split before main coefficient calculation.

Returns DSL_OKAY on success, or a negative error code on failure.


double GetMaxSensitivity() const;

Returns maximum sensitivity over all targets.


double GetMaxSensitivity(Target target) const;

Returns maximum sensitivity over a specified target.


double GetMaxSensitivity(int node) const;

Returns maximum sensitivity over all targets for a specified node.


double GetMaxSensitivity(int node, Target target) const;

Returns maximum sensitivity over a specified target for a specified node.


void GetMaxSensitivity(int node, DSL_Dmatrix &maxSens) const;

For a specified node, fills the maxSens matrix with maximum sensitivity for each CPT parameter over all targets.


const DSL_Dmatrix* GetSensitivity(int node, Target target) const;

Returns a pointer to a matrix containing sensitivity value for each CPT parameter of node over a specified target.


void GetCoefficients(int node, Target target, std::vector<const DSL_Dmatrix *> &coeffs) const; 

For a specified node and target, returns the calculated sensitivity coefficients. For chance nodes, coeffs is a 4-element vector with a, b, c, d. For probabilitites, the target posterior (tp) is a function of given CPT entry (p):

 tp = (a * p + b) / (c * p + d)

This applies to BNs and IDs alike. For utilities the relationship is linear, the target utility (tu) is a function of  given utility or ALU weight (u):

 tu = a * u + b

The coeffs vector will have only two entries, the values of a and b.


const std::vector<int>& GetIndexingNodes() const;

For sensitivity calculated in an influence diagram, the method returns a reference to the vector with handles of indexing parents of the utility node. The combinations of the outcomes of the indexing parents are sensitivity configurations. In order to obtain sensitivity for a specific configuration, its index must be set with SetCurrentConfig.


int GetNumberOfConfigs() const

For sensitivity calculated in an influence diagram, returns a number of configurations (combinations of the utility indexing parents).


bool IsConfigPossible(int configIndex) const;

For sensitivity calculated in an influence diagram, returns true if a sensitivity configuration at specific configIndex is possible.


int SetCurrentConfig(int configIndex);

For sensitivity calculated in an influence diagram, sets the current configuration index.


int GetCurrentConfig() const;

Returns the current configuration index.