Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/17 22:36:02 (7 years ago)
Author:
abeham
Message:

#2783:

  • Implemented GetBestIndividual as public static and protected method in SingleObjectiveBasicProblem
  • Impblemented GetParetorFronts as public static and protected method in MultiObjectiveBasicProblem
  • Implemented AddOrUpdateResult as public method in ResultCollection
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs

    r14185 r15051  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    8485    }
    8586
     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
    8696    protected override void OnOperatorsChanged() {
    8797      base.OnOperatorsChanged();
Note: See TracChangeset for help on using the changeset viewer.