Example #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
                );
        }
Example #2
0
 /// <summary>
 /// Print the solver statistics to the results file.
 /// </summary>
 /// <param name="instance">The problem instance that was solved. Not used!</param>
 /// <param name="CFMAMSolver">The solver that solved the problem instance</param>
 /// <param name="runtimeInMillis">The time it took the given solver to solve the given instance</param>
 private void PrintStatistics
 (
     ProblemInstance instance,
     double runtimeInMillis,
     IMS_ISolver CFMAMSolver,
     ICbsSolver CBSMMStarSolver = null
 )
 {
     // Success col:
     //if (solver.GetSolutionCost() < 0)
     //  this.resultsWriter.Write(Run.FAILURE_CODE + RESULTS_DELIMITER);
     //else
     this.resultsWriter.Write(MAM_Run.SUCCESS_CODE + RESULTS_DELIMITER);
     // Runtime col:
     this.resultsWriter.Write(runtimeInMillis + RESULTS_DELIMITER);
     // Solution Cost col:
     //this.resultsWriter.Write(solver.GetSolutionCost() + RESULTS_DELIMITER);
     if (CBSMMStarSolver != null)
     {
         CBSMMStarSolver.OutputStatistics(this.resultsWriter);
         this.resultsWriter.Write(CBSMMStarSolver.GetSolutionDepth() + RESULTS_DELIMITER);
     }
     else
     {
         // Algorithm specific cols:
         CFMAMSolver.OutputStatistics(this.resultsWriter);
         // Solution Depth col:
         this.resultsWriter.Write(CFMAMSolver.GetSolutionDepth() + RESULTS_DELIMITER);
     }
     //this.resultsWriter.Flush();
 }
Example #3
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);
            }
        }
Example #4
0
        public CFMAM_OpenList
        (
            IMS_ISolver user
        )
        {
            this.openNodes = new Dictionary <IBinaryHeapItem, IBinaryHeapItem>();
            this.heap      = new BinaryHeap();
            this.queue     = new Queue <IBinaryHeapItem>();

            this.user = user;
            this.ClearPrivateStatistics();
            this.ClearPrivateAccumulatedStatistics();
        }
Example #5
0
 private void PrintNullStatistics
 (
     IMS_ISolver solver
 )
 {
     // Success col:
     this.resultsWriter.Write(MAM_Run.FAILURE_CODE + RESULTS_DELIMITER);
     // Runtime col:
     this.resultsWriter.Write(Constants.MAX_TIME + RESULTS_DELIMITER);
     // Solution Cost col:
     this.resultsWriter.Write("irrelevant" + RESULTS_DELIMITER);
     // Max Group col:
     this.resultsWriter.Write("irrelevant" + RESULTS_DELIMITER);
     // Solution Depth col:
     this.resultsWriter.Write("irrelevant" + RESULTS_DELIMITER);
 }