Changeset 17710 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/Capacitated/CapacityRelaxationVRPAnalyzer.cs
- Timestamp:
- 08/03/20 15:50:59 (4 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.