Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/27/12 15:21:20 (12 years ago)
Author:
jkarder
Message:

#1331:

  • added operators for the VehicleRouting problem
  • minor code improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs

    r8053 r8346  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2526
    2627namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4243    }
    4344
    44     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    45       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    46 
     45    public static PotvinEncoding Apply(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2, IVRPProblemInstance problemInstance, bool allowInfeasible) {
    4746      PotvinEncoding child = parent1.Clone() as PotvinEncoding;
    4847      Tour newTour = new Tour();
    4948
    50       int cities = ProblemInstance.Cities.Value;
     49      int cities = problemInstance.Cities.Value;
    5150
    5251      if (cities > 0) {
     
    7776            child.Unrouted.Add(city);
    7877
    79         if (Repair(random, child, newTour, ProblemInstance, allowInfeasible) || allowInfeasible) {
     78        if (Repair(random, child, newTour, problemInstance, allowInfeasible) || allowInfeasible) {
    8079          return child;
    8180        } else {
     
    8988      }
    9089    }
     90
     91    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
     92      return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value);
     93    }
    9194  }
    9295}
Note: See TracChangeset for help on using the changeset viewer.