Changeset 17712 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveEvaluator.cs
- Timestamp:
- 08/04/20 07:06:39 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveEvaluator.cs
r17698 r17712 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 25 26 using HeuristicLab.Optimization; 26 27 using HeuristicLab.Parameters; 27 using HEAL.Attic;28 28 using HeuristicLab.Problems.VehicleRouting.Interfaces; 29 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 43 44 get { return (ILookupParameter<DoubleValue>)Parameters["MovePenalty"]; } 44 45 } 46 public ILookupParameter<VRPEvaluation> MoveEvaluationResultParameter { 47 get { return (ILookupParameter<VRPEvaluation>)Parameters["MoveEvaluationResult"]; } 48 } 45 49 46 50 [StorableConstructor] … … 52 56 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 53 57 Parameters.Add(new LookupParameter<DoubleValue>("MovePenalty", "The penalty applied to the move.")); 58 Parameters.Add(new LookupParameter<VRPEvaluation>("MoveEvaluationResult", "The evaluation result of the move.")); 54 59 } 55 60 … … 60 65 //helper method to evaluate an updated individual 61 66 protected void UpdateEvaluation(IVRPEncodedSolution updatedTours) { 62 IVRPEvaluator evaluator = ProblemInstance.MoveEvaluator; 63 64 try { 65 this.ExecutionContext.Scope.Variables.Add(new Variable(evaluator.VRPToursParameter.ActualName, 66 updatedTours)); 67 68 IAtomicOperation op = this.ExecutionContext.CreateChildOperation(evaluator); 69 op.Operator.Execute((IExecutionContext)op, CancellationToken); 70 } 71 finally { 72 this.ExecutionContext.Scope.Variables.Remove(evaluator.VRPToursParameter.ActualName); 73 } 67 var evaluation = ProblemInstance.Evaluate(updatedTours); 68 MoveEvaluationResultParameter.ActualValue = evaluation; 69 MoveQualityParameter.ActualValue = new DoubleValue(evaluation.Quality); 70 MovePenaltyParameter.ActualValue = new DoubleValue(evaluation.Penalty); 74 71 } 75 72
Note: See TracChangeset
for help on using the changeset viewer.