Changeset 17383 for branches/2521_ProblemRefactoring
- Timestamp:
- 12/18/19 16:32:41 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/BestScopeSolutionAnalyzer.cs
r17226 r17383 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 using HEAL.Attic;32 32 33 33 namespace HeuristicLab.Analysis { … … 86 86 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 87 87 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"))); 89 89 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution.")); 90 90 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 43 43 void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken); 44 44 45 void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random);46 45 void Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random); 47 46 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs
r17382 r17383 66 66 } 67 67 68 void ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {69 CompiledProblemDefinition.Analyze(individuals, qualities, results, random);70 }71 68 void ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random) { 72 69 CompiledProblemDefinition.Analyze(solutionContexts, results, random); 73 70 } 74 75 71 76 72 IEnumerable<TEncodedSolution> ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.GetNeighbors(TEncodedSolution individual, IRandom random) { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs
r17382 r17383 118 118 ProblemDefinition.Analyze(solutionContexts, results, random); 119 119 } 120 public override void Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {121 ProblemDefinition.Analyze(individuals, qualities, results, random);122 }123 120 124 121 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 31 31 32 32 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) {39 33 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 40 34 // Write or update results given the range of vectors and resulting qualities 41 35 // Uncomment the following lines if you want to retrieve the best solution 42 36 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 } 45 41 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 51 43 52 44 public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS solution, IRandom random) {
Note: See TracChangeset
for help on using the changeset viewer.