Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/08/20 06:34:12 (5 years ago)
Author:
abeham
Message:

#2521: Completed porting of OrienteeringProblem

  • Adapted unit tests
  • Commented non-working unit test
Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r17525 r17526  
    9090  <ItemGroup>
    9191    <Compile Include="Creators\GreedyOrienteeringTourCreator.cs" />
    92     <Compile Include="DistanceMatrix.cs" />
    9392    <Compile Include="Improvers\OrienteeringLocalImprovementOperator.cs" />
    9493    <Compile Include="Interfaces\IOrienteeringSolutionCreator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r17525 r17526  
    110110      var data = OrienteeringProblemData;
    111111
    112       var best = GetBestSolution(vectors, qualities);
    113       var score = CalculateScore(OrienteeringProblemData, best.Item1);
    114       var travelCosts = CalculateTravelCosts(OrienteeringProblemData, best.Item1);
     112      var best = GetBestSolution(vectors, qualities).Item1;
     113      var score = CalculateScore(OrienteeringProblemData, best);
     114      var travelCosts = CalculateTravelCosts(OrienteeringProblemData, best);
    115115      var quality = CalculateQuality(OrienteeringProblemData, score, travelCosts);
    116116
    117       if (BestKnownQuality == double.NaN || best.Item2 > BestKnownQuality) {
    118         BestKnownQuality = best.Item2;
    119         BestKnownSolutionParameter.ActualValue = data.GetSolution((IntegerVector)best.Item1.Clone(), quality, score, travelCosts);
     117      if (double.IsNaN(BestKnownQuality) || IsBetter(quality, BestKnownQuality)) {
     118        BestKnownQuality = quality;
     119        BestKnownSolutionParameter.ActualValue = data.GetSolution((IntegerVector)best.Clone(), quality, score, travelCosts);
    120120      }
    121121
    122122      var bestSoFar = BestOrienteeringSolutionParameter.ActualValue;
    123123     
    124       if (bestSoFar == null) {
    125         bestSoFar = data.GetSolution((IntegerVector)best.Item1.Clone(), quality, score, travelCosts);
     124      if (bestSoFar == null || IsBetter(quality, bestSoFar.Quality.Value)) {
     125        bestSoFar = data.GetSolution((IntegerVector)best.Clone(), quality, score, travelCosts);
    126126        BestOrienteeringSolutionParameter.ActualValue = bestSoFar;
    127       } else {
    128         if (IsBetter(best.Item2, bestSoFar.Quality.Value)) {
    129           bestSoFar.Route = (IntegerVector)best.Item1.Clone();
    130           bestSoFar.Quality.Value = quality;
    131           bestSoFar.Score.Value = score;
    132           bestSoFar.TravelCosts.Value = travelCosts;
    133         }
    134127      }
    135128    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/OrienteeringSolution.cs

    r17525 r17526  
    101101      : base(original, cloner) {
    102102      this.route = cloner.Clone(original.route);
     103      this.routeAsPermutation = cloner.Clone(original.routeAsPermutation);
    103104      this.opData = cloner.Clone(original.opData);
    104105      this.quality = cloner.Clone(original.quality);
     
    110111      : base() {
    111112      this.route = route;
     113      this.routeAsPermutation = new Permutation(PermutationTypes.RelativeDirected, route);
    112114      this.opData = opData;
    113115      this.quality = quality;
Note: See TracChangeset for help on using the changeset viewer.