DiagNetwork
From DSL
The DiagNetwork object is used to obtain the following numeric data through the call to its update() method:
- Diagnostic value of tests, based on entropy and cost
- Probability of faults
Please note that diagnosis-related attributes of nodes and outcomes are accessed with methods defined in Network class - see methods getNodeDiagType, getNodeQuestion, getOutcomeLabel, getOutcomeDocumentation, etc.
DiagNetwork provides a simple interface for iterating over fault states in the model. These fault states are accessed through fault indices falling in the <0..getFaultCount-1> range, where getFaultCount is a method of DiagNetwork class. The methods for getting/setting pursued fault(s) use these indices. Please note that any fault node can have more than one fault state.
To instantiate observations, one can use any combination of node handle/id and outcome index/id. We provide four overloaded methods for user's convenience.
To build an diagnostic user interface, both Network and DiagNetwork are needed. DiagNetwork can be created only by passing Network reference to its constructor and is associated with this particular Network object until destroyed.
The general outline of a program utilizing DiagNetwork object is:
1. Create DiagNetwork
2. Set the pursued fault(s)
3. Instantiate/release observation(s)
4. Call the update() method
5. Go to (2), (3) or exit
DiagNetwork uses auxiliary value types to return information: FaultInfo, ObservationInfo, and DiagResults.
[edit] Constants
- static final double NotRelevant
Value used to mark observations and faults cut by d-separation, when DSep property (see below) is set to true.
- static final double NotAvailable
Value used to mark observations when their cost-parent nodes are instantiated and appropriate entry in their cost matrix is set to N/A.
[edit] Inner Classes
- MultiFaultAlgorithmType
This class holds the names of algorithms used to update Bayesian (belief) networks. Available algorithms include: Lauritzen, Henrion, Peardeletearcl, LSampling, SelfImportance, HeuristicImportance, BackSampling, AisSampling, and EpisSampling.
For more detailed information on the above algorithms please consult SMILE On-Line Documentation.
[edit] Methods
In this section, all the methods defined for the Class DiagNetwork are described below. To view the list of methods please refer to DiagNewtwork Methods.
- DiagNetwork(Network net)
Creates DiagNetwork and it's wrapped DIAG_network C++ object. Sets the most likely fault as the pursued one. Throws SMILEException when net is null.
- int getFaultCount()
Returns the number of fault states in the associated Network object.
- int getUnperformedTestCount()
Returns the number of unperformed tests (observations).
- boolean getDSep
void setDSep(boolean value)
Sets/returns the state of flag controlling the d-separation feature of diagnostic code. When enabled, some of observations and faults are omitted from calculation and marked with NotRelevant value. This allows for faster execution time.
- int getMultiFaultAlgorithm()
void getMultiFaultAlgorithm(int type)
Sets/returns the algorithm used to calculate entropy-based diagnostic value for observations when more than one fault is set as pursued. The default value is IndependenceAtLeastOne.
More information on available algorithms is available in the MultiFaultAlgorithmType inner class description (above).
- void instantiateObservation(int nodeHandle, int outcomeIndex)
void instantiateObservation(int nodeHandle, String outcomeId)
void instantiateObservation(String nodeId, String outcomeId)
void instantiateObservation(String nodeId, int outcomeIndex)
Instantiate observation by setting evidence on node to specified outcome. These methods also update internal state of DiagNetwork, so they're not simple equivalent of Network.setEvidence(). SMILEException is thrown when SMILE returns error code.
- void releaseObservation(int nodeHandle)
void releaseObservation(String nodeId)
Release observation by clearing evidence on given node. These methods also update internal state of DiagNetwork, so they're not simple equivalent of Network.clearEvidence(). SMILEException is thrown when SMILE returns error code.
- int[] getUnperformedObservations()
string[] getUnperformedObservationIds()
Return the array containing handles/identifiers of observations which haven't been instantiated yet.
- bool mandatoriesInstantiated()
Returns true if all mandatory observations have been instantiated.
- int findMostLikelyFault()
Returns index of fault state with highest probability.
- int getFaultIndex(int nodeHandle, int outcomeIndex)
int getFaultIndex(int nodeHandle, String outcomeId)
int getFaultIndex(String nodeId, String outcomeId)
int getFaultIndex(String nodeId, int outcomeIndex)
Convert node/outcome pair to fault index. Returns negative value if not found.
- int getFaultNode(int faultIndex)
string getFaultNodeId(int faultIndex)
int getFaultOutcome(int faultIndex)
string getFaultOutcomeId(int faultIndex)
Return node/outcome information given fault index. SMILEException is thrown when faultIndex is out of <0..getFaultCount()-1> range.
- FaultInfo getFault(int faultIndex)
Return complete information about given fault, including node handle, outcome index, probability and pursued status. SMILEException is thrown when faultIndex is out of <0..getFaultCount()-1> range. For more information see FaultInfo class
- int getPursuedFault()
Returns the index of currently pursued fault. If multiple faults are pursued, negative value is returned.
- int[] getPursuedFaults()
Returns the indices of currently pursued faults. If single fault is pursued, array with one element is returned.
- void setPursuedFault(int faultIndex)
Sets the single pursued fault. SMILEException is thrown when faultIndex is out of <0..getFaultCount()-1> range or SMILE returns error code.
- void setPursuedFaults(int[] faultIndices)
Sets pursued faults. It's correct to pass array with one element to this function. SMILEException is thrown when any element of faultIndices is out of <0..FaultCount-1> range or SMILE returns error code.
- DiagResults update()
Calculates the probability of faults and diagnostic value of observations. SMILEException is thrown when SMILE returns error code.
Complete information about tests and faults is returned in DiagResults object - DiagNetwork used to obtain these results is not needed to interpret them (so it's possible to get rid of the DiagNetwork object right after update() when no more observations are going to be instantiated/released, or pursued fault set is going to be changed).
