Changeset 17710 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation
- Timestamp:
- 08/03/20 15:50:59 (4 years ago)
- 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 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Parameters; 28 using HEAL.Attic;29 29 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 30 31 using HeuristicLab.Problems.VehicleRouting.Variants; 31 32 … … 43 44 get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; } 44 45 } 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"]; } 51 48 } 52 49 … … 79 76 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance.")); 80 77 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.")); 84 79 85 80 Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5))); … … 113 108 ResultCollection results = ResultsParameter.ActualValue; 114 109 115 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 116 ItemArray<DoubleValue> overloads = OverloadParameter.ActualValue; 110 ItemArray<CVRPEvaluation> evaluations = EvaluationParameter.ActualValue; 117 111 118 112 double sigma = SigmaParameter.Value.Value; … … 121 115 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 122 116 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; 125 119 } 126 120 127 121 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) 130 124 validCount++; 131 125 } 132 126 133 double factor = 1.0 - ((double)validCount / (double) qualities.Length);127 double factor = 1.0 - ((double)validCount / (double)evaluations.Length); 134 128 135 129 double min = cvrp.OverloadPenalty.Value / (1 + sigma); … … 142 136 cvrp.CurrentOverloadPenalty.Value = maxPenalty; 143 137 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; 146 140 } 147 141 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)); 150 144 } else { 151 (res ults["Current Overload Penalty"].Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value;145 (res.Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value; 152 146 } 153 147 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs
r17698 r17710 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Parameters; 28 using HEAL.Attic;29 29 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 30 31 using HeuristicLab.Problems.VehicleRouting.Variants; 31 32 … … 43 44 get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; } 44 45 } 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"]; } 51 48 } 52 49 … … 79 76 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance.")); 80 77 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.")); 84 79 85 80 Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5))); … … 113 108 ResultCollection results = ResultsParameter.ActualValue; 114 109 115 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 116 ItemArray<IntValue> pickupViolations = PickupViolationsParameter.ActualValue; 110 ItemArray<CVRPPDTWEvaluation> evaluations = EvaluationParameter.ActualValue; 117 111 118 112 double sigma = SigmaParameter.Value.Value; … … 121 115 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 122 116 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; 125 119 } 126 120 127 121 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) 130 124 validCount++; 131 125 } 132 126 133 double factor = 1.0 - ((double)validCount / (double) qualities.Length);127 double factor = 1.0 - ((double)validCount / (double)evaluations.Length); 134 128 135 129 double min = pdp.PickupViolationPenalty.Value / (1 + sigma); … … 142 136 pdp.CurrentPickupViolationPenalty.Value = maxPenalty; 143 137 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; 146 140 } 147 141 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)); 150 144 } else { 151 (res ults["Current Pickup Violation Penalty"].Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value;145 (res.Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value; 152 146 } 153 147 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs
r17698 r17710 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Parameters; 28 using HEAL.Attic;29 29 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 30 31 using HeuristicLab.Problems.VehicleRouting.Variants; 31 32 … … 43 44 get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; } 44 45 } 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"]; } 51 48 } 52 49 … … 79 76 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance.")); 80 77 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.")); 84 79 85 80 Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5))); … … 113 108 ResultCollection results = ResultsParameter.ActualValue; 114 109 115 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 116 ItemArray<DoubleValue> tardiness = TardinessParameter.ActualValue; 110 ItemArray<CVRPTWEvaluation> evaluations = EvaluationParameter.ActualValue; 117 111 118 112 double sigma = SigmaParameter.Value.Value; … … 121 115 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 122 116 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; 125 119 } 126 120 127 121 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) 130 124 validCount++; 131 125 } 132 126 133 double factor = 1.0 - ((double)validCount / (double) qualities.Length);127 double factor = 1.0 - ((double)validCount / (double)evaluations.Length); 134 128 135 129 double min = vrptw.TardinessPenalty.Value / (1 + sigma); … … 142 136 vrptw.CurrentTardinessPenalty.Value = maxPenalty; 143 137 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; 146 140 } 147 141 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)); 150 144 } else { 151 (res ults["Current Tardiness Penalty"].Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value;145 (res.Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value; 152 146 } 153 147
Note: See TracChangeset
for help on using the changeset viewer.