Example #1
0
        public ExpandingNode GetMaxLeafNode(int stopLevel)
        {
            List <ExpandingNode> .Enumerator e = nodeList.GetEnumerator();
            double        maxVal      = -0.1;
            ExpandingNode maxLeafNode = null;

            while (e.MoveNext())
            {
                // if it is less than stop level and child count = 0
                if (e.Current.level < stopLevel && e.Current.childrenNodes.Count == 0)
                {
                    // only expanding NEW node
                    if (e.Current.state == ExpandingNode.STATE.NEW)
                    {
                        if (e.Current.maxVal > maxVal)
                        {
                            maxLeafNode = e.Current;
                            maxVal      = e.Current.maxVal;
                        }
                    }
                }
            }
            treeMaxVal = maxVal;
            return(maxLeafNode);
        }
Example #2
0
 public ExpandingTree(ExpandingNode root)
 {
     nodeList = new List <ExpandingNode>();
     rootNode = root;
     root.AddToParent(null);
     nodeList.Add(root);
 }
Example #3
0
 public void AddToParent(ExpandingNode node, ExpandingNode parent)
 {
     if (parent != null)
     {
         node.AddToParent(parent);
         nodeList.Add(node);
     }
 }
Example #4
0
 public ExpandingNode(PlanningNode node)
 {
     planningNode  = node;
     parentNode    = null;
     childrenNodes = new List <ExpandingNode>();
     minVal        = 0.0;
     maxVal        = Double.MaxValue;
     level         = -1;
     instRwd       = 0.0;
     futrRwd       = 0.0;
     state         = STATE.NEW;
 }
Example #5
0
 public void AddToParent(ExpandingNode parent)
 {
     parentNode = parent;
     if (parent != null)
     {
         parent.childrenNodes.Add(this);
         level = parent.level + 1;
     }
     else
     {
         level = 0;
     }
 }
Example #6
0
        public HexaPath GetPath(ExpandingNode node)
        {
            HexaPath path = new HexaPath();

            ExpandingNode currentNode = node;

            while (currentNode != null)
            {
                path.InsertFront(currentNode.planningNode.pos);
                currentNode = currentNode.parentNode;
            }

            return(path);
        }
Example #7
0
        public void BackPropagateMinVal(ExpandingNode node, double val)
        {
            // set self minVal
            node.minVal = val;

            ExpandingNode parent = node.parentNode;

            // stop at the root
            while (parent != null && parent.minVal < val)
            {
                parent.minVal = val;
                parent        = parent.parentNode;
            }
        }
Example #8
0
        public ExpandingNode GetMaxChild(ExpandingNode node)
        {
            ExpandingNode maxChild = null;
            double        maxVal   = -0.1;

            List <ExpandingNode> .Enumerator e = node.childrenNodes.GetEnumerator();
            while (e.MoveNext())
            {
                if (e.Current.maxVal > maxVal)
                {
                    maxChild = e.Current;
                    maxVal   = e.Current.maxVal;
                }
            }

            return(maxChild);
        }
Example #9
0
        private void FormatVertex(object sender, FormatVertexEventArgs <ExpandingNode> e)
        {
            ExpandingNode ent = e.Vertex;

            //e.VertexFormatter.Label = ent.GetName();
            e.VertexFormatter.Shape = GraphvizVertexShape.Record;
            e.VertexFormatter.Style = GraphvizVertexStyle.Filled;

            switch (ent.state)
            {
            case ExpandingNode.STATE.NEW:
                e.VertexFormatter.FillColor = Color.Orange;
                break;

            case ExpandingNode.STATE.EXPANDED:
                e.VertexFormatter.FillColor = Color.Red;
                break;

            case ExpandingNode.STATE.FREEZED:
                e.VertexFormatter.FillColor = Color.LightBlue;
                break;
            }

            GraphvizRecord rec = new GraphvizRecord();

            GraphvizRecordCell name = new GraphvizRecordCell();

            name.Text = ent.GetName();

            GraphvizRecordCell maxScore = new GraphvizRecordCell();

            maxScore.Text = ent.maxVal.ToString();

            GraphvizRecordCell minScore = new GraphvizRecordCell();

            minScore.Text = ent.minVal.ToString();

            rec.Cells.Add(name);
            rec.Cells.Add(maxScore);
            rec.Cells.Add(minScore);

            e.VertexFormatter.Record = rec;
        }