Changeset 17363 for branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid
- Timestamp:
- 11/21/19 17:58:32 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs
r17320 r17363 23 23 using System; 24 24 using System.Collections.Generic; 25 using System.Linq; 25 26 using System.Threading; 26 27 using HEAL.Attic; … … 110 111 } 111 112 113 public void Evaluate(ISingleObjectiveSolutionContext<BinaryVector> solutionContext, IRandom random) { 114 Evaluate(solutionContext, random, CancellationToken.None); 115 } 116 public void Evaluate(ISingleObjectiveSolutionContext<BinaryVector> solutionContext, IRandom random, CancellationToken cancellationToken) { 117 double quality = Evaluate(solutionContext.EncodedSolution, random, cancellationToken); 118 solutionContext.EvaluationResult = new SingleObjectiveEvaluationResult(quality); 119 } 120 112 121 public bool Maximization { 113 122 get { … … 125 134 } 126 135 136 public void Analyze(ISingleObjectiveSolutionContext<BinaryVector>[] solutionContexts, ResultCollection results, IRandom random) { 137 var solutions = solutionContexts.Select(c => c.EncodedSolution).ToArray(); 138 var qualities = solutionContexts.Select(c => c.EvaluationResult.Quality).ToArray(); 139 Analyze(solutions, qualities, results, random); 140 } 141 127 142 public IEnumerable<BinaryVector> GetNeighbors(BinaryVector individual, IRandom random) { 128 143 return problem.GetNeighbors(individual, random); 129 144 } 145 public IEnumerable<ISingleObjectiveSolutionContext<BinaryVector>> GetNeighbors(ISingleObjectiveSolutionContext<BinaryVector> solutionContext, IRandom random) { 146 return GetNeighbors(solutionContext.EncodedSolution, random).Select(n => new SingleObjectiveSolutionContext<BinaryVector>(n)); 147 } 130 148 } 131 149 }
Note: See TracChangeset
for help on using the changeset viewer.