private IEnumerable <AnalysisResult> Analyze(Assembly assembly) { try { var internalTypeNames = assembly.DefinedTypes.Select(t => t.FullName); #if NET451 var referencedAssemblyNames = assembly.GetReferencedAssemblies().Select(x => x.Name); #else var referencedAssemblyNames = Enumerable.Empty <string>(); // not currently supported :( #endif var analysisData = new AnalysisData(referencedAssemblyNames, internalTypeNames); var runner = new HeuristicRunner(HeuristicProvider.GetAll()); return(runner.GetResults(analysisData)); } catch { if (this.failSilently) { return(null); } throw; } }
public AStar(HeuristicProvider heuristicProvider) { HeuristicFunction = heuristicProvider.Heuristic; }
static void Main(string[] args) { if (args.Length == 5) { GraphExplorer explorer = null; IFinder finder = null; string inputFile = args[2]; string outputFile = args[3]; string dataFile = args[4]; string operations = null; string solutionPath = "solution.txt"; IState solutionState; byte[] dimensions, root; (dimensions, root) = LoadInputFile(inputFile); if (File.Exists(solutionPath)) { byte[] solutionDimensions, state; (solutionDimensions, state) = LoadInputFile(solutionPath); solutionState = new NodeState(solutionDimensions, state); } else { byte limit = (byte)(dimensions[0] * dimensions[1]); byte[] solutionArray = new byte[limit]; for (byte i = 0; i < limit - 1; ++i) { solutionArray[i] = (byte)(i + 1); } solutionArray[limit - 1] = 0; solutionState = new NodeState(dimensions, solutionArray); } try { switch (args[0]) { case "bfs": finder = new BFS(); operations = args[1].ToLower(); break; case "dfs": finder = new DFS(); operations = Reverse(args[1].ToLower()); break; case "astr": HeuristicProvider heuristicProvider = null; switch (args[1]) { case "manh": heuristicProvider = new Manhattan(solutionState); break; case "hamm": heuristicProvider = new Hamming(solutionState); break; } operations = "lrud"; finder = new AStar(heuristicProvider); break; } if (Enumerable.SequenceEqual(dimensions, solutionState.Dimensions)) { explorer = GraphExplorer.CreateGraphExplorer(dimensions, root, operations.ToCharArray(), finder); explorer.TargetState = solutionState; } else { throw new NullReferenceException("root state and solution state have different dimensions"); } } catch (NullReferenceException e) { Console.WriteLine($"Wrong parameters format {Environment.NewLine}{e.Message}"); } catch (FormatException e) { Console.WriteLine($"Wrong input file format {Environment.NewLine}{e.Message}"); } string solution = explorer.TraverseForSolution(); WriteOutputFiles(outputFile, dataFile, solution, explorer); } }