Changeset 15168 for trunk/sources/HeuristicLab.Problems.VehicleRouting
- Timestamp:
- 07/07/17 12:51:24 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MDCVRP/MDCVRPProblemInstance.cs
r14185 r15168 110 110 111 111 private void AttachEventHandlers() { 112 CapacityParameter.ValueChanged += new EventHandler(CapacityParameter_ValueChanged); 113 OverloadPenaltyParameter.ValueChanged += new EventHandler(OverloadPenaltyParameter_ValueChanged); 114 OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged); 112 CapacityParameter.ValueChanged += CapacityParameter_ValueChanged; 113 Capacity.Reset += Capacity_Changed; 114 Capacity.ItemChanged += Capacity_Changed; 115 OverloadPenaltyParameter.ValueChanged += OverloadPenaltyParameter_ValueChanged; 116 OverloadPenalty.ValueChanged += OverloadPenalty_ValueChanged; 115 117 } 116 118 … … 123 125 #region Event handlers 124 126 void CapacityParameter_ValueChanged(object sender, EventArgs e) { 127 Capacity.Reset += Capacity_Changed; 128 Capacity.ItemChanged += Capacity_Changed; 129 EvalBestKnownSolution(); 130 } 131 private void Capacity_Changed(object sender, EventArgs e) { 125 132 EvalBestKnownSolution(); 126 133 } 127 134 void OverloadPenaltyParameter_ValueChanged(object sender, EventArgs e) { 128 OverloadPenalty Parameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged);135 OverloadPenalty.ValueChanged += OverloadPenalty_ValueChanged; 129 136 EvalBestKnownSolution(); 130 137 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MDCVRP/MDCVRPTW/MDCVRPPDTW/MDCVRPPDTWProblemInstance.cs
r14185 r15168 117 117 118 118 private void AttachEventHandlers() { 119 PickupDeliveryLocationParameter.ValueChanged += new EventHandler(PickupDeliveryLocationParameter_ValueChanged); 119 PickupDeliveryLocationParameter.ValueChanged += PickupDeliveryLocationParameter_ValueChanged; 120 PickupDeliveryLocation.Reset += PickupDeliveryLocation_Changed; 121 PickupDeliveryLocation.ItemChanged += PickupDeliveryLocation_Changed; 122 PickupViolationPenaltyParameter.ValueChanged += PickupViolationPenaltyParameter_ValueChanged; 123 PickupViolationPenalty.ValueChanged += PickupViolationPenalty_Changed; 120 124 } 121 125 … … 128 132 #region Event handlers 129 133 void PickupDeliveryLocationParameter_ValueChanged(object sender, EventArgs e) { 130 PickupDeliveryLocationParameter.Value.ItemChanged += new EventHandler<EventArgs<int>>(Value_ItemChanged); 134 PickupDeliveryLocation.Reset += PickupDeliveryLocation_Changed; 135 PickupDeliveryLocation.ItemChanged += PickupDeliveryLocation_Changed; 131 136 EvalBestKnownSolution(); 132 137 } 133 134 void Value_ItemChanged(object sender, EventArgs<int> e) { 138 private void PickupDeliveryLocation_Changed(object sender, EventArgs e) { 139 EvalBestKnownSolution(); 140 } 141 private void PickupViolationPenaltyParameter_ValueChanged(object sender, EventArgs e) { 142 PickupViolationPenalty.ValueChanged += PickupViolationPenalty_Changed; 143 EvalBestKnownSolution(); 144 } 145 private void PickupViolationPenalty_Changed(object sender, EventArgs e) { 135 146 EvalBestKnownSolution(); 136 147 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MDCVRP/MDCVRPTW/MDCVRPTWProblemInstance.cs
r14185 r15168 136 136 137 137 private void AttachEventHandlers() { 138 TardinessPenaltyParameter.ValueChanged += new EventHandler(TardinessPenaltyParameter_ValueChanged); 139 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 140 TimeFactorParameter.ValueChanged += new EventHandler(TimeFactorParameter_ValueChanged); 141 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 138 ReadyTimeParameter.ValueChanged += ReadyTimeParameter_ValueChanged; 139 ReadyTime.Reset += ReadyTime_Changed; 140 ReadyTime.ItemChanged += ReadyTime_Changed; 141 DueTimeParameter.ValueChanged += DueTimeParameter_ValueChanged; 142 DueTime.Reset += DueTime_Changed; 143 DueTime.ItemChanged += DueTime_Changed; 144 ServiceTimeParameter.ValueChanged += ServiceTimeParameter_ValueChanged; 145 ServiceTime.Reset += ServiceTime_Changed; 146 ServiceTime.ItemChanged += ServiceTime_Changed; 147 TardinessPenaltyParameter.ValueChanged += TardinessPenaltyParameter_ValueChanged; 148 TardinessPenalty.ValueChanged += TardinessPenalty_ValueChanged; 149 TimeFactorParameter.ValueChanged += TimeFactorParameter_ValueChanged; 150 TimeFactor.ValueChanged += TimeFactor_ValueChanged; 142 151 } 143 152 … … 149 158 150 159 #region Event handlers 151 void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) { 152 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 153 EvalBestKnownSolution(); 154 } 155 void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 156 EvalBestKnownSolution(); 157 } 158 void TimeFactorParameter_ValueChanged(object sender, EventArgs e) { 159 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 160 EvalBestKnownSolution(); 161 } 162 void TimeFactor_ValueChanged(object sender, EventArgs e) { 160 private void ReadyTimeParameter_ValueChanged(object sender, EventArgs e) { 161 ReadyTime.Reset += ReadyTime_Changed; 162 ReadyTime.ItemChanged += ReadyTime_Changed; 163 EvalBestKnownSolution(); 164 } 165 private void ReadyTime_Changed(object sender, EventArgs e) { 166 EvalBestKnownSolution(); 167 } 168 private void DueTimeParameter_ValueChanged(object sender, EventArgs e) { 169 DueTime.Reset += DueTime_Changed; 170 DueTime.ItemChanged += DueTime_Changed; 171 EvalBestKnownSolution(); 172 } 173 private void DueTime_Changed(object sender, EventArgs e) { 174 EvalBestKnownSolution(); 175 } 176 private void ServiceTimeParameter_ValueChanged(object sender, EventArgs e) { 177 ServiceTime.Reset += ServiceTime_Changed; 178 ServiceTime.ItemChanged += ServiceTime_Changed; 179 EvalBestKnownSolution(); 180 } 181 private void ServiceTime_Changed(object sender, EventArgs e) { 182 EvalBestKnownSolution(); 183 } 184 private void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) { 185 TardinessPenalty.ValueChanged += TardinessPenalty_ValueChanged; 186 EvalBestKnownSolution(); 187 } 188 private void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 189 EvalBestKnownSolution(); 190 } 191 private void TimeFactorParameter_ValueChanged(object sender, EventArgs e) { 192 TimeFactor.ValueChanged += TimeFactor_ValueChanged; 193 EvalBestKnownSolution(); 194 } 195 private void TimeFactor_ValueChanged(object sender, EventArgs e) { 163 196 EvalBestKnownSolution(); 164 197 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MultiDepotVRPProblemInstance.cs
r14185 r15168 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 174 175 [StorableConstructor] 175 176 protected MultiDepotVRPProblemInstance(bool deserializing) : base(deserializing) { } 176 177 protected MultiDepotVRPProblemInstance(MultiDepotVRPProblemInstance original, Cloner cloner) 178 : base(original, cloner) { 179 AttachEventHandlers(); 180 } 177 181 public MultiDepotVRPProblemInstance() { 178 182 Parameters.Add(new ValueParameter<IntValue>("Depots", "The number of depots", new IntValue(0))); 179 183 Parameters.Add(new ValueParameter<IntArray>("VehicleDepotAssignment", "The assignment of vehicles to depots", new IntArray())); 184 AttachEventHandlers(); 180 185 } 181 186 … … 184 189 } 185 190 186 protected MultiDepotVRPProblemInstance(MultiDepotVRPProblemInstance original, Cloner cloner) 187 : base(original, cloner) { 188 } 191 [StorableHook(HookType.AfterDeserialization)] 192 private void AfterDeserialization() { 193 AttachEventHandlers(); 194 } 195 196 private void AttachEventHandlers() { 197 DepotsParameter.ValueChanged += DepotsParameter_ValueChanged; 198 Depots.ValueChanged += Depots_ValueChanged; 199 VehicleDepotAssignmentParameter.ValueChanged += VehicleDepotAssignmentParameter_ValueChanged; 200 VehicleDepotAssignment.Reset += VehicleDepotAssignment_Changed; 201 VehicleDepotAssignment.ItemChanged += VehicleDepotAssignment_Changed; 202 } 203 204 #region Event handlers 205 private void DepotsParameter_ValueChanged(object sender, EventArgs e) { 206 Depots.ValueChanged += Depots_ValueChanged; 207 EvalBestKnownSolution(); 208 } 209 private void Depots_ValueChanged(object sender, EventArgs e) { 210 EvalBestKnownSolution(); 211 } 212 private void VehicleDepotAssignmentParameter_ValueChanged(object sender, EventArgs e) { 213 VehicleDepotAssignment.Reset += VehicleDepotAssignment_Changed; 214 VehicleDepotAssignment.ItemChanged += VehicleDepotAssignment_Changed; 215 EvalBestKnownSolution(); 216 } 217 private void VehicleDepotAssignment_Changed(object sender, EventArgs e) { 218 EvalBestKnownSolution(); 219 } 220 #endregion 189 221 } 190 222 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPPDTW/CVRPPDTWProblemInstance.cs
r14185 r15168 117 117 118 118 private void AttachEventHandlers() { 119 PickupDeliveryLocationParameter.ValueChanged += new EventHandler(PickupDeliveryLocationParameter_ValueChanged); 119 PickupDeliveryLocationParameter.ValueChanged += PickupDeliveryLocationParameter_ValueChanged; 120 PickupDeliveryLocation.Reset += PickupDeliveryLocation_Changed; 121 PickupDeliveryLocation.ItemChanged += PickupDeliveryLocation_Changed; 120 122 } 121 123 … … 128 130 #region Event handlers 129 131 void PickupDeliveryLocationParameter_ValueChanged(object sender, EventArgs e) { 130 PickupDeliveryLocationParameter.Value.ItemChanged += new EventHandler<EventArgs<int>>(Value_ItemChanged); 132 PickupDeliveryLocation.Reset += PickupDeliveryLocation_Changed; 133 PickupDeliveryLocation.ItemChanged += PickupDeliveryLocation_Changed; 131 134 EvalBestKnownSolution(); 132 135 } 133 134 void Value_ItemChanged(object sender, EventArgs<int> e) { 136 private void PickupDeliveryLocation_Changed(object sender, EventArgs e) { 135 137 EvalBestKnownSolution(); 136 138 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWProblemInstance.cs
r14185 r15168 136 136 137 137 private void AttachEventHandlers() { 138 TardinessPenaltyParameter.ValueChanged += new EventHandler(TardinessPenaltyParameter_ValueChanged); 139 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 140 TimeFactorParameter.ValueChanged += new EventHandler(TimeFactorParameter_ValueChanged); 141 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 138 ReadyTimeParameter.ValueChanged += ReadyTimeParameter_ValueChanged; 139 ReadyTime.Reset += ReadyTime_Changed; 140 ReadyTime.ItemChanged += ReadyTime_Changed; 141 DueTimeParameter.ValueChanged += DueTimeParameter_ValueChanged; 142 DueTime.Reset += DueTime_Changed; 143 DueTime.ItemChanged += DueTime_Changed; 144 ServiceTimeParameter.ValueChanged += ServiceTimeParameter_ValueChanged; 145 ServiceTime.Reset += ServiceTime_Changed; 146 ServiceTime.ItemChanged += ServiceTime_Changed; 147 TardinessPenaltyParameter.ValueChanged += TardinessPenaltyParameter_ValueChanged; 148 TardinessPenalty.ValueChanged += TardinessPenalty_ValueChanged; 149 TimeFactorParameter.ValueChanged += TimeFactorParameter_ValueChanged; 150 TimeFactor.ValueChanged += TimeFactor_ValueChanged; 142 151 } 143 152 … … 149 158 150 159 #region Event handlers 151 void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) { 152 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 153 EvalBestKnownSolution(); 154 } 155 void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 156 EvalBestKnownSolution(); 157 } 158 void TimeFactorParameter_ValueChanged(object sender, EventArgs e) { 159 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 160 EvalBestKnownSolution(); 161 } 162 void TimeFactor_ValueChanged(object sender, EventArgs e) { 160 private void ReadyTimeParameter_ValueChanged(object sender, EventArgs e) { 161 ReadyTime.Reset += ReadyTime_Changed; 162 ReadyTime.ItemChanged += ReadyTime_Changed; 163 EvalBestKnownSolution(); 164 } 165 private void ReadyTime_Changed(object sender, EventArgs e) { 166 EvalBestKnownSolution(); 167 } 168 private void DueTimeParameter_ValueChanged(object sender, EventArgs e) { 169 DueTime.Reset += DueTime_Changed; 170 DueTime.ItemChanged += DueTime_Changed; 171 EvalBestKnownSolution(); 172 } 173 private void DueTime_Changed(object sender, EventArgs e) { 174 EvalBestKnownSolution(); 175 } 176 private void ServiceTimeParameter_ValueChanged(object sender, EventArgs e) { 177 ServiceTime.Reset += ServiceTime_Changed; 178 ServiceTime.ItemChanged += ServiceTime_Changed; 179 EvalBestKnownSolution(); 180 } 181 private void ServiceTime_Changed(object sender, EventArgs e) { 182 EvalBestKnownSolution(); 183 } 184 private void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) { 185 TardinessPenaltyParameter.Value.ValueChanged += TardinessPenalty_ValueChanged; 186 EvalBestKnownSolution(); 187 } 188 private void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 189 EvalBestKnownSolution(); 190 } 191 private void TimeFactorParameter_ValueChanged(object sender, EventArgs e) { 192 TimeFactorParameter.Value.ValueChanged += TimeFactor_ValueChanged; 193 EvalBestKnownSolution(); 194 } 195 private void TimeFactor_ValueChanged(object sender, EventArgs e) { 163 196 EvalBestKnownSolution(); 164 197 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r14482 r15168 280 280 281 281 private void AttachEventHandlers() { 282 DistanceFactorParameter.ValueChanged += new EventHandler(DistanceFactorParameter_ValueChanged); 283 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged); 284 FleetUsageFactorParameter.ValueChanged += new EventHandler(FleetUsageFactorParameter_ValueChanged); 285 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged); 286 DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged); 282 CoordinatesParameter.ValueChanged += CoordinatesParameter_ValueChanged; 283 Coordinates.Reset += Coordinates_Changed; 284 Coordinates.ItemChanged += Coordinates_Changed; 285 DemandParameter.ValueChanged += DemandParameter_ValueChanged; 286 Demand.Reset += Demand_Changed; 287 Demand.ItemChanged += Demand_Changed; 288 VehiclesParameter.ValueChanged += VehiclesParameter_ValueChanged; 289 VehiclesParameter.Value.ValueChanged += Vehicles_Changed; 290 DistanceFactorParameter.ValueChanged += DistanceFactorParameter_ValueChanged; 291 DistanceFactorParameter.Value.ValueChanged += DistanceFactor_ValueChanged; 292 FleetUsageFactorParameter.ValueChanged += FleetUsageFactorParameter_ValueChanged; 293 FleetUsageFactorParameter.Value.ValueChanged += FleetUsageFactor_ValueChanged; 294 DistanceMatrixParameter.ValueChanged += DistanceMatrixParameter_ValueChanged; 287 295 if (DistanceMatrix != null) { 288 DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged);289 DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset);290 } 291 UseDistanceMatrixParameter.ValueChanged += new EventHandler(UseDistanceMatrixParameter_ValueChanged);292 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged);296 DistanceMatrix.ItemChanged += DistanceMatrix_ItemChanged; 297 DistanceMatrix.Reset += DistanceMatrix_Reset; 298 } 299 UseDistanceMatrixParameter.ValueChanged += UseDistanceMatrixParameter_ValueChanged; 300 UseDistanceMatrix.ValueChanged += UseDistanceMatrix_ValueChanged; 293 301 } 294 302 … … 300 308 301 309 #region Event handlers 310 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { 311 if (distanceMatrix != null) distanceMatrix = null; 312 if (DistanceMatrix != null && DistanceMatrix.Rows != Coordinates.Rows) DistanceMatrix = null; 313 Coordinates.Reset += Coordinates_Changed; 314 Coordinates.ItemChanged += Coordinates_Changed; 315 EvalBestKnownSolution(); 316 } 317 private void Coordinates_Changed(object sender, EventArgs e) { 318 if (distanceMatrix != null) distanceMatrix = null; 319 if (DistanceMatrix != null && DistanceMatrix.Rows != Coordinates.Rows) DistanceMatrix = null; 320 EvalBestKnownSolution(); 321 } 322 private void DemandParameter_ValueChanged(object sender, EventArgs e) { 323 Demand.Reset += Demand_Changed; 324 Demand.ItemChanged += Demand_Changed; 325 EvalBestKnownSolution(); 326 } 327 private void Demand_Changed(object sender, EventArgs e) { 328 EvalBestKnownSolution(); 329 } 330 private void VehiclesParameter_ValueChanged(object sender, EventArgs e) { 331 Vehicles.ValueChanged += Vehicles_Changed; 332 EvalBestKnownSolution(); 333 } 334 private void Vehicles_Changed(object sender, EventArgs e) { 335 EvalBestKnownSolution(); 336 } 302 337 void DistanceFactorParameter_ValueChanged(object sender, EventArgs e) { 303 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged);338 DistanceFactorParameter.Value.ValueChanged += DistanceFactor_ValueChanged; 304 339 EvalBestKnownSolution(); 305 340 } … … 308 343 } 309 344 void FleetUsageFactorParameter_ValueChanged(object sender, EventArgs e) { 310 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged);345 FleetUsageFactorParameter.Value.ValueChanged += FleetUsageFactor_ValueChanged; 311 346 EvalBestKnownSolution(); 312 347 } … … 316 351 void DistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 317 352 if (DistanceMatrix != null) { 318 DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged);319 DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset);353 DistanceMatrix.ItemChanged += DistanceMatrix_ItemChanged; 354 DistanceMatrix.Reset += DistanceMatrix_Reset; 320 355 } 321 356 distanceMatrix = DistanceMatrix; … … 330 365 } 331 366 void UseDistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 332 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged);367 UseDistanceMatrix.ValueChanged += UseDistanceMatrix_ValueChanged; 333 368 if (!UseDistanceMatrix.Value) 334 369 distanceMatrix = null; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r15069 r15168 194 194 195 195 private void EvalBestKnownSolution() { 196 if (BestKnownSolution != null) { 196 if (BestKnownSolution == null) return; 197 try { 197 198 //call evaluator 198 199 BestKnownQuality = new DoubleValue(ProblemInstance.Evaluate(BestKnownSolution.Solution).Quality); 199 200 BestKnownSolution.Quality = BestKnownQuality; 201 } catch { 202 BestKnownQuality = null; 203 BestKnownSolution = null; 200 204 } 201 205 } … … 207 211 void ProblemInstance_EvaluationChanged(object sender, EventArgs e) { 208 212 BestKnownQuality = null; 209 EvalBestKnownSolution(); 213 if (BestKnownSolution != null) { 214 // the tour is not valid if there are more vehicles in it than allowed 215 if (ProblemInstance.Vehicles.Value < BestKnownSolution.Solution.GetTours().Count) { 216 BestKnownSolution = null; 217 } else EvalBestKnownSolution(); 218 } 210 219 } 211 220
Note: See TracChangeset
for help on using the changeset viewer.