示例#1
0
        private void btnRobotPath_Click(object sender, EventArgs e)
        {
            if (this.rbBatchTest.Checked == true)
            {
                //ParameterTester tester = new ParameterTester(this);
                //GdParameterTester tester = new GdParameterTester(this);
                TeleportTester tester = new TeleportTester(this);
                tester.Run();
                MessageBox.Show("Finished batch test");
            }
            else
            {
                // apply parameters
                _human.WingmanToleranceRange = int.Parse(tbWR.Text);
                _human.SetObservationRange(int.Parse(tbHR.Text));

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(_map);

                TopologyGraph tograph = topologyGenerator.GetTopologyGraph();
                //graph.Print();
                tograph.Draw();

                PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph);
                PathPlanningGraph      planGraph         = planningGenerator.GetPathPlanningGraph(this.HumanPath, this.human.WingmanToleranceRange);

                planGraph.Draw();

                HexaPos startPos = _human.path[0];

                PlanningGraphPruner pruner       = new PlanningGraphPruner();
                PathPlanningGraph   newPlanGraph = pruner.GetPlanningGraph(planGraph, startPos);

                newPlanGraph.Draw("PlanningGraph2");

                PathPlanningGraph prunedPlanGraph = pruner.BackwardPrune(newPlanGraph);
                prunedPlanGraph = pruner.ForwardPrune(prunedPlanGraph);

                prunedPlanGraph.Draw("PrunedPlanningGraph");

                /*
                 * ExhaustiveDFSPathPlanner planner = new ExhaustiveDFSPathPlanner(_map, _robot);
                 * HexaPath maxPath = planner.FindPath(prunedPlanGraph, startPos);
                 *
                 * Console.WriteLine("PATH BY EXHAUSTIVE DFS: " + maxPath.ToString());
                 */

                _planningForm = new PlanningForm(prunedPlanGraph, _map, _robot, startPos, _mapDrawer, _human.path);
                _planningForm.Show();
            }
        }
示例#2
0
        public void Run()
        {
            for (int i = 0; i < trial_times; i++)
            {
                foreach (int WR in wingmanRange)
                {
                    HexaPos startPos = this._mapForm.human.path[0];

                    TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(this._mapForm.map);

                    TopologyGraph tograph = topologyGenerator.GetTopologyGraph();

                    PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph);
                    PathPlanningGraph      planGraph         = planningGenerator.GetPathPlanningGraph(this._mapForm.HumanPath, WR);

                    PlanningGraphPruner pruner       = new PlanningGraphPruner();
                    PathPlanningGraph   newPlanGraph = pruner.GetPlanningGraph(planGraph, startPos);

                    PathPlanningGraph prunedPlanGraph = pruner.BackwardPrune(newPlanGraph);
                    prunedPlanGraph = pruner.ForwardPrune(prunedPlanGraph);

                    Robot robot = new Robot(this._mapForm.map);
                    Human human = new Human(this._mapForm.map);

                    foreach (int HR in humanRange)
                    {
                        this._mapForm.map.GetMapStateMgr().RandomizeValue();

                        human.SetObservationRange(HR);
                        double[,] localEntropy = this._mapForm.map.GetMapStateMgr().CopyEntropy();
                        human.Update(this._mapForm.HumanPath, localEntropy);

                        foreach (int RR in robotRange)
                        {
                            robot.SetObservationRange(RR);
                            Console.WriteLine("Trial Time: " + i.ToString() + " WR: " + WR.ToString() + " RR: " + RR.ToString() + " HR: " + HR.ToString());

                            HexaPath maxPath = new HexaPath();

                            TreeExpandingWithIterativeTrackingPathPlanner planner
                                = new TreeExpandingWithIterativeTrackingPathPlanner(this._mapForm.map, robot);
                            planner._localEntropy = localEntropy;
                            planner.iteratingOnce = false;
                            maxPath = planner.FindPath(prunedPlanGraph, startPos);

                            Console.WriteLine("PATH : " + maxPath.ToString());
                            // double[,] tempEntropy = (double[,])this._mapForm.map.GetMapStateMgr().CopyEntropy();
                            //double maxScore = robot.Score(maxPath, tempEntropy);
                            double maxScore = planner.finalMaxScore;
                            Console.WriteLine("SCORE: " + maxScore);

                            Console.WriteLine("");

                            PerformanceParameter param = new PerformanceParameter();
                            param.maxScore          = maxScore;
                            param.problemSize       = planner.problemSize;
                            param.scoreAtFirstRun   = planner.scoreAtFirstRun;
                            param.exploredSize      = planner.exploredSize;
                            param.totalRunTime      = planner.totalRunTime;
                            param.hitOptimalRunTime = planner.hitOptimalRunTime;

                            param.robotRange   = RR;
                            param.humanRange   = HR;
                            param.wingmanRange = WR;
                            param.runIndex     = i;

                            this.performanceList.Add(param);
                        }
                    }
                }
            }

            save(prefix);
        }
示例#3
0
        private void tbPlan_Click(object sender, EventArgs e)
        {
            int planLength = 0;

            if (this.tbPlanLength.Text != "")
            {
                planLength = Int32.Parse(this.tbPlanLength.Text);
            }
            else
            {
                planLength = 0;
            }

            Random  rnd     = new Random();
            int     start_x = this.mapViewForm.map.mapState.ActiveHex.posX;
            int     start_y = this.mapViewForm.map.mapState.ActiveHex.posY;
            HexaPos pos     = new HexaPos(start_x, start_y);

            if (this.rbRandom.Checked == true)
            {
                HexaPath path = new HexaPath();
                path.AddPos(pos);
                for (int t = 0; t < planLength; t++)
                {
                    int rndIdx = rnd.Next(5);
                    HexagonalMap.Direction direction = mapViewForm.map.directionList[rndIdx];
                    HexaPos newPos = mapViewForm.map.GetNext(path[t], direction);
                    path.AddPos(newPos);
                }

                LoadActivePath(path);

                mapViewForm.Refresh();
            }
            else if (this.rbInfoMax.Checked == true)
            {
                InfoMaxPathPlanner planner
                    = new InfoMaxPathPlanner(mapViewForm.map, (Robot)mapViewForm.robot);

                HexaPos startPos = new HexaPos(mapViewForm.startHex.posX, mapViewForm.startHex.posY);

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(mapViewForm.map);
                TopologyGraph          tograph           = topologyGenerator.GetTopologyGraph();
                tograph.Draw();
                PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph);
                PathPlanningGraph      graph             = planningGenerator.GetPathPlanningGraph(startPos, Int32.Parse(this.tbPlanLength.Text));
                graph.Draw();
                planner.iteratingOnce = true;
                HexaPath maxPath = planner.FindPath(graph, startPos);

                LoadActivePath(maxPath);

                mapViewForm.Refresh();
            }
            else if (this.rbDistMin.Checked == true)
            {
                DistMinPathPlanner planner  = new DistMinPathPlanner(mapViewForm.map, (Robot)mapViewForm.robot);
                HexaPos            startPos = new HexaPos(mapViewForm.startHex.posX, mapViewForm.startHex.posY);
                HexaPos            endPos   = new HexaPos(mapViewForm.endHex.posX, mapViewForm.endHex.posY);

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(mapViewForm.map);
                TopologyGraph          tograph           = topologyGenerator.GetTopologyGraph();

                HexaPath path = planner.FindPath(tograph, startPos, endPos);

                LoadActivePath(path);
                mapViewForm.Refresh();
            }
        }