Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/11 15:40:01 (14 years ago)
Author:
svonolfe
Message:

Merged changes from trunk into branch (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r4752 r5867  
    4444      : base(original, cloner) {
    4545    }
    46    
     46
    4747    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    4848      int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    49       Tour route1 =
    50         individual.Tours[selectedIndex];
     49      Tour route1 = individual.Tours[selectedIndex];
    5150
    52       for (int customer1Position = 0; customer1Position < route1.Stops.Count; customer1Position++) {
     51      bool performed = false;
     52      int customer1Position = 0;
     53      while (customer1Position < route1.Stops.Count) {
     54        performed = false;
     55
    5356        foreach (Tour tour in individual.Tours) {
    5457          if (tour != route1) {
     
    6063              tour.Stops[customer2Position] = customer1;
    6164              if (ProblemInstance.Feasible(tour)) {
    62                 int route, place;
     65                int routeIdx, place;
    6366                if (FindInsertionPlace(individual,
    64                   customer2, selectedIndex, out route, out place)) {
    65                     individual.Tours[route].Stops.Insert(place, customer2);
    66                     route1.Stops.RemoveAt(customer1Position);
     67                  customer2, selectedIndex, out routeIdx, out place)) {
     68                  individual.Tours[routeIdx].Stops.Insert(place, customer2);
     69                  route1.Stops.RemoveAt(customer1Position);
    6770
    68                     if (route1.Stops.Count == 0)
     71                  if (route1.Stops.Count == 0)
    6972                    individual.Tours.Remove(route1);
    7073
    7174                  //two-level exchange has been performed
    72                   return;
     75                  performed = true;
     76                  break;
    7377                } else {
    7478                  tour.Stops[customer2Position] = customer2;
     
    7983            }
    8084          }
     85
     86          if (performed)
     87            break;
    8188        }
     89
     90        if (!performed)
     91          customer1Position++;
    8292      }
    8393    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveEvaluator.cs

    r5202 r5867  
    8585        string key = AdditionFrequencyMemoryKeyParameter.Value.Value;
    8686
    87         if (memory.ContainsKey(key)) {
     87        if (memory != null && memory.ContainsKey(key)) {
    8888          ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
    8989               memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveMaker.cs

    r5202 r5867  
    101101      PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;
    102102
    103       PotvinEncoding newSolution = move.Individual as PotvinEncoding;
     103      PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding;
    104104      Apply(newSolution, move);
    105105      VRPToursParameter.ActualValue = newSolution;
     
    125125      string key = AdditionFrequencyMemoryKeyParameter.Value.Value;
    126126
    127       if (!memory.ContainsKey(key)) {
    128         memory.Add(new Variable(key,
    129             new ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>()));
     127      if (memory != null) {
     128        if (!memory.ContainsKey(key)) {
     129          memory.Add(new Variable(key,
     130              new ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>()));
     131        }
     132        ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
     133          memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>;
     134
     135        PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
     136        if (!additionFrequency.ContainsKey(attr))
     137          additionFrequency[attr] = new IntValue(0);
     138
     139        additionFrequency[attr].Value++;
    130140      }
    131       ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
    132         memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>;
    133 
    134       PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
    135       if (!additionFrequency.ContainsKey(attr))
    136         additionFrequency[attr] = new IntValue(0);
    137 
    138       additionFrequency[attr].Value++;
    139141    }
    140142  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMultiMoveGenerator.cs

    r5127 r5867  
    2929using HeuristicLab.Common;
    3030using HeuristicLab.Data;
     31using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    3132
    3233namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    3334  [Item("PotvinCustomerRelocationMultiMoveGenerator", "Generates customer relocation moves from a given VRP encoding.")]
    3435  [StorableClass]
    35   public sealed class PotvinCustomerRelocationMultiMoveGenerator : PotvinCustomerRelocationMoveGenerator, IMultiMoveGenerator {
     36  public sealed class PotvinCustomerRelocationMultiMoveGenerator : PotvinCustomerRelocationMoveGenerator, IMultiMoveGenerator, IMultiVRPMoveGenerator {
    3637    public ILookupParameter<IRandom> RandomParameter {
    3738      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationSingleMoveGenerator.cs

    r5127 r5867  
    3535  [StorableClass]
    3636  public sealed class PotvinCustomerRelocationSingleMoveGenerator : PotvinCustomerRelocationMoveGenerator,
    37     ISingleMoveGenerator, IMultiVRPMoveGenerator {
     37    ISingleMoveGenerator {
    3838    #region IMultiVRPMoveOperator Members
    3939
Note: See TracChangeset for help on using the changeset viewer.