Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4186


Ignore:
Timestamp:
08/10/10 17:40:41 (14 years ago)
Author:
svonolfe
Message:

Added some Potvin operators (RBX, SBX, LSM) (#1039)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3
Files:
3 added
5 edited

Legend:

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

    r4179 r4186  
    5151        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
    5252        city, -1, out route, out place);
     53    }
     54
     55    protected Tour FindRoute(PotvinEncoding solution, int city) {
     56      Tour found = null;
     57
     58      foreach (Tour tour in solution.Tours) {
     59        if (tour.Cities.Contains(city)) {
     60          found = tour;
     61          break;
     62        }
     63      }
     64
     65      return found;
    5366    }
    5467
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/SequenceBasedCrossover.cs

    r4179 r4186  
    3535    public SequenceBasedCrossover()
    3636      : base() { }
    37    
    38     private Tour FindRoute(PotvinEncoding solution, int city) {
    39       Tour found = null;
    40 
    41       foreach (Tour tour in solution.Tours) {
    42         if (tour.Cities.Contains(city)) {
    43           found = tour;
    44           break;
    45         }
    46       }
    47 
    48       return found;
    49     }
    50    
     37       
    5138    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    5239      PotvinEncoding child = parent1.Clone() as PotvinEncoding;
     
    7865          child.Unrouted.Add(city);
    7966
    80       if (Repair(random, child, newTour))
     67      if (Feasible(newTour) &&
     68          Repair(random, child, newTour)) {
    8169        return child;
    82       else {
    83         if(random.NextDouble() < 0.5)
     70      } else {
     71        if (random.NextDouble() < 0.5)
    8472          return parent1.Clone() as PotvinEncoding;
    8573        else
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/TwoLevelExchangeManipulator.cs

    r4179 r4186  
    2828
    2929namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    30   [Item("TwoLevelExchangeOperator", "The 2M operator which manipulates a Potvin VRP representation.  It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")]
     30  [Item("TwoLevelExchangeManipulator", "The 2M operator which manipulates a Potvin VRP representation.  It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")]
    3131  [StorableClass]
    32   public sealed class TwoLevelExchangeOperator : PotvinManipulator {
     32  public sealed class TwoLevelExchangeManipulator : PotvinManipulator {
    3333    [StorableConstructor]
    34     private TwoLevelExchangeOperator(bool deserializing) : base(deserializing) { }
     34    private TwoLevelExchangeManipulator(bool deserializing) : base(deserializing) { }
    3535
    36     public TwoLevelExchangeOperator(): base() { }
     36    public TwoLevelExchangeManipulator() : base() { }
    3737   
    3838    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4183 r4186  
    110110    <Compile Include="Encodings\General\Crossovers\MultiVRPCrossover.cs" />
    111111    <Compile Include="Encodings\General\Creators\RandomCreator.cs" />
     112    <Compile Include="Encodings\Potvin\Crossovers\SequenceBasedCrossover2.cs" />
     113    <Compile Include="Encodings\Potvin\Crossovers\RouteBasedCrossover.cs" />
    112114    <Compile Include="Encodings\Potvin\Crossovers\SequenceBasedCrossover.cs" />
    113115    <Compile Include="Encodings\Potvin\Crossovers\PotvinCrossover.cs" />
     116    <Compile Include="Encodings\Potvin\Manipulators\LocalSearchManipulator.cs" />
    114117    <Compile Include="Encodings\Potvin\Manipulators\TwoLevelExchangeManipulator.cs" />
    115118    <Compile Include="Encodings\Potvin\Manipulators\OneLevelExchangeManipulator.cs" />
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs

    r4179 r4186  
    137137    }
    138138
     139    protected bool Feasible(IVRPEncoding solution) {
     140      bool feasible = true;
     141
     142      foreach (Tour tour in solution.Tours) {
     143        if (!Feasible(tour)) {
     144          feasible = false;
     145          break;
     146        }
     147      }
     148
     149      return feasible;
     150    }
     151
    139152    protected double GetLength(Tour tour) {
    140153      return tour.GetLength(
Note: See TracChangeset for help on using the changeset viewer.