Changeset 4619 for trunk/sources
- Timestamp:
- 10/19/10 13:22:55 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/HeuristicLab.Problems.VehicleRouting.Views-3.3.csproj
r4065 r4619 172 172 <Name>HeuristicLab.MainForm-3.3</Name> 173 173 </ProjectReference> 174 <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj"> 175 <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project> 176 <Name>HeuristicLab.Operators-3.3</Name> 177 </ProjectReference> 174 178 <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj"> 175 179 <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project> -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs.frame
r4497 r4619 38 38 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 39 39 [PluginDependency("HeuristicLab.Optimization", "3.3")] 40 [PluginDependency("HeuristicLab.Operators", "3.3")] 40 41 [PluginDependency("HeuristicLab.Optimization.Views", "3.3")] 41 42 [PluginDependency("HeuristicLab.Parameters", "3.3")] -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.Designer.cs
r4352 r4619 123 123 this.tourGridView.Location = new System.Drawing.Point(3, 16); 124 124 this.tourGridView.Name = "tourGridView"; 125 this.tourGridView.ReadOnly = true; 125 126 this.tourGridView.Size = new System.Drawing.Size(403, 507); 126 127 this.tourGridView.TabIndex = 0; -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs
r4352 r4619 31 31 this.importButton2 = new System.Windows.Forms.Button(); 32 32 this.importButton3 = new System.Windows.Forms.Button(); 33 this.importBestButton = new System.Windows.Forms.Button(); 33 34 this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView(); 34 35 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 60 61 this.tabControl1.Controls.Add(this.tabPage1); 61 62 this.tabControl1.Controls.Add(this.tabPage2); 62 this.tabControl1.Location = new System.Drawing.Point(0, 84);63 this.tabControl1.Location = new System.Drawing.Point(0, 111); 63 64 this.tabControl1.Name = "tabControl1"; 64 65 this.tabControl1.SelectedIndex = 0; 65 this.tabControl1.Size = new System.Drawing.Size(490, 2 65);66 this.tabControl1.Size = new System.Drawing.Size(490, 255); 66 67 this.tabControl1.TabIndex = 6; 67 68 // … … 72 73 this.tabPage1.Name = "tabPage1"; 73 74 this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 74 this.tabPage1.Size = new System.Drawing.Size(482, 2 39);75 this.tabPage1.Size = new System.Drawing.Size(482, 229); 75 76 this.tabPage1.TabIndex = 0; 76 77 this.tabPage1.Text = "Parameters"; … … 79 80 // parameterCollectionView 80 81 // 82 this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 83 | System.Windows.Forms.AnchorStyles.Left) 84 | System.Windows.Forms.AnchorStyles.Right))); 81 85 this.parameterCollectionView.Caption = "ParameterCollection View"; 82 86 this.parameterCollectionView.Content = null; 83 this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;84 87 this.parameterCollectionView.Location = new System.Drawing.Point(3, 3); 85 88 this.parameterCollectionView.Name = "parameterCollectionView"; 86 89 this.parameterCollectionView.ReadOnly = false; 87 this.parameterCollectionView.Size = new System.Drawing.Size(476, 2 33);90 this.parameterCollectionView.Size = new System.Drawing.Size(476, 223); 88 91 this.parameterCollectionView.TabIndex = 1; 89 92 // … … 94 97 this.tabPage2.Name = "tabPage2"; 95 98 this.tabPage2.Padding = new System.Windows.Forms.Padding(3); 96 this.tabPage2.Size = new System.Drawing.Size(482, 2 39);99 this.tabPage2.Size = new System.Drawing.Size(482, 229); 97 100 this.tabPage2.TabIndex = 1; 98 101 this.tabPage2.Text = "Visualization"; … … 119 122 this.importButton3.Click += new System.EventHandler(this.importButton3_Click); 120 123 // 124 // importBestButton 125 // 126 this.importBestButton.Location = new System.Drawing.Point(0, 82); 127 this.importBestButton.Name = "importBestButton"; 128 this.importBestButton.Size = new System.Drawing.Size(139, 23); 129 this.importBestButton.TabIndex = 9; 130 this.importBestButton.Text = "Import solution"; 131 this.importBestButton.UseVisualStyleBackColor = true; 132 this.importBestButton.Click += new System.EventHandler(this.importBestButton_Click); 133 // 121 134 // vrpSolutionView 122 135 // … … 127 140 this.vrpSolutionView.Name = "vrpSolutionView"; 128 141 this.vrpSolutionView.ReadOnly = false; 129 this.vrpSolutionView.Size = new System.Drawing.Size(476, 2 33);142 this.vrpSolutionView.Size = new System.Drawing.Size(476, 223); 130 143 this.vrpSolutionView.TabIndex = 0; 131 144 // … … 133 146 // 134 147 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 148 this.Controls.Add(this.importBestButton); 135 149 this.Controls.Add(this.importButton3); 136 150 this.Controls.Add(this.importButton2); … … 138 152 this.Controls.Add(this.tabControl1); 139 153 this.Name = "VehicleRoutingProblemView"; 140 this.Size = new System.Drawing.Size(490, 3 52);154 this.Size = new System.Drawing.Size(490, 369); 141 155 this.Controls.SetChildIndex(this.tabControl1, 0); 142 156 this.Controls.SetChildIndex(this.importButton, 0); … … 147 161 this.Controls.SetChildIndex(this.importButton2, 0); 148 162 this.Controls.SetChildIndex(this.importButton3, 0); 163 this.Controls.SetChildIndex(this.importBestButton, 0); 149 164 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 150 165 this.tabControl1.ResumeLayout(false); … … 166 181 private System.Windows.Forms.Button importButton2; 167 182 private System.Windows.Forms.Button importButton3; 183 private System.Windows.Forms.Button importBestButton; 168 184 } 169 185 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs
r4352 r4619 26 26 using HeuristicLab.Core.Views; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 29 31 namespace HeuristicLab.Problems.VehicleRouting.Views { … … 42 44 protected override void DeregisterContentEvents() { 43 45 Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged); 46 Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged); 44 47 base.DeregisterContentEvents(); 45 48 } … … 47 50 base.RegisterContentEvents(); 48 51 Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged); 52 Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged); 49 53 } 50 54 … … 56 60 } else { 57 61 parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters; 58 vrpSolutionView.Content = new VRPSolution(Content.Coordinates);62 UpdateSolution(); 59 63 } 60 64 } … … 64 68 parameterCollectionView.Enabled = Content != null; 65 69 vrpSolutionView.Enabled = Content != null; 66 importB utton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;70 importBestButton.Enabled = importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly; 67 71 } 68 72 … … 85 89 } 86 90 91 private void importBestButton_Click(object sender, EventArgs e) { 92 OpenFileDialog dialog = new OpenFileDialog(); 93 dialog.Filter = "VRP solution files (*.opt)|*.opt"; 94 95 if (dialog.ShowDialog() == DialogResult.OK) { 96 Content.ImportSolution(dialog.FileName); 97 } 98 } 99 87 100 private void importButton3_Click(object sender, EventArgs e) { 88 101 OpenFileDialog dialog = new OpenFileDialog(); … … 96 109 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { 97 110 vrpSolutionView.Content.Coordinates = Content.Coordinates; 98 } 111 } 112 113 private void UpdateSolution() { 114 if (Content.BestKnownSolution == null) 115 vrpSolutionView.Content = new VRPSolution(Content.Coordinates); 116 else { 117 //call evaluator 118 IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix", 119 Content.DistanceMatrix); 120 121 TourEvaluation eval = VRPEvaluator.Evaluate( 122 Content.BestKnownSolution, 123 Content.Vehicles, 124 Content.DueTime, 125 Content.ServiceTime, 126 Content.ReadyTime, 127 Content.Demand, 128 Content.Capacity, 129 Content.FleetUsageFactorParameter.Value, 130 Content.TimeFactorParameter.Value, 131 Content.DistanceFactorParameter.Value, 132 Content.OverloadPenaltyParameter.Value, 133 Content.TardinessPenaltyParameter.Value, 134 Content.Coordinates, 135 distMatrix, 136 Content.UseDistanceMatrix); 137 138 Content.DistanceMatrix = distMatrix.Value; 139 140 vrpSolutionView.Content = new VRPSolution(Content.Coordinates, 141 Content.BestKnownSolution, 142 new DoubleValue(eval.Quality), 143 new DoubleValue(eval.Distance), 144 new DoubleValue(eval.Overload), 145 new DoubleValue(eval.Tardiness), 146 new DoubleValue(eval.TravelTime), 147 new DoubleValue(eval.VehcilesUtilized), 148 Content.DistanceMatrix, 149 Content.UseDistanceMatrix, 150 Content.ReadyTime, 151 Content.DueTime, 152 Content.ServiceTime); 153 } 154 } 155 156 void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) { 157 UpdateSolution(); 158 } 99 159 } 100 160 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj
r4352 r4619 110 110 <Compile Include="Analyzers\BestVRPToursMemorizer.cs" /> 111 111 <Compile Include="Analyzers\BestVRPSolutionAnalyzer.cs" /> 112 <Compile Include="SolutionParser.cs" /> 112 113 <Compile Include="Encodings\Alba\Crossovers\AlbaPermutationCrossover.cs" /> 113 114 <Compile Include="Encodings\Alba\Manipulators\AlbaIntraRouteInversionManipulator.cs" /> -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs
r4352 r4619 56 56 57 57 public static double GetDistance(int start, int end, 58 DoubleMatrix coordinates, I LookupParameter<DoubleMatrix>distanceMatrix, BoolValue useDistanceMatrix) {58 DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) { 59 59 double distance = 0.0; 60 60 61 61 if (useDistanceMatrix.Value) { 62 if (distanceMatrix is IValueLookupParameter<DoubleMatrix> && 63 (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value != null) { 64 distance = (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value[start, end]; 62 if (distanceMatrix is IValueLookupParameter<DoubleMatrix>) { 63 if ((distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value == null) { 64 (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates); 65 } 66 67 distance = (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value[start, end]; 65 68 } else { 66 69 if (distanceMatrix.ActualValue == null) { … … 68 71 } 69 72 70 distance = distanceMatrix.ActualValue[start, end];71 } 73 distance = (distanceMatrix.ActualValue as DoubleMatrix)[start, end]; 74 } 72 75 } else { 73 76 distance = CalculateDistance(start, end, coordinates); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs
r4419 r4619 93 93 get { return EvaluatorParameter; } 94 94 } 95 public IValueParameter<DoubleValue> FleetUsageFactor {95 public IValueParameter<DoubleValue> FleetUsageFactorParameter { 96 96 get { return (IValueParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; } 97 97 } 98 public IValueParameter<DoubleValue> TimeFactor {98 public IValueParameter<DoubleValue> TimeFactorParameter { 99 99 get { return (IValueParameter<DoubleValue>)Parameters["EvalTimeFactor"]; } 100 100 } 101 public IValueParameter<DoubleValue> DistanceFactor {101 public IValueParameter<DoubleValue> DistanceFactorParameter { 102 102 get { return (IValueParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; } 103 103 } 104 public IValueParameter<DoubleValue> OverloadPenalty {104 public IValueParameter<DoubleValue> OverloadPenaltyParameter { 105 105 get { return (IValueParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; } 106 106 } 107 public IValueParameter<DoubleValue> TardinessPenalty {107 public IValueParameter<DoubleValue> TardinessPenaltyParameter { 108 108 get { return (IValueParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; } 109 109 } … … 113 113 IParameter ISingleObjectiveProblem.BestKnownQualityParameter { 114 114 get { return BestKnownQualityParameter; } 115 } 116 public OptionalValueParameter<IVRPEncoding> BestKnownSolutionParameter { 117 get { return (OptionalValueParameter<IVRPEncoding>)Parameters["BestKnownSolution"]; } 115 118 } 116 119 #endregion … … 157 160 set { BestKnownQualityParameter.Value = value; } 158 161 } 162 public IVRPEncoding BestKnownSolution { 163 get { return BestKnownSolutionParameter.Value; } 164 set { BestKnownSolutionParameter.Value = value; } 165 } 159 166 IVRPCreator SolutionCreator { 160 167 get { return SolutionCreatorParameter.Value; } … … 190 197 [StorableConstructor] 191 198 private VehicleRoutingProblem(bool deserializing) : base(deserializing) { } 199 200 #region Backwards Compatibility 201 [StorableHook(Persistence.Default.CompositeSerializers.Storable.HookType.AfterDeserialization)] 202 private void CheckParameters() { 203 if (!Parameters.ContainsKey("BestKnownSolution")) { 204 Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this TSP instance.")); 205 } 206 } 207 #endregion 208 192 209 public VehicleRoutingProblem() 193 210 : base() { … … 206 223 Parameters.Add(new ValueParameter<DoubleArray>("ServiceTime", "The service time of each customer.", new DoubleArray())); 207 224 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 225 Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this TSP instance.")); 208 226 Parameters.Add(new ValueParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation.", new DoubleValue(100))); 209 227 Parameters.Add(new ValueParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation.", new DoubleValue(0))); … … 264 282 ParameterizeSolutionCreator(); 265 283 ClearDistanceMatrix(); 284 285 BestKnownSolution = null; 286 BestKnownQuality = null; 266 287 } 267 288 private void Coordinates_ItemChanged(object sender, EventArgs<int, int> e) { 268 289 ClearDistanceMatrix(); 290 291 BestKnownSolution = null; 292 BestKnownQuality = null; 269 293 } 270 294 private void Coordinates_Reset(object sender, EventArgs e) { 271 295 ParameterizeSolutionCreator(); 272 296 ClearDistanceMatrix(); 297 298 BestKnownSolution = null; 299 BestKnownQuality = null; 273 300 } 274 301 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { … … 300 327 } 301 328 } 329 330 void DistanceFactor_ValueChanged(object sender, EventArgs e) { 331 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactorValue_ValueChanged); 332 EvalBestKnownSolution(); 333 } 334 void DistanceFactorValue_ValueChanged(object sender, EventArgs e) { 335 EvalBestKnownSolution(); 336 } 337 void FleetUsageFactor_ValueChanged(object sender, EventArgs e) { 338 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactorValue_ValueChanged); 339 EvalBestKnownSolution(); 340 } 341 void FleetUsageFactorValue_ValueChanged(object sender, EventArgs e) { 342 EvalBestKnownSolution(); 343 } 344 void OverloadPenalty_ValueChanged(object sender, EventArgs e) { 345 OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenaltyValue_ValueChanged); 346 EvalBestKnownSolution(); 347 } 348 void OverloadPenaltyValue_ValueChanged(object sender, EventArgs e) { 349 EvalBestKnownSolution(); 350 } 351 void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 352 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenaltyValue_ValueChanged); 353 EvalBestKnownSolution(); 354 } 355 void TardinessPenaltyValue_ValueChanged(object sender, EventArgs e) { 356 EvalBestKnownSolution(); 357 } 358 void TimeFactor_ValueChanged(object sender, EventArgs e) { 359 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactorValue_ValueChanged); 360 EvalBestKnownSolution(); 361 } 362 void TimeFactorValue_ValueChanged(object sender, EventArgs e) { 363 EvalBestKnownSolution(); 364 } 365 void DistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 366 DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged); 367 DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset); 368 EvalBestKnownSolution(); 369 } 370 void DistanceMatrix_Reset(object sender, EventArgs e) { 371 EvalBestKnownSolution(); 372 } 373 void DistanceMatrix_ItemChanged(object sender, EventArgs<int, int> e) { 374 EvalBestKnownSolution(); 375 } 376 void UseDistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 377 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged); 378 EvalBestKnownSolution(); 379 } 380 void UseDistanceMatrix_ValueChanged(object sender, EventArgs e) { 381 EvalBestKnownSolution(); 382 } 383 void CapacityParameter_ValueChanged(object sender, EventArgs e) { 384 Capacity.ValueChanged += new EventHandler(Capacity_ValueChanged); 385 BestKnownSolution = null; 386 BestKnownQuality = null; 387 } 388 void Capacity_ValueChanged(object sender, EventArgs e) { 389 BestKnownSolution = null; 390 BestKnownQuality = null; 391 } 392 void DemandParameter_ValueChanged(object sender, EventArgs e) { 393 Demand.ItemChanged += new EventHandler<EventArgs<int>>(Demand_ItemChanged); 394 Demand.Reset += new EventHandler(Demand_Reset); 395 396 BestKnownSolution = null; 397 BestKnownQuality = null; 398 } 399 void Demand_Reset(object sender, EventArgs e) { 400 BestKnownSolution = null; 401 BestKnownQuality = null; 402 } 403 void Demand_ItemChanged(object sender, EventArgs<int> e) { 404 BestKnownSolution = null; 405 BestKnownQuality = null; 406 } 407 void DueTimeParameter_ValueChanged(object sender, EventArgs e) { 408 DueTime.ItemChanged += new EventHandler<EventArgs<int>>(DueTime_ItemChanged); 409 DueTime.Reset += new EventHandler(DueTime_Reset); 410 BestKnownSolution = null; 411 BestKnownQuality = null; 412 } 413 void DueTime_Reset(object sender, EventArgs e) { 414 BestKnownSolution = null; 415 BestKnownQuality = null; 416 } 417 void DueTime_ItemChanged(object sender, EventArgs<int> e) { 418 BestKnownSolution = null; 419 BestKnownQuality = null; 420 } 421 void ReadyTimeParameter_ValueChanged(object sender, EventArgs e) { 422 ReadyTime.ItemChanged += new EventHandler<EventArgs<int>>(ReadyTime_ItemChanged); 423 ReadyTime.Reset += new EventHandler(ReadyTime_Reset); 424 BestKnownSolution = null; 425 BestKnownQuality = null; 426 } 427 void ReadyTime_Reset(object sender, EventArgs e) { 428 BestKnownSolution = null; 429 BestKnownQuality = null; 430 } 431 void ReadyTime_ItemChanged(object sender, EventArgs<int> e) { 432 BestKnownSolution = null; 433 BestKnownQuality = null; 434 } 435 void ServiceTimeParameter_ValueChanged(object sender, EventArgs e) { 436 ServiceTime.ItemChanged += new EventHandler<EventArgs<int>>(ServiceTime_ItemChanged); 437 ServiceTime.Reset += new EventHandler(ServiceTime_Reset); 438 BestKnownSolution = null; 439 BestKnownQuality = null; 440 } 441 void ServiceTime_Reset(object sender, EventArgs e) { 442 BestKnownSolution = null; 443 BestKnownQuality = null; 444 } 445 void ServiceTime_ItemChanged(object sender, EventArgs<int> e) { 446 BestKnownSolution = null; 447 BestKnownQuality = null; 448 } 449 void VehiclesParameter_ValueChanged(object sender, EventArgs e) { 450 Vehicles.ValueChanged += new EventHandler(Vehicles_ValueChanged); 451 BestKnownSolution = null; 452 BestKnownQuality = null; 453 } 454 void Vehicles_ValueChanged(object sender, EventArgs e) { 455 BestKnownSolution = null; 456 BestKnownQuality = null; 457 } 302 458 #endregion 303 459 … … 310 466 private void AttachEventHandlers() { 311 467 CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged); 312 Vehicles.ValueChanged += new EventHandler(VehiclesValue_ValueChanged);313 468 Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged); 314 469 Coordinates.Reset += new EventHandler(Coordinates_Reset); 470 471 Vehicles.ValueChanged += new EventHandler(VehiclesValue_ValueChanged); 472 315 473 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 474 316 475 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 317 476 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 318 } 477 478 DistanceFactorParameter.ValueChanged += new EventHandler(DistanceFactor_ValueChanged); 479 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactorValue_ValueChanged); 480 FleetUsageFactorParameter.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged); 481 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactorValue_ValueChanged); 482 OverloadPenaltyParameter.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged); 483 OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenaltyValue_ValueChanged); 484 TardinessPenaltyParameter.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 485 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenaltyValue_ValueChanged); 486 TimeFactorParameter.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 487 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactorValue_ValueChanged); 488 489 DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged); 490 UseDistanceMatrixParameter.ValueChanged += new EventHandler(UseDistanceMatrixParameter_ValueChanged); 491 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged); 492 493 CapacityParameter.ValueChanged += new EventHandler(CapacityParameter_ValueChanged); 494 Capacity.ValueChanged += new EventHandler(Capacity_ValueChanged); 495 DemandParameter.ValueChanged += new EventHandler(DemandParameter_ValueChanged); 496 Demand.ItemChanged += new EventHandler<EventArgs<int>>(Demand_ItemChanged); 497 Demand.Reset += new EventHandler(Demand_Reset); 498 DueTimeParameter.ValueChanged += new EventHandler(DueTimeParameter_ValueChanged); 499 DueTime.ItemChanged += new EventHandler<EventArgs<int>>(DueTime_ItemChanged); 500 DueTime.Reset += new EventHandler(DueTime_Reset); 501 ReadyTimeParameter.ValueChanged += new EventHandler(ReadyTimeParameter_ValueChanged); 502 ReadyTime.ItemChanged += new EventHandler<EventArgs<int>>(ReadyTime_ItemChanged); 503 ReadyTime.Reset += new EventHandler(ReadyTime_Reset); 504 ServiceTimeParameter.ValueChanged += new EventHandler(ServiceTimeParameter_ValueChanged); 505 ServiceTime.ItemChanged += new EventHandler<EventArgs<int>>(ServiceTime_ItemChanged); 506 ServiceTime.Reset += new EventHandler(ServiceTime_Reset); 507 VehiclesParameter.ValueChanged += new EventHandler(VehiclesParameter_ValueChanged); 508 Vehicles.ValueChanged += new EventHandler(Vehicles_ValueChanged); 509 } 510 319 511 private void InitializeOperators() { 320 512 operators = new List<IOperator>(); … … 361 553 Evaluator.DueTimeParameter.ActualName = DueTimeParameter.Name; 362 554 Evaluator.ServiceTimeParameter.ActualName = ServiceTimeParameter.Name; 363 Evaluator.FleetUsageFactor.ActualName = FleetUsageFactor .Name;364 Evaluator.TimeFactor.ActualName = TimeFactor .Name;365 Evaluator.DistanceFactor.ActualName = DistanceFactor .Name;366 Evaluator.OverloadPenalty.ActualName = OverloadPenalty .Name;367 Evaluator.TardinessPenalty.ActualName = TardinessPenalty .Name;555 Evaluator.FleetUsageFactor.ActualName = FleetUsageFactorParameter.Name; 556 Evaluator.TimeFactor.ActualName = TimeFactorParameter.Name; 557 Evaluator.DistanceFactor.ActualName = DistanceFactorParameter.Name; 558 Evaluator.OverloadPenalty.ActualName = OverloadPenaltyParameter.Name; 559 Evaluator.TardinessPenalty.ActualName = TardinessPenaltyParameter.Name; 368 560 } 369 561 private void ParameterizeAnalyzer() { … … 403 595 404 596 foreach (IPrinsOperator op in Operators.OfType<IPrinsOperator>()) { 405 op.FleetUsageFactor.ActualName = FleetUsageFactor .Name;406 op.TimeFactor.ActualName = TimeFactor .Name;407 op.DistanceFactor.ActualName = DistanceFactor .Name;408 op.OverloadPenalty.ActualName = OverloadPenalty .Name;409 op.TardinessPenalty.ActualName = TardinessPenalty .Name;597 op.FleetUsageFactor.ActualName = FleetUsageFactorParameter.Name; 598 op.TimeFactor.ActualName = TimeFactorParameter.Name; 599 op.DistanceFactor.ActualName = DistanceFactorParameter.Name; 600 op.OverloadPenalty.ActualName = OverloadPenaltyParameter.Name; 601 op.TardinessPenalty.ActualName = TardinessPenaltyParameter.Name; 410 602 } 411 603 412 604 foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) { 413 op.FleetUsageFactor.ActualName = FleetUsageFactor .Name;414 op.TimeFactor.ActualName = TimeFactor .Name;415 op.DistanceFactor.ActualName = DistanceFactor .Name;416 op.OverloadPenalty.ActualName = OverloadPenalty .Name;417 op.TardinessPenalty.ActualName = TardinessPenalty .Name;605 op.FleetUsageFactor.ActualName = FleetUsageFactorParameter.Name; 606 op.TimeFactor.ActualName = TimeFactorParameter.Name; 607 op.DistanceFactor.ActualName = DistanceFactorParameter.Name; 608 op.OverloadPenalty.ActualName = OverloadPenaltyParameter.Name; 609 op.TardinessPenalty.ActualName = TardinessPenaltyParameter.Name; 418 610 op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 419 611 op.VRPToursParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName; … … 490 682 491 683 OnReset(); 684 } 685 686 private void EvalBestKnownSolution() { 687 if (BestKnownSolution != null) { 688 //call evaluator 689 IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix", 690 DistanceMatrix); 691 692 TourEvaluation eval = VRPEvaluator.Evaluate( 693 BestKnownSolution, 694 Vehicles, 695 DueTime, 696 ServiceTime, 697 ReadyTime, 698 Demand, 699 Capacity, 700 FleetUsageFactorParameter.Value, 701 TimeFactorParameter.Value, 702 DistanceFactorParameter.Value, 703 OverloadPenaltyParameter.Value, 704 TardinessPenaltyParameter.Value, 705 Coordinates, 706 distMatrix, 707 UseDistanceMatrix); 708 709 DistanceMatrix = distMatrix.Value; 710 711 BestKnownQuality = new DoubleValue(eval.Quality); 712 } else { 713 BestKnownQuality = null; 714 } 715 } 716 717 public void ImportSolution(string solutionFileName) { 718 SolutionParser parser = new SolutionParser(solutionFileName); 719 parser.Parse(); 720 721 HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinEncoding encoding = new Encodings.Potvin.PotvinEncoding(); 722 723 int cities = 0; 724 foreach (List<int> route in parser.Routes) { 725 Encodings.Tour tour = new Encodings.Tour(); 726 tour.Cities.AddRange(route); 727 cities += tour.Cities.Count; 728 729 encoding.Tours.Add(tour); 730 } 731 732 if (cities != Coordinates.Rows - 1) 733 throw new Exception("Invalid solution"); 734 735 BestKnownSolutionParameter.Value = encoding; 736 EvalBestKnownSolution(); 492 737 } 493 738
Note: See TracChangeset
for help on using the changeset viewer.