SMILE.NET: DiagNetwork

From DSL

Jump to: navigation, search

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..FaultCount-1> range, where FaultCount is a read-only property 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.

Contents

[edit] Interfaces

  • IDisposable

The .NET garbage collector automatically releases the memory allocated to a objects when they’re no longer used. It is however unpredictable when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources such as DIAG_network C++ object wrapped by DiagNetwork. The IDisposable.Dispose() method provides means to ensure that wrapped object is deleted before garbage collection occurs:

  void TestDiagNet(Network net) {
    DiagNetwork diagNet = new DiagNetwork(net);
    try {
      // use diagNet here
    }
    finally {
     If (diagNet != null) diagNet.Dispose();
    }
  }

C# has an using statement, which is the equivalent to try/finally/Dispose construct in the preceding example:

  void TestDiagNet5(Network net) {
    using (DiagNetwork diagNet = new DiagNetwork(net)) {
      // use diagNet here 
    }
  }


[edit] Constants

  • static const double NotRelevant

Value used to mark observations and faults cut by d-separation, when DSep property (see below) is set to true.


  • static const double NotAvailable

Value used to mark observations when their cost parent nodes are instantiated and appropriate entry in the cost matrix is set to NotAvailable (or "N/A" in GeNIe). See Network.GetNodeCost for more information


[edit] Properties

  • int FaultCount (read)

Returns the number of fault states in the associated Network object.


  • int UnperformedTestCount (read)

Returns the number of unperformed tests (observations).


  • bool DSep (read, write)

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.


  • MultiFaultAlgorithmType MultiFaultAlgorithm (read, write)

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.


  • double EntropyCostRatio (read, write)

Sets/returns the value used to combine the cost and the calculated entropy of the unperformed observations. If observation has positive cost associated with it, its infoGain is reduced by EntropyCostRatio * cost.


[edit] 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.


  • 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..FaultCount-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..FaultCount-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..FaultCount-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 use IDisposable.Dispose() right after Update() when no more observations are going to be instantiated/released, or pursued fault set is going to be changed).

Personal tools