Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/2521_ProblemRefactoring
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/BestScopeSolutionAnalyzer.cs

    r17226 r17383  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
    31 using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Analysis {
     
    8686      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    8787      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the solutions."));
    88       Parameters.Add(new FixedValueParameter<StringValue>("BestSolution ResultName", "The name of the result for storing the best solution.", new StringValue("Best Solution")));
     88      Parameters.Add(new FixedValueParameter<StringValue>("BestSolution ResultName", "The name of the result for storing the best solution.", new StringValue("Best Solution Scope")));
    8989      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution."));
    9090      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the solution should be stored."));
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r17382 r17383  
    4343    void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken);
    4444
    45     void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random);
    4645    void Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random);
    4746
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r17382 r17383  
    6666    }
    6767
    68     void ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    69       CompiledProblemDefinition.Analyze(individuals, qualities, results, random);
    70     }
    7168    void ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random) {
    7269      CompiledProblemDefinition.Analyze(solutionContexts, results, random);
    7370    }
    74 
    7571
    7672    IEnumerable<TEncodedSolution> ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.GetNeighbors(TEncodedSolution individual, IRandom random) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r17382 r17383  
    118118      ProblemDefinition.Analyze(solutionContexts, results, random);
    119119    }
    120     public override void Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    121       ProblemDefinition.Analyze(individuals, qualities, results, random);
    122     }
    123120
    124121    public override IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>> GetNeighbors(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random) {
  • 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.