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
Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers
Files:
3 edited

Legend:

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

    r8053 r8346  
    6363    }
    6464
    65     protected Tour FindRoute(PotvinEncoding solution, int city) {
     65    protected static Tour FindRoute(PotvinEncoding solution, int city) {
    6666      Tour found = null;
    6767
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs

    r8053 r8346  
    2424using HeuristicLab.Encodings.PermutationEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2627
    2728namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4344    }
    4445
    45     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    46       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    47 
     46    public static PotvinEncoding Apply(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2, IVRPProblemInstance problemInstance, bool allowInfeasible) {
    4847      PotvinEncoding child = parent2.Clone() as PotvinEncoding;
    4948
     
    7574            child.Unrouted.Add(city);
    7675
    77         if (Repair(random, child, replacing, ProblemInstance, allowInfeasible) || allowInfeasible)
     76        if (Repair(random, child, replacing, problemInstance, allowInfeasible) || allowInfeasible)
    7877          return child;
    7978        else {
     
    8786      }
    8887    }
     88
     89    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
     90      return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value);
     91    }
    8992  }
    9093}
  • 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.