Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/27/11 13:29:56 (13 years ago)
Author:
svonolfe
Message:

Updated interface of evaluator - added individual (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs

    r6788 r6838  
    101101
    102102      Tour currentTour = new Tour();
     103      result.Tours.Add(currentTour);
    103104
    104105      int j = random.Next(customers.Count);
     
    114115        }
    115116
    116         CVRPEvaluation evaluation = instance.Evaluate(currentTour) as CVRPEvaluation;
     117        CVRPEvaluation evaluation = instance.EvaluateTour(currentTour, result) as CVRPEvaluation;
    117118        if (result.Tours.Count < instance.Vehicles.Value &&
    118119          ((adhereTimeWindows && !instance.Feasible(evaluation)) || ((!adhereTimeWindows) && evaluation.Overload > double.Epsilon))) {
     
    132133      }
    133134
    134       if (currentTour.Stops.Count > 0)
    135         result.Tours.Add(currentTour);
     135      if (currentTour.Stops.Count == 0)
     136        result.Tours.Remove(currentTour);
    136137
    137138      return result;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs

    r6752 r6838  
    149149
    150150    private bool FindRouteInsertionPlace(
     151      PotvinEncoding individual,
    151152      Tour tour,
    152153      int city, bool allowInfeasible, out int place) {
     
    162163
    163164      double minDetour = 0;
    164       VRPEvaluation eval = ProblemInstance.Evaluate(tour);
     165      VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, individual);
    165166      bool originalFeasible = ProblemInstance.Feasible(eval);
    166167
     
    220221
    221222        Tour childTour = new Tour();
     223        child.Tours.Add(childTour);
    222224        childTour.Stops.AddRange(r1.Stops);
    223225
     
    233235
    234236        while (count < maxCount && R2.Count != 0) {
    235           PotvinEncoding newChild = child.Clone() as PotvinEncoding;
    236           newChild.Tours.Add(childTour);
    237 
    238237          int index = random.Next(R2.Count);
    239238          int city = R2[index];
     
    241240
    242241          int place = -1;
    243           bool found = FindRouteInsertionPlace(childTour, city, allowInfeasible, out place);
     242          bool found = FindRouteInsertionPlace(child, childTour, city, allowInfeasible, out place);
    244243          if (found) {
    245244            childTour.Stops.Insert(place, city);
     
    253252        }
    254253
    255         child.Tours.Add(childTour);
    256254        Repair(random, child, childTour, ProblemInstance, allowInfeasible);
    257255      }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs

    r4752 r6838  
    6969          distance = individual.GetTourLength(individual.Tours[currentTour]);
    7070          individual.Tours[currentTour].Stops.InsertRange(currentCity, toBeDeleted);
    71           if (ProblemInstance.Feasible(individual.Tours[currentTour])) {
     71          if (ProblemInstance.TourFeasible(individual.Tours[currentTour], individual)) {
    7272            double lengthIncrease =
    7373              individual.GetTourLength(individual.Tours[currentTour]) - distance;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r6796 r6838  
    6666              route1.Stops.RemoveAt(customer1Position);
    6767
    68               if (ProblemInstance.Feasible(tour)) {
     68              if (ProblemInstance.TourFeasible(tour, individual)) {
    6969                int routeIdx, place;
    7070                if (FindInsertionPlace(individual,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveMaker.cs

    r6806 r6838  
    6161    public static void InsertPair(PotvinEncoding solution, Tour tour, int source, int target, IVRPProblemInstance problemInstance, int positionToAvoid = -1, int positionToAvoid2 = -1) {
    6262      int stops = tour.Stops.Count;
    63       VRPEvaluation eval = problemInstance.Evaluate(tour);
     63      VRPEvaluation eval = problemInstance.EvaluateTour(tour, solution);
    6464      double minCosts = double.MaxValue;
    6565      int sourceLocation = -1;
     
    6868      for (int i = 0; i <= stops; i++) {
    6969        tour.Stops.Insert(i, source);
    70         VRPEvaluation tourEval = problemInstance.Evaluate(tour);
     70        VRPEvaluation tourEval = problemInstance.EvaluateTour(tour, solution);
    7171        double sourceCosts = tourEval.Quality - eval.Quality;
    7272
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r6771 r6838  
    8282      double minQuality = -1;
    8383
    84       VRPEvaluation eval = ProblemInstance.Evaluate(tour);
     84      VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, this);
    8585
    8686      for (int i = 0; i <= tour.Stops.Count; i++) {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/PrinsEncoding.cs

    r6758 r6838  
    6161
    6262          VRPEvaluation eval =
    63             ProblemInstance.Evaluate(tour);
     63            ProblemInstance.EvaluateTour(tour, this);
    6464
    6565          double cost = eval.Quality;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/ZhuEncoding.cs

    r4752 r6838  
    4343        int city = this[i] + 1;
    4444        newTour.Stops.Add(city);
    45         if (!ProblemInstance.Feasible(newTour)) {
     45        if (!ProblemInstance.TourFeasible(newTour, this)) {
    4646          newTour.Stops.Remove(city);
    4747          if (newTour.Stops.Count > 0)
Note: See TracChangeset for help on using the changeset viewer.