// Build a range of tree depths. public static void MultipleTrees(string domainName, int startDepth, int endDepth) { // Save the summaries of each build. List <List <Tuple <String, String> > > summaries = new List <List <Tuple <String, String> > >(); // Remember a time stamp for the top directory. string timeStamp = DateTime.Now.ToString("MM-dd-yyyy-HH-mm-tt"); // Loop through the depths. for (int depth = startDepth; depth <= endDepth; depth++) { // Build the tree and save its summary. summaries.Add(SingleTree(domainName, timeStamp, depth)); // Clear the mediator's memory. StateSpaceMediator.Clear(); } // Write the summary CSV file to disk. WriteSummary(domainName, timeStamp, summaries); // Use the CSV file to create an Excel spreadsheet and graphs of each summary element. Grapher.CreateGraphs(domainName, timeStamp, endDepth - startDepth + 2, Parser.GetTopDirectory() + @"TestLogs\" + domainName + @"\" + timeStamp + @"\", summaries); }
// Creates a single tree of specified depth without specifying a folder name. public static void BreadthFirst(string domainName, int endDepth, bool domainRevision, bool eventRevision, bool superposition) { string modifier = "vanilla"; if (domainRevision && eventRevision) { modifier = "domain-event"; } else if (domainRevision) { modifier = "domain"; } else if (eventRevision) { modifier = "event"; } else if (superposition) { modifier = "superposition"; } // Parse the domain file. Domain domain = Parser.GetDomain(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\domain.pddl", PlanType.StateSpace); // Parse the problem file. Problem problem = Parser.GetProblemWithTypes(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\prob01.pddl", domain); // Create the initial node of mediation space. MediationTree tree = new MediationTree(domain, problem, Parser.GetTopDirectory() + @"MediationTrees\Data\" + domain.Name + @"\" + modifier + @"\", domainRevision, eventRevision, superposition); // Remember the game tree path. string dataPath = Parser.GetTopDirectory() + @"TestLogs\Level\" + domainName + @"\" + modifier + @"\"; // Check each path to see if it exists. If not, create the folder. if (!File.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } TestData data = new TestData(); Stopwatch watch = new Stopwatch(); Console.WriteLine("Creating a " + modifier + " tree to level " + endDepth); // If data already exists, load it from memory. if (File.Exists(dataPath + "mediationtreedata")) { data = BinarySerializer.DeSerializeObject <TestData>(dataPath + "mediationtreedata"); } else { data.elapsedMilliseconds = 0; data.frontier = new List <int>() { 0 }; data.depth = 0; data.nodeCounter = 1; data.goalStateCount = 0; data.deadEndCount = 0; data.summarySkip = 1000; data.summaries = new List <List <Tuple <string, string> > >(); } Console.WriteLine("Beginning at level " + data.depth); Console.WriteLine("Beginning at node number " + data.nodeCounter); watch.Start(); while (endDepth - data.depth > 0 && data.frontier.Count > 0) { MediationTreeNode current = tree.GetNode(data.frontier[0]); foreach (MediationTreeEdge edge in current.Outgoing) { bool newDepth = false; MediationTreeNode child = tree.GetNode(current.Domain, current.Problem, edge); if (child.Depth > data.depth) { data.depth = child.Depth; newDepth = true; Console.WriteLine("Reached level " + data.depth); } data.nodeCounter++; if (child.IsGoal) { data.goalStateCount++; } if (child.DeadEnd) { data.deadEndCount++; } data.frontier.Add(child.ID); watch.Stop(); if (newDepth) { data.summaries.Add(CreateSummary(data)); } watch.Start(); } data.frontier.RemoveAt(0); data.elapsedMilliseconds += watch.ElapsedMilliseconds; watch.Reset(); BinarySerializer.SerializeObject <TestData>(dataPath + "mediationtreedata", data); if (data.nodeCounter % 1000 == 0) { Console.WriteLine("Reached node number " + data.nodeCounter); } watch.Start(); } watch.Stop(); int size = data.summaries.Count + 1; BinarySerializer.SerializeObject <TestData>(dataPath + "mediationtreedata", data); WriteSummary(@"\Level\" + domainName + @"\" + modifier, data.nodeCounter.ToString(), data.summaries); if (data.summaries.Count > 0) { Grapher.CreateGraphs(domainName, data.nodeCounter.ToString(), size, dataPath, data.summaries); } }