Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/11 13:00:09 (13 years ago)
Author:
svonolfe
Message:

Adapted creators to support pickup and delivery constraints (#1177)

File:
1 edited

Legend:

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

    r6713 r6759  
    3131using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3232using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     33using HeuristicLab.Problems.VehicleRouting.Variants;
    3334
    3435namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    8485      PotvinEncoding result = new PotvinEncoding(instance);
    8586
     87      IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance;
     88
    8689      List<int> customers = new List<int>();
    87       for (int i = 0; i < instance.Cities.Value; i++)
    88         customers.Add(i + 1);
     90      for (int i = 1; i <= instance.Cities.Value; i++)
     91        if(pdp == null || pdp.Demand[i] >= 0)
     92          customers.Add(i);
     93
    8994      customers.Sort(delegate(int city1, int city2)
    9095          {
     
    104109        currentTour.Stops.Insert(stopIdx, customers[index]);
    105110
     111        if (pdp != null) {
     112          stopIdx = result.FindBestInsertionPlace(currentTour, pdp.PickupDeliveryLocation[customers[index]]);
     113          currentTour.Stops.Insert(stopIdx, pdp.PickupDeliveryLocation[customers[index]]);
     114        }
     115
    106116        CVRPEvaluation evaluation = instance.Evaluate(currentTour) as CVRPEvaluation;
    107117        if (result.Tours.Count < instance.Vehicles.Value &&
    108118          ((adhereTimeWindows && !instance.Feasible(evaluation)) || ((!adhereTimeWindows) && evaluation.Overload > double.Epsilon))) {
    109           currentTour.Stops.RemoveAt(stopIdx);
     119            currentTour.Stops.Remove(customers[index]);
     120            if (pdp != null)
     121              currentTour.Stops.Remove(pdp.PickupDeliveryLocation[customers[index]]);
    110122
    111123          if(currentTour.Stops.Count > 0)
Note: See TracChangeset for help on using the changeset viewer.