- Timestamp:
- 09/15/20 13:53:11 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.PTSP/3.3/ProbabilisticTSP.cs
r17680 r17745 21 21 22 22 using System; 23 using System.Linq;24 23 using HEAL.Attic; 25 24 using HeuristicLab.Common; … … 77 76 } 78 77 79 public override void Analyze(Permutation[] solutions, double[] qualities, ResultCollection results, IRandom random) { 80 base.Analyze(solutions, qualities, results, random); 81 var max = Maximization; 78 public override void Analyze(ISingleObjectiveSolutionContext<Permutation>[] solutionContexts, IRandom random) { 79 base.Analyze(solutionContexts, random); 82 80 83 var i = !max ? qualities.Select((x, index) => new { index, Quality = x }).OrderBy(x => x.Quality).First().index 84 : qualities.Select((x, index) => new { index, Quality = x }).OrderByDescending(x => x.Quality).First().index; 81 //TODO reimplement code below using results directly 85 82 86 if (double.IsNaN(BestKnownQuality) || 87 max && qualities[i] > BestKnownQuality || 88 !max && qualities[i] < BestKnownQuality) { 89 BestKnownQuality = qualities[i]; 90 BestKnownSolution = ProbabilisticTSPData.GetSolution((Permutation)solutions[i].Clone(), qualities[i]); 91 } 83 //var max = Maximization; 92 84 93 IResult bestSolutionResult; 94 if (results.TryGetValue("Best pTSP Solution", out bestSolutionResult)) { 95 var bestSolution = bestSolutionResult.Value as ITSPSolution; 96 if (bestSolution == null || Maximization && bestSolution.TourLength.Value < qualities[i] 97 || !Maximization && bestSolution.TourLength.Value > qualities[i]) { 98 bestSolutionResult.Value = ProbabilisticTSPData.GetSolution(solutions[i], qualities[i]); 99 } 100 } else results.Add(new Result("Best pTSP Solution", ProbabilisticTSPData.GetSolution(solutions[i], qualities[i]))); 85 //var i = !max ? qualities.Select((x, index) => new { index, Quality = x }).OrderBy(x => x.Quality).First().index 86 // : qualities.Select((x, index) => new { index, Quality = x }).OrderByDescending(x => x.Quality).First().index; 87 88 //if (double.IsNaN(BestKnownQuality) || 89 // max && qualities[i] > BestKnownQuality || 90 // !max && qualities[i] < BestKnownQuality) { 91 // BestKnownQuality = qualities[i]; 92 // BestKnownSolution = ProbabilisticTSPData.GetSolution((Permutation)solutions[i].Clone(), qualities[i]); 93 //} 94 95 //IResult bestSolutionResult; 96 //if (results.TryGetValue("Best pTSP Solution", out bestSolutionResult)) { 97 // var bestSolution = bestSolutionResult.Value as ITSPSolution; 98 // if (bestSolution == null || Maximization && bestSolution.TourLength.Value < qualities[i] 99 // || !Maximization && bestSolution.TourLength.Value > qualities[i]) { 100 // bestSolutionResult.Value = ProbabilisticTSPData.GetSolution(solutions[i], qualities[i]); 101 // } 102 //} else results.Add(new Result("Best pTSP Solution", ProbabilisticTSPData.GetSolution(solutions[i], qualities[i]))); 101 103 } 102 104
Note: See TracChangeset
for help on using the changeset viewer.