Reference Manual: DIAG network

From DSL
Jump to: navigation, search

The necessary functions to perform diagnosis are provided by this class. Whenever the user selects a target state to pursue, functions in this class are called to determine the ranking of each test and returns the results with the restriction that the network contains at least one target and one observation node. For more information about these types see class DSL_extraDefinition.

All the states that the user would like to pursue are stored in the vector faults and are called faultStates. Each faultState contains the handle of the node and the handle of the state that the user would like to pursue. From the vector faults the user can select one or more faultStates to pursue. The array pursuedFaults will contain the index of the specific faultStates in the array faults. The vector faults and the array pursuedFaults are declared as follows:

  std::vector<DIAG_faultyState> faults;   
  DSL_intArray pursuedFaults; // indexes in [faults]

where DIAG_faultyState is declared as follows:

  struct DIAG_faultyState {  int node;  int state; };

The observation nodes that have the flag ranked and are still unperformed are stored in the array unperformedTests. This array will contain the handle of the unperformed ranked observation node. For more information about ranked see class DSL_extraDefinition. To help the user select the best test, the system calculates the usefulness or value for each test depending on the pursuedFaults. The values for each test are stored in the vector testStatistics. The vector unperformedTests and the vector testStatistics are declared as follows:

  // contains all ranked observations not observed yet 
 
  DSL_intArray unperformedTests; 
  
  // test results (paired with [unperformedTests]) std::vector<DIAG_testInfo> testStatistics; where DIAG_testinfo is declared as follows: 
  struct DIAG_testInfo { int    test; double entropy; double cost; double strength; };

To perform diagnosis, information from the network is collected with CollectNetworkInfo and a model is created perform diagnosis. It is assumed that the model will not change after creating (i.e. we are in the troubleshooting phase, as opposed to the model-building phase).


Methods

  • int LinkToNetwork(DSL_network *thisNet)

Links ourselves to the specified network thisNet and compiles the model associated with this network.


  • DSL_network &GetNetwork(void)

Returns the network we are linked to.


  • int LoadModel(char *fileName)

Loads the model with its contents from filename, collects the network information, and compiles the model. If any error occurred during the reading of the file the function will return the error DSL_OUT_OF_RANGE. It is assumed that the model will not change after this method is called (i.e., we are in the troubleshooting phase, as opposed to the model-building phase). After loading the model is ready for performing diagnosis.


  • int RestartDiagnosis(void)

Clears all the diagnosis steps (release the evidence and pursuedFaults) and leaves the network as if LoadModel has just been called.


  • int ComputeTestStrenghts(void)

Solves the diagnostic model and computes the Value of Information for all the unperformed ranked observation nodes. With GetTestStatistics the values of these nodes can be collected.


  • DSL_intArray &GetUnperformedTests(void)

