Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.VehicleRouting

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

    r4352 r4722  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
     25using HeuristicLab.Optimization;
    2426using HeuristicLab.Parameters;
    2527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Optimization;
    28 using System.Collections.Generic;
    2928
    3029namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3837    [StorableConstructor]
    3938    protected PotvinCrossover(bool deserializing) : base(deserializing) { }
     39    protected PotvinCrossover(PotvinCrossover original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
    4042
    4143    public PotvinCrossover() {
     
    6870    protected bool Repair(IRandom random, PotvinEncoding solution, Tour newTour) {
    6971      bool success = true;
    70      
     72
    7173      //remove duplicates from new tour     
    7274      for (int i = 0; i < newTour.Cities.Count; i++) {
     
    8082        }
    8183      }
    82       while(newTour.Cities.Contains(0))
     84      while (newTour.Cities.Contains(0))
    8385        newTour.Cities.Remove(0);
    8486
     
    108110
    109111        int route, place;
    110         if(FindInsertionPlace(solution, unrouted, out route, out place)) {
     112        if (FindInsertionPlace(solution, unrouted, out route, out place)) {
    111113          solution.Tours[route].Cities.Insert(place, unrouted);
    112114        } else {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs

    r4352 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    2725
    2826namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3230    [StorableConstructor]
    3331    private PotvinRouteBasedCrossover(bool deserializing) : base(deserializing) { }
    34 
     32    private PotvinRouteBasedCrossover(PotvinRouteBasedCrossover original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
     35    public override IDeepCloneable Clone(Cloner cloner) {
     36      return new PotvinRouteBasedCrossover(this, cloner);
     37    }
    3538    public PotvinRouteBasedCrossover()
    3639      : base() { }
    37      
     40
    3841    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    3942      PotvinEncoding child = parent2.Clone() as PotvinEncoding;
     
    5558        return child;
    5659      else {
    57         if(random.NextDouble() < 0.5)
     60        if (random.NextDouble() < 0.5)
    5861          return parent1.Clone() as PotvinEncoding;
    5962        else
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs

    r4352 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    2725
    2826namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3230    [StorableConstructor]
    3331    private PotvinSequenceBasedCrossover(bool deserializing) : base(deserializing) { }
     32    private PotvinSequenceBasedCrossover(PotvinSequenceBasedCrossover original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
     35    public override IDeepCloneable Clone(Cloner cloner) {
     36      return new PotvinSequenceBasedCrossover(this, cloner);
     37    }
    3438
    3539    public PotvinSequenceBasedCrossover()
    3640      : base() { }
    37        
     41
    3842    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    3943      PotvinEncoding child = parent1.Clone() as PotvinEncoding;
Note: See TracChangeset for help on using the changeset viewer.