Free cookie consent management tool by TermsFeed Policy Generator

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

Fixed minor bugs in VRP operators (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.