Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/20 15:50:59 (4 years ago)
Author:
abeham
Message:

#2521: working on VRP

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/Capacitated/CapacityRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<DoubleValue> OverloadParameter {
    50       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Overload"]; }
     46    public ScopeTreeLookupParameter<CVRPEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<DoubleValue> overloads = OverloadParameter.ActualValue;
     110      ItemArray<CVRPEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= overloads[j].Value * cvrp.OverloadPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].Overload * cvrp.OverloadPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (overloads[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].Overload == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = cvrp.OverloadPenalty.Value / (1 + sigma);
     
    142136        cvrp.CurrentOverloadPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += overloads[j].Value * cvrp.CurrentOverloadPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].Overload * cvrp.CurrentOverloadPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Overload Penalty")) {
    149         results.Add(new Result("Current Overload Penalty", new DoubleValue(cvrp.CurrentOverloadPenalty.Value)));
     142      if (!results.TryGetValue("Current Overload Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Overload Penalty", new DoubleValue(cvrp.CurrentOverloadPenalty.Value));
    150144      } else {
    151         (results["Current Overload Penalty"].Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value;
     145        (res.Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value;
    152146      }
    153147
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<IntValue> PickupViolationsParameter {
    50       get { return (ScopeTreeLookupParameter<IntValue>)Parameters["PickupViolations"]; }
     46    public ScopeTreeLookupParameter<CVRPPDTWEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPPDTWEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<IntValue>("PickupViolations", "The pickup violation of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPPDTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<IntValue> pickupViolations = PickupViolationsParameter.ActualValue;
     110      ItemArray<CVRPPDTWEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= pickupViolations[j].Value * pdp.PickupViolationPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].PickupViolations * pdp.PickupViolationPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (pickupViolations[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].PickupViolations == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = pdp.PickupViolationPenalty.Value / (1 + sigma);
     
    142136        pdp.CurrentPickupViolationPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += pickupViolations[j].Value * pdp.CurrentPickupViolationPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].PickupViolations * pdp.CurrentPickupViolationPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Pickup Violation Penalty")) {
    149         results.Add(new Result("Current Pickup Violation Penalty", new DoubleValue(pdp.CurrentPickupViolationPenalty.Value)));
     142      if (!results.TryGetValue("Current Pickup Violation Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Pickup Violation Penalty", new DoubleValue(pdp.CurrentPickupViolationPenalty.Value));
    150144      } else {
    151         (results["Current Pickup Violation Penalty"].Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value;
     145        (res.Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value;
    152146      }
    153147
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<DoubleValue> TardinessParameter {
    50       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Tardiness"]; }
     46    public ScopeTreeLookupParameter<CVRPTWEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPTWEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<DoubleValue> tardiness = TardinessParameter.ActualValue;
     110      ItemArray<CVRPTWEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= tardiness[j].Value * vrptw.TardinessPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].Tardiness * vrptw.TardinessPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (tardiness[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].Tardiness == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = vrptw.TardinessPenalty.Value / (1 + sigma);
     
    142136        vrptw.CurrentTardinessPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += tardiness[j].Value * vrptw.CurrentTardinessPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].Tardiness * vrptw.CurrentTardinessPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Tardiness Penalty")) {
    149         results.Add(new Result("Current Tardiness Penalty", new DoubleValue(vrptw.CurrentTardinessPenalty.Value)));
     142      if (!results.TryGetValue("Current Tardiness Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Tardiness Penalty", new DoubleValue(vrptw.CurrentTardinessPenalty.Value));
    150144      } else {
    151         (results["Current Tardiness Penalty"].Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value;
     145        (res.Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value;
    152146      }
    153147
Note: See TracChangeset for help on using the changeset viewer.