Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8497


Ignore:
Timestamp:
08/17/12 14:32:54 (12 years ago)
Author:
svonolfe
Message:

Fixed behavior of VRP analyzers related to constraint relaxation (#1177)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/Capacitated/BestCapacitatedVRPSolutionAnalyzer.cs

    r8053 r8497  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    8788
    8889    public override IOperation Apply() {
     90      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    8991      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9092      ResultCollection results = ResultsParameter.ActualValue;
     
    100102          results.Add(new Result("Best VRP Solution Overload", new DoubleValue(overloads[i].Value)));
    101103        } else {
    102           if (qualities[i].Value <= solution.Quality.Value) {
     104          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     105          if (qualities[i].Value <= eval.Quality) {
    103106            (results["Best VRP Solution Overload"].Value as DoubleValue).Value = overloads[i].Value;
    104107          }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/PickupAndDelivery/BestPickupAndDeliveryVRPSolutionAnalyzer.cs

    r8053 r8497  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    8788
    8889    public override IOperation Apply() {
     90      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    8991      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9092      ResultCollection results = ResultsParameter.ActualValue;
     
    101103          results.Add(new Result("Best VRP Solution PickupViolations", new DoubleValue(pickupViolations[i].Value)));
    102104        } else {
    103           if (qualities[i].Value <= solution.Quality.Value) {
     105          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     106          if (qualities[i].Value <= eval.Quality) {
    104107            (results["Best VRP Solution PickupViolations"].Value as DoubleValue).Value = pickupViolations[i].Value;
    105108          }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/TimeWindowed/BestTimeWindowedVRPSolutionAnalyzer.cs

    r8053 r8497  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    9192
    9293    public override IOperation Apply() {
     94      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    9395      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9496      ResultCollection results = ResultsParameter.ActualValue;
     
    106108          results.Add(new Result("Best VRP Solution TravelTime", new DoubleValue(travelTimes[i].Value)));
    107109        } else {
    108           if (qualities[i].Value <= solution.Quality.Value) {
     110          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     111          if (qualities[i].Value <= eval.Quality) {
    109112            (results["Best VRP Solution Tardiness"].Value as DoubleValue).Value = tardinesses[i].Value;
    110113            (results["Best VRP Solution TravelTime"].Value as DoubleValue).Value = travelTimes[i].Value;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/Capacitated/CapacityRelaxationVRPAnalyzer.cs

    r8053 r8497  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      ICapacitatedProblemInstance cvrp = ProblemInstanceParameter.ActualValue as ICapacitatedProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (cvrp.OverloadPenalty.Value < minPenalty)
    125140        cvrp.OverloadPenalty.Value = minPenalty;
     141      if (cvrp.OverloadPenalty.Value > maxPenalty)
     142        cvrp.OverloadPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs

    r8053 r8497  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<IntValue>("PickupViolations", "The pickup violation of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      IPickupAndDeliveryProblemInstance pdp = ProblemInstanceParameter.ActualValue as IPickupAndDeliveryProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (pdp.PickupViolationPenalty.Value < minPenalty)
    125140        pdp.PickupViolationPenalty.Value = minPenalty;
     141      if (pdp.PickupViolationPenalty.Value > maxPenalty)
     142        pdp.PickupViolationPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs

    r8053 r8497  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      ITimeWindowedProblemInstance vrptw = ProblemInstanceParameter.ActualValue as ITimeWindowedProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (vrptw.TardinessPenalty.Value < minPenalty)
    125140        vrptw.TardinessPenalty.Value = minPenalty;
     141      if (vrptw.TardinessPenalty.Value > maxPenalty)
     142        vrptw.TardinessPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
Note: See TracChangeset for help on using the changeset viewer.