Returns an array of handles to the nodes of the ranked tests (observation nodes) of the network that are unperformed (haven't been instantiated with evidence yet). For more information about ranked see class DSL_extraDefinition. This array can be combined with the array testStatistics to give an overview, which is the best test to select.


  • std::vector<DIAG_testInfo> &GetTestStatistics(void)

Returns a vector of the testStatistics of all the ranked unperformed (haven't been instantiated with evidence yet) tests of the network. For each of these test the array stores:

The handle to the observation node

The calculated entropy (value for how good the test is)

The cost associated with performing this test

The strength of the test, ratio of the calculated entropy and the cost

This array is paired with the one returned by GetUnperformedTests.

For more information about the structure of DIAG_testInfo see the introduction of this paragraph.


  • const std::vector<DIAG_faultyState> &GetFaults(void)

Returns a vector of all the handles of the faultStates of the network. Each item in this array is of the type DIAG_faultyState, which stores the handle of the node with the faultState and the handle of the faultState.

For more information about the structure of DIAG_faultyState see the introduction of this paragraph.


  • void SetEntropyCostRatio(double ratio, DSL_network *onThisNet)

Sets the EntropyCostRatio in the network onThisNet as a user-defined property, under the name DIAG_alphaPropertyName.


  • double GetEntropyCostRatio(void)

Gets the EntropyCostRatio from the current network as a user-defined property. If the property is not there, the function will set the EntropyCostRatio to the default: 1. This ratio is used for combining the cost and the calculated entropy of the unperformed ranked tests.


  • int ClearModel(void)

Unloads the network, leaving everything as it was before LoadModel was called.


  • int InstantiateObservation(int thisNode, int toThisOutcome)

Sets the evidence of the observation node, defined with the handle thisNode, to toThisOutcome. If something goes wrong with setting the evidence, the function will return an error. If succeeded the observed test will be removed from the unperformedTests array and the testStatistics will be cleared because they have become invalid.


  • int ReleaseObservation(int thisNode)

Releases the evidence of the observation node defined with the handle thisNode. If something goes wrong with releasing the evidence, the function will return the result of this error. If succeeded the observation node will be added to the array unperformedTests.


  • int SetPursuedFault(int faultHandle)

Empties the array pursuedFaults and adds the faultState defined by, faultHandle, to the array pursuedFaults. The faultStates are members of the array faults and the array pursuedFaults contains the index of the faultState that is to be pursued. If the faultHandle has a value smaller than zero or bigger than the size of the array of faults the function will return the error: DSL_OUT_OF_RANGE and the array pursuedFaults will be emptied.


  • int GetPursuedFault(void)

Checks if the array pursuedFaults consist of only one element, and returns the pursuedFault. The pursuedFault represents the index of the faultState from the vector of all the faultStates that is pursued. When the array pursuedFaults is empty or contains more then one pursuedFault the function will return the error DSL_OUT_OF_RANGE.


  • int SetPursuedFaults(DSL_intArray & faultHandles)

Sets the array pursuedFaults to the array faultHandles. When the array faultHandles contains less then 1 element or when an element of the array faultHandles is smaller then zero or bigger then the size of the vector faults, the function returns the error DSL_OUT_OF_RANGE.


  • int AddPursuedFault(int faultHandle)

Adds the index, faultHandle to the array pursuedFaults. When the index faultHandle, is smaller then zero or bigger then the size of the vector faults, the function will return the error DSL_OUT_OF_RANGE.


  • DSL_intArray &GetPursuedFaults(void)

Returns the array of pursuedFaults. Each pursuedFault represents the index of the faultState from the vector of all the faultStates that is pursued.


  • int AddPursuedFault(int faultHandle)

Deletes the index, faultHandle from the array pursuedFaults. When the index faultHandle, is smaller then zero or bigger then the size of the vector faults, or when the index faultHandle is not in the array pursuedFaults the function will return the error DSL_OUT_OF_RANGE.


  • void SetDefaultStates(void)

Sets evidence in all nodes, flagged as setToDefault, to their default state. For more information about this flag and the default state, see the previous class: DSL_ExtraDefinition.


  • int FindMostLikelyFault(void)

Returns the handle of the most likely fault (IMPORTANT, this function assumes that the current network is already solved). To solve the network you should call GetNetwork()->UpdateBeliefs(). The function will return the handle of the faultState with the highest likeliness. If all the faults have likeliness of 0 the function will return the error value: DSL_OUT_OF_RANGE.


  • int GetHandles(DSL_extraDefinition::troubleType ofThisType, bool getAll, bool ranked, bool mandatory, bool setToDefault, std::vector<int> &here)

This function will return here a vector of handles according to the parameters. These handles could be observation handles (node handles in SMILE) or target handles (fault handles in DIAG_network) NOTE: it does NOT clear content of here before adding the new elements.


  • int CollectNetworkInfo(void)

Collects the information about the current network and fills up the array faults and unperformedTests. A note is that the function assumes that the model is not going to change at run-time.


  • bool MandatoriesInstantiated(void);

Returns true if all mandatories are instantiated and false if one of the nodes is mandatory and not instantiated. For more information about when a node is mandatory, see the previous class: DSL_ExtraDefinition.


  • int FindFault(int faultNode, int faultState)

Returns the index of the fault in the vector of faults that complies with the variables faultNode and faultState. If the fault cannot be found the program will return the error DSL_OUT_OF_RANGE.

Personal tools