示例#1
0
        private void doValueIteration(BinaryDecisionTree bdt)
        {
            List <double>     maxV        = bdt.ReturnValue(true);
            List <double>     minV        = bdt.ReturnValue(false);
            List <Set <int> > abstractMap = bdt.ReturnLeaves();
            double            tmp;
            int maxvcount = maxV.Count;


            double diff    = 1.0;
            double epsilon = 0.1;

            while (diff > epsilon)
            {
                diff = 0.0;
                for (int k = 0; k < maxvcount; k++)
                {
                    tmp     = doLocalValueIteration(k, abstractMap, maxV, true);
                    diff    = Math.Max(diff, Math.Abs(tmp - maxV[k]));
                    maxV[k] = tmp;
                    tmp     = doLocalValueIteration(k, abstractMap, minV, false);
                    diff    = Math.Max(diff, Math.Abs(tmp - minV[k]));
                    minV[k] = tmp;
                }
            }

            for (int k = 0; k < maxvcount; k++)
            {
                System.Console.WriteLine("maxv " + maxV[k] + " minv " + minV[k]);
            }
            // Need to update the maxValue as well as minValue in the tree
            bdt = bdt.UpdateMaxMin(maxV, minV, abstractMap);
        }
示例#2
0
 internal BinaryDecisionTree UpdateMaxMin(List <double> maxV, List <double> minV, List <Set <int> > abstractMap)
 {
     if (this.trueEdge == null && this.falseEdge == null)
     {
         if (abstractMap.Contains(states))
         {
             int index = abstractMap.IndexOf(states);
             this.maxValue = maxV[index];
             this.minValue = minV[index];
         }
         return(this);
     }
     else
     {
         trueEdge  = trueEdge.UpdateMaxMin(maxV, minV, abstractMap);
         falseEdge = falseEdge.UpdateMaxMin(maxV, minV, abstractMap);
         return(this);
     }
 }
示例#3
0
 private void doValueIteration(BinaryDecisionTree bdt)
 {
     List<double> maxV = bdt.ReturnValue(true);
     List<double> minV = bdt.ReturnValue(false);
     List<Set<int>> abstractMap = bdt.ReturnLeaves();
     double tmp; 
     int maxvcount = maxV.Count;
     
             
     double diff = 1.0;
     double epsilon = 0.1;
     while (diff > epsilon)
     {
         diff = 0.0;
         for (int k = 0; k < maxvcount;k++)
         {
             tmp = doLocalValueIteration(k, abstractMap, maxV, true);
             diff = Math.Max(diff, Math.Abs(tmp - maxV[k]));
             maxV[k] = tmp;
             tmp = doLocalValueIteration(k, abstractMap, minV, false);
             diff = Math.Max(diff, Math.Abs(tmp - minV[k]));
             minV[k] = tmp;
         }
     }        
     
     for (int k = 0; k < maxvcount; k++)
     {
         System.Console.WriteLine("maxv "+ maxV[k]+ " minv "+ minV[k]);
     }
     // Need to update the maxValue as well as minValue in the tree
     bdt = bdt.UpdateMaxMin(maxV, minV, abstractMap);
 }