private static void BuildInterpretationPlan(LGSPGraph graph) { LGSPMatcherGenerator matcherGen = new LGSPMatcherGenerator(graph.Model); graph.matchingState.patternGraph = matcherGen.BuildPatternGraph(graph); PlanGraph planGraph = matcherGen.GeneratePlanGraph(graph.statistics, graph.matchingState.patternGraph, false, false, new Dictionary <PatternElement, SetValueType>()); matcherGen.MarkMinimumSpanningArborescence(planGraph, graph.matchingState.patternGraph.name); SearchPlanGraph searchPlanGraph = matcherGen.GenerateSearchPlanGraph(planGraph); ScheduledSearchPlan scheduledSearchPlan = matcherGen.ScheduleSearchPlan( searchPlanGraph, graph.matchingState.patternGraph, false); InterpretationPlanBuilder builder = new InterpretationPlanBuilder(scheduledSearchPlan, searchPlanGraph, graph.Model); graph.matchingState.interpretationPlan = builder.BuildInterpretationPlan("ComparisonMatcher_" + graph.graphID); ++GraphMatchingState.numInterpretationPlans; graph.matchingState.changesCounterAtInterpretationPlanBuilding = graph.changesCounterAtLastAnalyze; Debug.Assert(graph.changesCounterAtLastAnalyze == graph.ChangesCounter); #if LOG_ISOMORPHY_CHECKING SourceBuilder sb = new SourceBuilder(); graph.matchingState.interpretationPlan.Dump(sb); writer.WriteLine(); writer.WriteLine(sb.ToString()); writer.WriteLine(); writer.Flush(); #endif }
/// <summary> /// Constructs a new LGSPActions instance. /// This constructor is deprecated. /// </summary> /// <param name="lgspgraph">The associated graph.</param> /// <param name="modelAsmName">The name of the model assembly.</param> /// <param name="actionsAsmName">The name of the actions assembly.</param> public LGSPActions(LGSPGraph lgspgraph, String modelAsmName, String actionsAsmName) { graph = lgspgraph; modelAssemblyName = modelAsmName; actionsAssemblyName = actionsAsmName; matcherGenerator = new LGSPMatcherGenerator(graph.Model); #if ASSERT_ALL_UNMAPPED_AFTER_MATCH OnMatched += new AfterMatchHandler(AssertAllUnmappedAfterMatch); #endif }
/// <summary> /// Constructs a new LGSPActions instance. /// </summary> /// <param name="lgspgraph">The associated graph.</param> public LGSPActions(LGSPGraph lgspgraph) { graph = lgspgraph; matcherGenerator = new LGSPMatcherGenerator(graph.Model); modelAssemblyName = Assembly.GetAssembly(graph.Model.GetType()).Location; actionsAssemblyName = Assembly.GetAssembly(this.GetType()).Location; #if ASSERT_ALL_UNMAPPED_AFTER_MATCH OnMatched += new AfterMatchHandler(AssertAllUnmappedAfterMatch); #endif }
/// <summary> /// Constructs a new LGSPActions instance. /// This constructor is deprecated. /// </summary> /// <param name="lgspgraph">The associated graph.</param> /// <param name="modelAsmName">The name of the model assembly.</param> /// <param name="actionsAsmName">The name of the actions assembly.</param> protected LGSPActions(LGSPGraph lgspgraph, String modelAsmName, String actionsAsmName) { graph = lgspgraph; modelAssemblyName = modelAsmName; actionsAssemblyName = actionsAsmName; matcherGenerator = new LGSPMatcherGenerator(graph.Model); customCommandsToDescriptions = new Dictionary <string, string>(); FillCustomCommandDescriptions(); #if ASSERT_ALL_UNMAPPED_AFTER_MATCH OnMatched += new AfterMatchHandler(AssertAllUnmappedAfterMatch); #endif }
/// <summary> /// Constructs a new LGSPActions instance. /// </summary> /// <param name="lgspgraph">The associated graph.</param> protected LGSPActions(LGSPGraph lgspgraph) { graph = lgspgraph; matcherGenerator = new LGSPMatcherGenerator(graph.Model); modelAssemblyName = Assembly.GetAssembly(graph.Model.GetType()).Location; actionsAssemblyName = Assembly.GetAssembly(this.GetType()).Location; customCommandsToDescriptions = new Dictionary <string, string>(); FillCustomCommandDescriptions(); #if ASSERT_ALL_UNMAPPED_AFTER_MATCH OnMatched += new AfterMatchHandler(AssertAllUnmappedAfterMatch); #endif }
/// <summary> /// Does action-backend dependent stuff. /// </summary> /// <param name="args">Any kind of parameters for the stuff to do; first parameter has to be the command</param> public override void Custom(params object[] args) { if (args.Length == 0) { throw new ArgumentException("No command given"); } String command = (String)args[0]; switch (command) { case "gen_searchplan": { if (graph.statistics.edgeCounts == null) { throw new ArgumentException("Graph not analyzed yet!\nPlease execute 'custom graph analyze'!"); } LGSPAction[] oldActions; if (args.Length == 1) { oldActions = new LGSPAction[actions.Count]; int i = 0; foreach (LGSPAction action in actions.Values) { oldActions[i] = action; ++i; } } else { oldActions = new LGSPAction[args.Length - 1]; for (int i = 0; i < oldActions.Length; i++) { oldActions[i] = (LGSPAction)GetAction((String)args[i + 1]); if (oldActions[i] == null) { throw new ArgumentException("'" + (String)args[i + 1] + "' is not the name of an action!\n" + "Please use 'show actions' to get a list of the available names."); } } } int startticks = Environment.TickCount; matcherGenerator.LazyNegativeIndependentConditionEvaluation = LazyNIC; matcherGenerator.InlineIndependents = InlineIndependents; matcherGenerator.Profile = Profile; LGSPAction[] newActions = matcherGenerator.GenerateActions(graph, modelAssemblyName, actionsAssemblyName, oldActions); int stopticks = Environment.TickCount; Console.Write("Searchplans for actions "); for (int i = 0; i < oldActions.Length; i++) { actions[oldActions[i].Name] = newActions[i]; if (i != 0) { Console.Write(", "); } Console.Write("'" + oldActions[i].Name + "'"); } Console.WriteLine(" generated in " + (stopticks - startticks) + " ms."); return; } case "dump_sourcecode": if (args.Length != 2) { throw new ArgumentException("Usage: dump_sourcecode <bool>\n" + "If <bool> == true, C# files will be dumped for new searchplans."); } if (!bool.TryParse((String)args[1], out matcherGenerator.DumpDynSourceCode)) { throw new ArgumentException("Illegal bool value specified: \"" + (String)args[1] + "\""); } return; case "dump_searchplan": if (args.Length != 2) { throw new ArgumentException("Usage: dump_searchplan <bool>\n" + "If <bool> == true, VCG and TXT files will be dumped for new searchplans."); } if (!bool.TryParse((String)args[1], out matcherGenerator.DumpSearchPlan)) { throw new ArgumentException("Illegal bool value specified: \"" + (String)args[1] + "\""); } return; case "explain": { if (args.Length != 2) { throw new ArgumentException("Usage: explain <name>\n" + "Explains the searchplan of the given action."); } LGSPAction action = (LGSPAction)GetAction((String)args[1]); if (action == null) { throw new ArgumentException("'" + (String)args[1] + "' is not the name of an action!\n" + "Please use 'show actions' to get a list of the available names."); } if (action.patternGraph.schedules[0] == null) { LGSPGraphStatistics graphStatistics = null; if (StatisticsPath != null) { Console.WriteLine("static search plans from " + StatisticsPath); graphStatistics = new LGSPGraphStatistics(graph.Model); GraphStatisticsParserSerializer parserSerializer = new GraphStatisticsParserSerializer(graphStatistics); parserSerializer.Parse(StatisticsPath); } else { Console.WriteLine("static search plans"); } LGSPMatcherGenerator matcherGen = new LGSPMatcherGenerator(graph.Model); matcherGen.FillInStaticSearchPlans(graphStatistics, InlineIndependents, action); } SourceBuilder sb = new SourceBuilder(); foreach (KeyValuePair <LGSPMatchingPattern, LGSPMatchingPattern> usedSubpattern in action.rulePattern.patternGraph.usedSubpatterns) { usedSubpattern.Key.patternGraph.Explain(sb, graph.Model); } action.patternGraph.Explain(sb, graph.Model); Console.WriteLine(sb.ToString()); return; } default: throw new ArgumentException("Unknown command: " + command); } }