Exemple #1
0
 public void solveAndShow()
 {
     solution = solver.solve(inp);
     solution.computeDistance();
     Length_label.Text = solution.totalDistance.ToString();
     vis.draw(solution);
 }
Exemple #2
0
        private void Extern_button_Click(object sender, EventArgs e)
        {
            Process p = new Process();

            //p.StartInfo.FileName = @"C:\Documents and Settings\Ota\Dokumenty\Visual Studio 2010\Projects\MinesVisualizer\bin\Debug\MinesVisualizer.exe";
            p.StartInfo.FileName               = @".\solver.exe";
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardInput  = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            p.StandardInput.WriteLine(inp.nodesCount);
            for (int i = 0; i < inp.nodesCount; i++)
            {
                p.StandardInput.WriteLine((int)(Math.Floor(inp.getPoint(i).x)) + " " + (int)(Math.Floor(inp.getPoint(i).y)));
            }
            string result = p.StandardOutput.ReadLine();

            solution = TSPSolution.fromString(result, inp);
            solution.computeDistance();
            Length_label.Text = solution.totalDistance.ToString();
            vis.draw(solution);
        }
Exemple #3
0
        private void Solve_button_Click(object sender, EventArgs e)
        {
            if (engines_listBox.SelectedIndex == 3)
            {
                TreeAproximativeSolver s = new TreeApproximativeSolverFactory().create();
                solution = s.solve(inp);
                solution.computeDistance();
                Length_label.Text = solution.totalDistance.ToString();
                vis.drawSpanningTree(inp, s.successorsList);
                vis.draw(solution, false);
            }
            else
            {
                switch (engines_listBox.SelectedIndex)
                {
                case 0:
                    solver = new RandomSolverFactory().create();
                    break;

                case 1:
                    solver = new GreedySolverFactory().create();
                    break;

                case 2:
                    solver = new GreedyGrowingSolverSolverFactory().create();
                    break;

                case 4:
                    solver = new OptimalSolverFactory().create();
                    break;

                case 5:
                    solver = new CentroidBubbleSolver();
                    break;

                case 6:
                    /*
                     * solver = new PlannerWrapperFactory().create(plannerType.AstarBlind);
                     * break;
                     */
                    HillClimbingSolver s = new HillClimbingSolver(vis);
                    solution = s.solve(inp);
                    solution.computeDistance();
                    Length_label.Text = solution.totalDistance.ToString();
                    vis.draw(solution, false);
                    return;

                case 7:
                    GeneticAlgorightm ga = new GeneticAlgorightm(vis);
                    solution = ga.solve(inp);
                    solution.computeDistance();
                    Length_label.Text = solution.totalDistance.ToString();
                    vis.draw(solution, false);
                    return;
                }
                solveAndShow();
            }



            /*
             * 0 Random engine
             * 1 Greedy engine
             * 2 Greedy Growing engine
             * 3 Spanning tree 2-approximation
             * 4 Optimal solver
             * 5 Star solver
             * 6 Planner Blind
             * 7 Planner + FF heuristic
             * 8 Beam Search blind
             * 9 Hill climbing blind
             * 10 Hill climbing + FF heuristic
             * 11 MCTS blind
             * 12 MCTS + FF heuristic
             */
        }
Exemple #4
0
 private double Fitness(TSPSolution sol)
 {
     return(1 / sol.computeDistance());
 }