Changeset 6751


Ignore:
Timestamp:
09/13/11 15:59:26 (8 years ago)
Author:
svonolfe
Message:

Fixed minor bugs in VRP operators (#1177)

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

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeMutliMoveGenerator.cs

    r6607 r6751  
    7373
    7474    protected override AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance, int lambda) {
    75       return GenerateAllMoves(individual, problemInstance, lambda, SampleSizeParameter.Value.Value, RandomParameter.ActualValue);
     75      return GenerateAllMoves(individual, problemInstance, lambda, SampleSizeParameter.ActualValue.Value, RandomParameter.ActualValue);
    7676    }
    7777  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMove.cs

    r5127 r6751  
    3030
    3131namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    32   [Item("AlbaLambdaInterchangeMove", "Item that describes a lambda move on a VRP representation.  It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
     32  [Item("PotvinCustomerRelocationMove", "Item that describes a relocation move on a VRP representation.")]
    3333  [StorableClass]
    3434  public class PotvinCustomerRelocationMove: Item, IVRPMove {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveEvaluator.cs

    r5867 r6751  
    7676
    7777      PotvinEncoding newSolution = CustomerRelocationMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding;
    78       PotvinCustomerRelocationMoveMaker.Apply(newSolution, move);
     78      PotvinCustomerRelocationMoveMaker.Apply(newSolution, move, ProblemInstance);
    7979
    8080      UpdateEvaluation(newSolution);
     
    9191          if (additionFrequency.ContainsKey(attr)) {
    9292            int frequency = additionFrequency[attr].Value;
    93             double quality = MoveQualityParameter.ActualValue.Value - MovePenaltyParameter.ActualValue.Value;
     93            double quality = MoveQualityParameter.ActualValue.Value;
    9494
    9595            MoveQualityParameter.ActualValue.Value +=
    96               LambdaParameter.Value.Value * quality * frequency * System.Math.Sqrt(ProblemInstance.Cities.Value * ProblemInstance.Vehicles.Value);
     96              LambdaParameter.Value.Value * quality * frequency;
    9797          }
    9898        }
    9999      }
    100 
    101       //Apply constraint relaxation
    102       MoveQualityParameter.ActualValue.Value += MovePenaltyParameter.ActualValue.Value * (newSolution.PenaltyFactor - 1.0);
    103100    }
    104101  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveMaker.cs

    r6607 r6751  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     30using HeuristicLab.Problems.VehicleRouting.Interfaces;
     31using HeuristicLab.Problems.VehicleRouting.Variants;
    3032
    3133namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3941    public override ILookupParameter VRPMoveParameter {
    4042         get { return CustomerRelocationMoveParameter; }
    41     }
    42 
    43     public IValueParameter<DoubleValue> SigmaParameter {
    44       get { return (IValueParameter<DoubleValue>)Parameters["Sigma"]; }
    45     }
    46 
    47     public IValueParameter<DoubleValue> MinPenaltyFactorParameter {
    48       get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    49     }
    50 
    51     public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
    52       get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
    5343    }
    5444
     
    6757      : base() {
    6858      Parameters.Add(new LookupParameter<PotvinCustomerRelocationMove>("PotvinCustomerRelocationMove", "The moves that should be made."));
    69       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
    70       Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(-1000.0)));
    71       Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(1000.0)));
    7259
    7360      Parameters.Add(new LookupParameter<VariableCollection>("Memories", "The TS memory collection."));
     
    8370    }
    8471
    85     public static void Apply(PotvinEncoding solution, PotvinCustomerRelocationMove move) {
     72    public static void Apply(PotvinEncoding solution, PotvinCustomerRelocationMove move, IVRPProblemInstance problemInstance) {
    8673      if (move.Tour >= solution.Tours.Count)
    8774        solution.Tours.Add(new Tour());
     
    9481
    9582      int place = solution.FindBestInsertionPlace(tour, move.City);
    96 
    9783      tour.Stops.Insert(place, move.City);
    9884    }
     
    10288
    10389      PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding;
    104       Apply(newSolution, move);
     90      Apply(newSolution, move, ProblemInstance);
    10591      VRPToursParameter.ActualValue = newSolution;
    10692
     
    10894      VRPEvaluation eval = ProblemInstance.Evaluate(newSolution);
    10995      MoveQualityParameter.ActualValue.Value = eval.Quality;
    110 
    111       //update penalty factor
    112       double sigma = SigmaParameter.Value.Value;
    113       if (ProblemInstance.Feasible(eval)) {
    114         newSolution.PenaltyFactor /= (1 + sigma);
    115         if (newSolution.PenaltyFactor < MinPenaltyFactorParameter.Value.Value)
    116           newSolution.PenaltyFactor = MinPenaltyFactorParameter.Value.Value;
    117       } else {
    118         newSolution.PenaltyFactor *= (1 + sigma);
    119         if (newSolution.PenaltyFactor > MaxPenaltyFactorParameter.Value.Value)
    120           newSolution.PenaltyFactor = MaxPenaltyFactorParameter.Value.Value;
    121       }
    12296
    12397      //update memory
Note: See TracChangeset for help on using the changeset viewer.