Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12000


Ignore:
Timestamp:
02/13/15 12:55:38 (10 years ago)
Author:
mkommend
Message:

#2282: Adapted analyze method to respect the maximization flag.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Binary/3.3/BinaryProblem.cs

    r11996 r12000  
    7575    public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    7676      base.Analyze(individuals, qualities, results, random);
    77       var best = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderByDescending(z => z.Quality).First();
     77      var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
     78      var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
     79
    7880      if (!results.ContainsKey("Best Solution")) {
    7981        results.Add(new Result("Best Solution", typeof(BinaryVector)));
    8082      }
    81       results["Best Solution"].Value = best.Individual.BinaryVector();
     83      results["Best Solution"].Value = (IItem)best.BinaryVector().Clone();
    8284    }
    8385
Note: See TracChangeset for help on using the changeset viewer.