<< Click to Display Table of Contents >> Navigation: Reference Manual > DSL_diagSession |
Header file: diagsession.h
DSL_diagSession uses an DSL_network instance passed to its constructor to perform cross-entropy calculation for diagnostic observation nodes. When a diagnostic session is in progress, your program should not modify the underlying DSL_network.
DSL_diagSession(DSL_network &diagNetwork);
Initializes the diagnostic session, instantiates the mandatory observations.
int RestartDiagnosis();
Restarts the diagnostic session by removing all evidence from the network.
void UpdateFaultBeliefs();
Performs single inference call to calculate fault beliefs. Fault beliefs are required for FindMostLikelyFault to work.
int UpdateTestStrengths();
Runs the main diagnostic algorithm, which is computationally complex and involves a series of runs of a belief updating algorithm. Returns DSL_OKAY on success, or a negative error code on failure.
int GetSingleFaultAlgorithm() const { return singleFaultAlg; }
int SetSingleFaultAlgorithm(int algId);
Gets/sets the diagnostic measure algorithm for single fault diagnosis. The available algorithms are:
•DSL_DIAG_SINGLE_PROB_CHANGE
•DSL_DIAG_SINGLE_NORM_CROSSENTROPY
•DSL_DIAG_SINGLE_CROSSENTROPY
The default algorithm is DSL_DIAG_SINGLE_PROB_CHANGE.
int GetMultiFaultAlgorithm() const { return singleFaultAlg; }
int SetMultieFaultAlgorithm(int algId);
Gets/sets the diagnostic measure algorithm for single fault diagnosis. The available algorithms are:
•DSL_DIAG_MULTI_MAX_PROB_CHANGE
•DSL_DIAG_MULTI_L2_NORMALIZED_DISTANCE
•DSL_DIAG_MULTI_COSINE_DISTANCE
•DSL_DIAG_MULTI_CITYBLOCK_DISTANCE
•DSL_DIAG_MULTI_AVG_L2_CITY_DISTANCE
•DSL_DIAG_MULTI_DEPENDENCE_ATLEAST1
•DSL_DIAG_MULTI_DEPENDENCE_ONLY1
•DSL_DIAG_MULTI_DEPENDENCE_ALL
•DSL_DIAG_MULTI_INDEPENDENCE_ATLEAST1
•DSL_DIAG_MULTI_INDEPENDENCE_ONLY1
•DSL_DIAG_MULTI_MARGINAL1
•DSL_DIAG_MULTI_MARGINAL2
The default algorithm is DSL_DIAG_MULTI_MAX_PROB_CHANGE.
const std::vector<DSL_diagTestInfo>& GetTestStatistics() const;
After a successful completion, ComputeTestStrengths returns a reference to an unordered vector of DSL_diagTestInfo structures, which contain calculated test statistics. The definition of the DSL_diagTestInfo structure is:
struct DSL_diagTestInfo
{
int test; // node handle
double entropy; // cross entropy
double cost; // observation cost
double strength; // diagnostic value
int observationPriorStartIndex; // detailed entropy
int faultPosteriorsStartIndex; // detailed entropy
};
The diagnostic value is equal to entropy if cost is not specified for the observation. The detailed value of cross-entropy is available from GetEntropyDetails.
const DSL_intArray& GetUnperformedTests()
Returns a reference to an array with handles of observation nodes that have not yet been observed.
const std::vector<DSL_diagFaultState>& GetFaults() const { return faults; }
Returns a vector of DSL_diagFaultState structures containing information about all fault node/state pairs in the network. The definition of the DSL_diagFaultState structure is:
struct DSL_diagFaultState
{
int node; // fault node handle
int state; // fault outcome index
};
The order of the elements in the vector does not change during the diagnostic session. Pursued fault indices are the indices of the elements in this vector.
int GetPursuedFault() const;
Returns the index of the pursued fault or a negative error code if there is no pursued fault, or more than one fault is pursued.
const DSL_intArray& GetPursuedFaults() const;
Returns a reference to an array containing indices of pursued faults. The array will be empty if there are no pursued faults, or will have one element when a single fault is pursued.
int SetPursuedFault(int faultIndex);
Sets the pursued fault to a specified faultIndex. Returns DSL_OKAY on success, or a negative error code on failure.
int SetPursuedFaults(const DSL_intArray & faultindices);
Sets the pursued faults to specified faultIndices. Returns DSL_OKAY on success, or a negative error code on failure.
int FindMostLikelyFault();
Finds the index of most likely fault. The fault probabilities must be calculated by UpdateFaultBeliefs. Returns DSL_OKAY on success, or a negative error code on failure.
int FindFault(int faultNodeHandle, int faultStateIndex) const;
Finds the index of the fault specified by faultNodeHandle and faultStateIndex. Returns DSL_OKAY on success, or a negative error code on failure.
bool MandatoriesInstantiated() const;
Returns true if all mandatory observations have been instantiated.
bool IsDSepEnabled() const;
void EnableDSep(bool enable);
Gets/sets the flag to enable D-separation. When D-separation is enabled, the diagnostic algorithm ranks only those observations that are relevant (in terms of being connected to) to the observed set of evidence nodes. This improves performance on very large networks.
bool IsDetailedEntropyEnabled() const;
void EnableDetailedEntropy(bool enable);
Gets/sets the flag to keep the detailed entropy information after ComputeTestStrengths. See GetEntropyDetails for details.
const std::vector<double>& GetEntropyDetails();
Returns a reference to a vector containing inputs to entropy calculations. The vector is non-empty only if detailed entropy is enabled, and there is a single pursued fault, or all pursued faults are states of the same node. The vector contains interleaved blocks of numbers representing the posterior probabilities of fault node and prior probabilities of observation nodes. To locate the blocks of probabilities, use observationPriorStartIndex and faultPosteriorsStartIndex members of DSL_diagTestInfo structure. The size of the probability block is equal to the number of states of the respective node (pursued fault for fault posteriors and each observation node for observation priors).