Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/19 16:32:41 (4 years ago)
Author:
mkommend
Message:

#2521: Adapted analyze methods of single-obj problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveProblem_Template.cs

    r17382 r17383  
    3131
    3232    public override void Analyze(ISingleObjectiveSolutionContext<SOLUTION_CLASS>[] solutionContexts, ResultCollection results, IRandom random) {
    33       var solutions = solutionContexts.Select(c => c.EncodedSolution).ToArray();
    34       var qualities = solutionContexts.Select(c => c.EvaluationResult.Quality).ToArray();
    35       Analyze(solutions, qualities, results, random);
    36     }
    37 
    38     public override void Analyze(SOLUTION_CLASS[] solutions, double[] qualities, ResultCollection results, IRandom random) {
    3933      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    4034      // Write or update results given the range of vectors and resulting qualities
    4135      // Uncomment the following lines if you want to retrieve the best solution
    4236
    43       //var orderedSolutions = solutions.Zip(qualities, (i, q) => new { Solution = i, Quality = q }).OrderBy(z => z.Quality);
    44       //var best = Maximization ? orderedSolutions.Last().Solution : orderedSolutions.First().Solution;
     37      //var orderedSolutions = solutionContexts.OrderBy(s => s.EvaluationResult.Quality);
     38      //var best = Maximization ? orderedSolutions.Last() : orderedSolutions.First();
     39      //results.AddOrUpdateResult("Best Solution",(IItem) best.EncodedSolution.Clone());
     40    }
    4541
    46       //if (!results.ContainsKey("Best Solution")) {
    47       //  results.Add(new Result("Best Solution", typeof(SOLUTION_CLASS)));
    48       //}
    49       //results["Best Solution"].Value = (IItem)best.Clone();
    50     }
     42
    5143
    5244    public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS solution, IRandom random) {
Note: See TracChangeset for help on using the changeset viewer.