- Timestamp:
- 11/22/19 15:54:31 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveEvaluationOperator.cs
r17363 r17366 21 21 22 22 using System; 23 using System.Threading; 23 24 using HEAL.Attic; 24 25 using HeuristicLab.Core; … … 28 29 internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator<TEncodedSolution> 29 30 where TEncodedSolution : class, IEncodedSolution { 30 Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom > Evaluate { get; set; }31 Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; } 31 32 } 32 33 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs
r17363 r17366 21 21 22 22 using System; 23 using System.Threading; 23 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; … … 46 47 } 47 48 48 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom > Evaluate { get; set; }49 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; } 49 50 50 51 [StorableConstructor] … … 65 66 var solutionContext = new SingleObjectiveSolutionContextScope<TEncodedSolution>(ExecutionContext.Scope, solution); 66 67 67 Evaluate(solutionContext, random );68 Evaluate(solutionContext, random, CancellationToken.None); 68 69 var qualityValue = solutionContext.EvaluationResult.Quality; 69 70 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveImprover.cs
r17363 r17366 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; … … 63 64 } 64 65 65 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom > Evaluate { get; set; }66 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; } 66 67 public Func<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>>> GetNeighbors { get; set; } 67 68 … … 94 95 double quality; 95 96 if (QualityParameter.ActualValue == null) { 96 if (!solutionContext.IsEvaluated) Evaluate(solutionContext, random );97 if (!solutionContext.IsEvaluated) Evaluate(solutionContext, random, CancellationToken.None); 97 98 98 99 quality = solutionContext.EvaluationResult.Quality; … … 104 105 var bestQuality = quality; 105 106 foreach (var neighbor in GetNeighbors(solutionContext, random).Take(sampleSize)) { 106 Evaluate(neighbor, random );107 Evaluate(neighbor, random, CancellationToken); 107 108 var q = neighbor.EvaluationResult.Quality; 108 109 count++; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveEvaluator.cs
r17363 r17366 21 21 22 22 using System; 23 using System.Threading; 23 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; … … 50 51 } 51 52 52 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom > Evaluate { get; set; }53 public Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; } 53 54 54 55 [StorableConstructor] … … 72 73 var solutionContext = new SingleObjectiveSolutionContextScope<TEncodedSolution>(ExecutionContext.Scope, solution); 73 74 74 Evaluate(solutionContext, random );75 Evaluate(solutionContext, random, CancellationToken.None); 75 76 var qualityValue = solutionContext.EvaluationResult.Quality; 76 77 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r17363 r17366 113 113 } 114 114 115 public virtualdouble Evaluate(TEncodedSolution solution, IRandom random) {115 public double Evaluate(TEncodedSolution solution, IRandom random) { 116 116 return Evaluate(solution, random, CancellationToken.None); 117 117 } 118 118 public abstract double Evaluate(TEncodedSolution solution, IRandom random, CancellationToken cancellationToken); 119 119 120 public v irtual void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random) {120 public void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random) { 121 121 Evaluate(solutionContext, random, CancellationToken.None); 122 122 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SolutionContext.cs
r17363 r17366 63 63 } 64 64 65 public v oid SetAdditionalData(string identifier, object o) {65 public virtual void SetAdditionalData(string identifier, object o) { 66 66 data[identifier] = o; 67 67 } 68 public object GetAdditionalData(string identifier) {68 public virtual object GetAdditionalData(string identifier) { 69 69 return data[identifier]; 70 70 }
Note: See TracChangeset
for help on using the changeset viewer.