Changeset 8720 for trunk/sources/HeuristicLab.Problems.VehicleRouting
- Timestamp:
- 10/02/12 18:59:15 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/SimilarityCalculators/VRPSimilarityCalculator.cs
r8346 r8720 92 92 93 93 public override double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution) { 94 var sol1 = leftSolution.Variables[SolutionVariableName].Value as PotvinEncoding;95 var sol2 = rightSolution.Variables[SolutionVariableName].Value as PotvinEncoding;94 var sol1 = leftSolution.Variables[SolutionVariableName].Value as IVRPEncoding; 95 var sol2 = rightSolution.Variables[SolutionVariableName].Value as IVRPEncoding; 96 96 97 return CalculateSimilarity(sol1, sol2); 97 var potvinSol1 = sol1 is PotvinEncoding ? sol1 as PotvinEncoding : PotvinEncoding.ConvertFrom(sol1, ProblemInstance); 98 var potvinSol2 = sol2 is PotvinEncoding ? sol2 as PotvinEncoding : PotvinEncoding.ConvertFrom(sol2, ProblemInstance); 99 100 return CalculateSimilarity(potvinSol1, potvinSol2); 98 101 } 99 102 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r8346 r8720 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HeuristicLab.Analysis; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; … … 112 113 set { SolutionCreatorParameter.Value = value; } 113 114 } 115 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer { 116 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); } 117 } 114 118 #endregion 115 119 … … 244 248 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); 245 249 Operators.Add(new VRPSimilarityCalculator()); 250 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer()); 246 251 247 252 IVRPCreator defaultCreator = null; … … 277 282 op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 278 283 op.ProblemInstance = ProblemInstance; 284 } 285 if (SingleObjectivePopulationDiversityAnalyzer != null) { 286 SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name; 287 SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 288 SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results"; 289 SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<VRPSimilarityCalculator>().SingleOrDefault(); 279 290 } 280 291 }
Note: See TracChangeset
for help on using the changeset viewer.