Ejemplo n.º 1
0
        static void runHeapsTestsOLD(string domainsFolder, List <ISearchHeap> dataStrucutures, TimeSpan timeLimit)
        {
            Logger logger = new Logger();
            List <List <string> > results = new List <List <string> >();

            results.Add(new List <string>());
            results[0].Add("");
            foreach (var directory in Directory.EnumerateDirectories(domainsFolder))
            {
                foreach (var file in Directory.EnumerateFiles(directory))
                {
                    results[0].Add(file);
                }
            }

            foreach (var ds in dataStrucutures)
            {
                results.Add(new List <string>());
                results[results.Count - 1].Add(ds.GetName());
                Problem     d;
                AStarSearch ast;
                //HillClimbingSearch ast;
                foreach (var directory in Directory.EnumerateDirectories(domainsFolder))
                {
                    foreach (var item in Directory.EnumerateFiles(directory))
                    {
                        logger.Log(" ----- new problem ----- ");
                        ds.Clear();
                        d = new Problem(item, false);
                        //ast = new AStarSearch(d, new FFHeuristic(d));
                        ast = new AStarSearch(d, new FFHeuristic(d), ds);
                        ast.Start();
                        logger.Log();
                        results[results.Count - 1].Add(ast.GetSearchTime().TotalSeconds.ToString());
                    }
                    logger.Log(" ----- new domain ----- ");
                }
            }
            foreach (var row in results)
            {
                foreach (var item in row)
                {
                    Console.Write(item + "\t");
                }
                logger.Log();
            }
        }
Ejemplo n.º 2
0
        static void runHeapsTests(string domainsFolder, List <ISearchHeap> dataStrucutures, TimeSpan timeLimit)
        {
            Logger      logger             = new Logger();
            string      heapsResultsFolder = @".\..\tests\heapsResults";
            Problem     d;
            AStarSearch ast;

            //HillClimbingSearch ast;
            foreach (var ds in dataStrucutures)
            {
                if (!Directory.Exists(heapsResultsFolder))
                {
                    Directory.CreateDirectory(heapsResultsFolder);
                }
                using (var writer = new StreamWriter(heapsResultsFolder + "\\" + ds.GetName() + ".txt"))
                {
                    var directories = Directory.EnumerateDirectories(domainsFolder);
                    foreach (var directory in directories)
                    {
                        var files = Directory.EnumerateFiles(directory);
                        foreach (var item in files)
                        {
                            logger.Log(" ----- new problem ----- ");
                            logger.Log(directory + "\\" + item);

                            d = new Problem(item, false);
                            //ast = new AStarSearch(d, new FFHeuristic(d));
                            ast = new AStarSearch(d, new FFHeuristic(d), ds);


                            DirectoryInfo currentDirectory = new DirectoryInfo(directory);
                            FileInfo      currentFile      = new FileInfo(item);

                            ds.Clear();

                            if (ast.OpenNodes is MeasuredHeap <PAD.Planner.IState> )
                            {
                                ((MeasuredHeap <PAD.Planner.IState>)ast.OpenNodes).SetLoggingOutputFile(currentDirectory.Name + "_" + currentFile.Name);
                            }

                            ast.TimeLimitOfSearch = timeLimit;
                            var result = ast.Start();
                            writer.WriteLine(currentDirectory.Name + "_" + currentFile.Name + "\t" + ast.GetSearchTime().TotalSeconds + "\t" + result);
                            writer.Flush();

                            logger.Log();
                        }
                        logger.Log(" ----- new domain ----- ");
                    }
                }
            }
        }