Changeset 15051 for trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
- Timestamp:
- 06/24/17 22:36:02 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r14185 r15051 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 84 85 } 85 86 87 protected Tuple<Individual, double> GetBestIndividual(Individual[] individuals, double[] qualities) { 88 return GetBestIndividual(individuals, qualities, Maximization); 89 } 90 public static Tuple<Individual, double> GetBestIndividual(Individual[] individuals, double[] qualities, bool maximization) { 91 var zipped = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }); 92 var best = (maximization ? zipped.OrderByDescending(z => z.Quality) : zipped.OrderBy(z => z.Quality)).First(); 93 return Tuple.Create(best.Individual, best.Quality); 94 } 95 86 96 protected override void OnOperatorsChanged() { 87 97 base.OnOperatorsChanged();
Note: See TracChangeset
for help on using the changeset viewer.