示例#1
0
        private static void SimilaritySolver(string resultPath, IGraph graph, ISimilarityCalculationStrategy[] calculationStrategies, GraspEdgeFinder edgeFinder)
        {
            var similaritySolver = new PathSimilaritySolver(graph,
                                                            new InitializationSolver(new TspSolver(graph), new RandomPathAlgorithm(Steps, edgeFinder)),
                                                            calculationStrategies);

            similaritySolver.Solve(new LocalSearchAlgorithm(Steps, edgeFinder));

            foreach (var similairityValue in similaritySolver.SimilairityValues)
            {
                var resultString = new StringBuilder();
                var title        = similairityValue.Key;
                var filePrinter  = new FilePrinter(resultPath, $"{title.Replace(' ', '_').Replace('|', '_')}_results.res");

                resultString.AppendLine($"{nameof(SimilaritySolverResult.Cost)} {nameof(SimilaritySolverResult.SimilarityValue)}");

                foreach (var similaritySolverResult in similairityValue.Value)
                {
                    resultString.AppendLine($"{similaritySolverResult.Cost} {similaritySolverResult.SimilarityValue:F}");
                }

                resultString.AppendLine();
                filePrinter.Print(resultString.ToString());
            }

            Console.WriteLine("SUCCES!!!");
        }
示例#2
0
        private static void RunRandomLSPathsStatistics(IGraph graph, TspSolver solver, string coordinatesPath)
        {
            var localSearchSolver = new PathSimilaritySolver(graph, new InitializationSolver(solver,
                                                                                             new RandomPathAlgorithm(Steps, new EdgeFinder())),
                                                             new ISimilarityCalculationStrategy[] { new EdgeSimillarityStrategy(), new NodeSimilarityStrategy() });
            var localSearchAlgorithm = new LocalSearchAlgorithm(Steps, new EdgeFinder());

            localSearchSolver.Solve(localSearchAlgorithm);
        }