Example #1
0
        public static void ReadAgentFiles(DirectoryInfo dir, string sOutputFile)
        {
            Console.WriteLine("Reading files " + dir.Name);
            List <string> lDomainFiles  = new List <string>();
            List <string> lProblemFiles = new List <string>();

            foreach (FileInfo fi in dir.GetFiles())
            {
                if (fi.Name.Contains("domain"))
                {
                    lDomainFiles.Add(fi.FullName);
                }
                if (fi.Name.Contains("problem"))
                {
                    lProblemFiles.Add(fi.FullName);
                }
            }
            //try
            {
                Domain.ResetStaticVar();
                List <Domain>  lDomains  = new List <Domain>();
                List <Problem> lProblems = new List <Problem>();
                Domain         dJoint    = null;
                Problem        pJoint    = null;
                Runner.ReadAgentFiles(lDomainFiles, lProblemFiles, lDomains, lProblems);
                GetJointDomain(lDomains, lProblems, out dJoint, out pJoint);
                pdbPath = @"PdbFiles/" + dir.Parent.Name;
                if (!Directory.Exists(pdbPath))
                {
                    Directory.CreateDirectory(pdbPath);
                }
                pdbPath += "/" + dir.Name + ".pdb";
                List <Agent>  agents = null;
                List <string> lPlan  = SolveFactored(lDomains, lProblems, ref agents, dJoint);
                //Program.projResults.WriteLine(
                if (lPlan != null)
                {
                    if (Program.VerifyPlan(dJoint, pJoint, lPlan))
                    {
                        Program.PlanMakeSpan = Program.MaxMakespanCalculation(agents, lPlan, dJoint);
                        Program.WritePlanToFile(lPlan, sOutputFile);
                        Program.WriteResults(dir.Name, " success");
                    }
                    else
                    {
                        Program.WriteResults(dir.Name, " plan verification failed - could not solve the problem :(");
                    }
                    Console.WriteLine();
                }
                else
                {
                    Program.WritePlanToFile(new List <string>(), sOutputFile);
                    Program.WriteResults(dir.Name, " fail, plan is null");
                }
            }
            //catch (Exception e)
            {
                //WriteResults(dir.Name , " fail, " + e.Message + ", " + e.StackTrace);
            }
        }