Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/12/11 15:45:48 (13 years ago)
Author:
svonolfe
Message:

Fixed more isses that occured in dynamic instances (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/VehicleAssignment
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/VehicleAssignment/PotvinVehicleAssignmentMultiMoveGenerator.cs

    r6857 r6909  
    6464
    6565      for (int i = 0; i < SampleSizeParameter.ActualValue.Value; i++) {
    66         result.Add(PotvinVehicleAssignmentSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue));
     66        var move = PotvinVehicleAssignmentSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue);
     67        if(move != null)
     68          result.Add(move);
    6769      }
    6870
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/VehicleAssignment/PotvinVehicleAssignmentSingleMoveGenerator.cs

    r6857 r6909  
    6565
    6666    public static PotvinVehicleAssignmentMove Apply(PotvinEncoding individual, IVRPProblemInstance problemInstance, IRandom rand) {
    67       int tour1 = rand.Next(individual.Tours.Count);
    68       int tour2 = rand.Next(problemInstance.Vehicles.Value);
     67      if (individual.Tours.Count > 1) {
     68        int tour1 = rand.Next(individual.Tours.Count);
     69        int tour2 = rand.Next(problemInstance.Vehicles.Value);
    6970
    70       while (tour2 == tour1)
    71         tour2 = rand.Next(problemInstance.Vehicles.Value);
     71        while (tour2 == tour1)
     72          tour2 = rand.Next(problemInstance.Vehicles.Value);
    7273
    73       return new PotvinVehicleAssignmentMove(tour1, tour2, individual);
     74        return new PotvinVehicleAssignmentMove(tour1, tour2, individual);
     75      } else {
     76        return null;
     77      }
    7478    }
    7579
Note: See TracChangeset for help on using the changeset viewer.