Beispiel #1
0
        /// <summary>
        /// Write to file a given instance
        /// </summary>
        /// <param name="instance">The instance to execute</param>
        public void WriteGivenIMSProblem
        (
            ProblemInstance instance,
            IMS_ISolver solver,
            String currentPlan = null)
        {
            string initialH = 0.ToString();

            if (solver.GetCostFunction() == CostFunction.SOC)
            {
                Tuple <double, int> bestInitH = solver.GetHeuristicCalculatorInitialH();
                double bestH      = bestInitH.Item1;
                double bestAgents = bestInitH.Item2;
                initialH = bestH.ToString();
            }

            writeToFile(
                solver.GetName(),                               // solver name
                planningTime.ToString(),                        // planning time
                costFunctionToString(solver.GetCostFunction()), // cost function
                solver.GetSolutionCost().ToString(),            // solution  cost
                instanceId.ToString(),                          // instanceId
                instance.fileName,                              // file Name
                instance.m_vAgents.Length.ToString(),           // #Agents
                m_mapFileName,                                  // Map name
                solver.IsSolved().ToString(),                   // Success
                instance.m_nObstacles,                          // Obstacles
                solver.GetExpanded().ToString(),                // Expansions
                solver.GetGenerated().ToString(),               // Generates
                preprocessingTime.ToString()                    // preprocessing time
                //solver.GetHeuristicCalculator().GetName() // Heuristic Name
                //initialH // Initial h value
                );
        }
Beispiel #2
0
        /// <summary>
        /// Solve a given instance with the given solver
        /// </summary>
        /// <param name="solver">The solver</param>
        /// <param name="instance">The problem instance that will be solved</param>
        private void runIMS
        (
            IMS_ISolver solver,
            ProblemInstance instance
        )
        {
            // Run the algorithm
            bool solved;

            Console.WriteLine("----------------- " + solver + " with " + solver.GetHeuristicCalculator().GetName() + ", Minimizing " + solver.GetCostFunction().ToString() + " -----------------");
            Constants.ALLOW_WAIT_MOVE = false;
            this.startTime            = this.ElapsedMillisecondsTotal();
            solver.GetHeuristicCalculator().init(instance);
            solver.Setup(instance, this);
            solved      = solver.Solve();
            elapsedTime = this.ElapsedMilliseconds();
            if (solved)
            {
                Console.WriteLine();
                Console.WriteLine("Total {0} cost: {1}", solver.GetCostFunction(), solver.GetSolutionCost());
            }
            else
            {
                Console.WriteLine("Failed to solve");
            }
            Console.WriteLine();
            Console.WriteLine("Expanded nodes: {0}", solver.GetExpanded());
            Console.WriteLine("Time in milliseconds: {0}", elapsedTime);
            if (toPrint)
            {
                this.PrintStatistics(instance, elapsedTime, solver);
            }
        }