Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/02/12 18:59:15 (12 years ago)
Author:
jkarder
Message:

#1899: applied the changes suggested by ascheibe in comment:6:ticket:1899

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  
    9292
    9393    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;
    9696
    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);
    98101    }
    99102  }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r8346 r8720  
    2424using System.Drawing;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    112113      set { SolutionCreatorParameter.Value = value; }
    113114    }
     115    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     116      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
     117    }
    114118    #endregion
    115119
     
    244248          ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name));
    245249        Operators.Add(new VRPSimilarityCalculator());
     250        Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
    246251
    247252        IVRPCreator defaultCreator = null;
     
    277282          op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
    278283          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();
    279290        }
    280291      }
Note: See TracChangeset for help on using the changeset viewer.