コード例 #1
0
        public bool DiscreteNodeInitializeStates(string nodeID, string databaseFieldName, DiscreteChanceNode dNode,
            SepsisFinder sepsisInfo, List<aDiscreteNodeRange> aDiscreteNodeRangeLookUpList, List<aDiscreteNodeLookup> aDiscreteNodeLookUpList)
        {
            //Find the right property to read a value from by databaseFieldName
            PropertyInfo result = sepsisInfo.GetType().GetProperties().Where(x => x.Name.Equals(databaseFieldName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
            //If value is null, don't initialize anything on the current node
            if (result.GetValue(sepsisInfo, null) != null)
            {
                string nodeState = null;

                //Check if discrete node is standard
                if (aDiscreteNodeLookUpList.Exists(x => x.NodeID.Equals(nodeID)))
                {
                    byte value = (byte)result.GetValue(sepsisInfo, null); //Standard use byte
                    nodeState = GetStateToInitDNodeStandard(nodeID, value, aDiscreteNodeLookUpList); //Find state on discrete node to initialize - standard
                }
                //Check if discrete node is range
                else if (aDiscreteNodeRangeLookUpList.Exists(x => x.NodeID.Equals(nodeID)))
                {
                    float value = (float)result.GetValue(sepsisInfo, null); //Range use float
                    nodeState = GetStateToInitDNodeRange(nodeID, value, aDiscreteNodeRangeLookUpList); //Find state on discrete node to initialize - range
                }

                //In some cases, a value might not be mapped to any node state. In that case, skip
                if (nodeState == null)
                {
                    return false;
                }
                //Enter findings (evidence) in discrete node
                DiscreteNodeEnterFindings(dNode, nodeState);
                return true;
            }
            return false;
        }
コード例 #2
0
 public void DiscreteNodeEnterFindings(DiscreteChanceNode dNode, string nodeState)
 {
     int i = 0;
     while (i < (int)dNode.GetNumberOfStates())
     {
         string currentNodeLabel = dNode.GetStateLabel((uint)i);
         if (currentNodeLabel.Equals(nodeState, StringComparison.OrdinalIgnoreCase))
         {
             dNode.EnterFinding((uint)i, 1.0f); //Set state to 100 %
         }
         else
         {
             dNode.EnterFinding((uint)i, 0f); //Set state to 0 %
         }
         i++;
     }
 }