Changeset 4847
- Timestamp:
- 11/19/10 11:12:40 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/HeuristicLab.Problems.VehicleRouting.Views-3.3.csproj
r4619 r4847 112 112 <ItemGroup> 113 113 <Compile Include="HeuristicLabProblemsVehicleRoutingViewsPlugin.cs" /> 114 <Compile Include="VRPImportDialog.cs"> 115 <SubType>Form</SubType> 116 </Compile> 117 <Compile Include="VRPImportDialog.Designer.cs"> 118 <DependentUpon>VRPImportDialog.cs</DependentUpon> 119 </Compile> 114 120 <Compile Include="VRPSolutionView.cs"> 115 121 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs
r4619 r4847 29 29 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 30 30 this.tabPage2 = new System.Windows.Forms.TabPage(); 31 this.importButton2 = new System.Windows.Forms.Button();32 this.importButton3 = new System.Windows.Forms.Button();33 this.importBestButton = new System.Windows.Forms.Button();34 31 this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView(); 35 32 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 46 43 // importButton 47 44 // 45 this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 46 | System.Windows.Forms.AnchorStyles.Right))); 48 47 this.importButton.Location = new System.Drawing.Point(0, 55); 49 48 this.importButton.Name = "importButton"; 50 this.importButton.Size = new System.Drawing.Size( 139, 23);49 this.importButton.Size = new System.Drawing.Size(490, 23); 51 50 this.importButton.TabIndex = 5; 52 this.importButton.Text = "Import from Solomon";51 this.importButton.Text = "Import"; 53 52 this.importButton.UseVisualStyleBackColor = true; 54 53 this.importButton.Click += new System.EventHandler(this.importButton_Click); … … 61 60 this.tabControl1.Controls.Add(this.tabPage1); 62 61 this.tabControl1.Controls.Add(this.tabPage2); 63 this.tabControl1.Location = new System.Drawing.Point(0, 111);62 this.tabControl1.Location = new System.Drawing.Point(0, 84); 64 63 this.tabControl1.Name = "tabControl1"; 65 64 this.tabControl1.SelectedIndex = 0; 66 this.tabControl1.Size = new System.Drawing.Size(490, 2 55);65 this.tabControl1.Size = new System.Drawing.Size(490, 278); 67 66 this.tabControl1.TabIndex = 6; 68 67 // … … 73 72 this.tabPage1.Name = "tabPage1"; 74 73 this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 75 this.tabPage1.Size = new System.Drawing.Size(482, 2 29);74 this.tabPage1.Size = new System.Drawing.Size(482, 252); 76 75 this.tabPage1.TabIndex = 0; 77 76 this.tabPage1.Text = "Parameters"; … … 88 87 this.parameterCollectionView.Name = "parameterCollectionView"; 89 88 this.parameterCollectionView.ReadOnly = false; 90 this.parameterCollectionView.Size = new System.Drawing.Size(476, 2 23);89 this.parameterCollectionView.Size = new System.Drawing.Size(476, 246); 91 90 this.parameterCollectionView.TabIndex = 1; 92 91 // … … 101 100 this.tabPage2.Text = "Visualization"; 102 101 this.tabPage2.UseVisualStyleBackColor = true; 103 //104 // importButton2105 //106 this.importButton2.Location = new System.Drawing.Point(145, 55);107 this.importButton2.Name = "importButton2";108 this.importButton2.Size = new System.Drawing.Size(126, 23);109 this.importButton2.TabIndex = 7;110 this.importButton2.Text = "Import from TSPLib";111 this.importButton2.UseVisualStyleBackColor = true;112 this.importButton2.Click += new System.EventHandler(this.importButton2_Click);113 //114 // importButton3115 //116 this.importButton3.Location = new System.Drawing.Point(277, 55);117 this.importButton3.Name = "importButton3";118 this.importButton3.Size = new System.Drawing.Size(131, 23);119 this.importButton3.TabIndex = 8;120 this.importButton3.Text = "Import from ORLib";121 this.importButton3.UseVisualStyleBackColor = true;122 this.importButton3.Click += new System.EventHandler(this.importButton3_Click);123 //124 // importBestButton125 //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 102 // 134 103 // vrpSolutionView … … 146 115 // 147 116 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 148 this.Controls.Add(this.importBestButton);149 this.Controls.Add(this.importButton3);150 this.Controls.Add(this.importButton2);151 117 this.Controls.Add(this.importButton); 152 118 this.Controls.Add(this.tabControl1); 153 119 this.Name = "VehicleRoutingProblemView"; 154 this.Size = new System.Drawing.Size(490, 36 9);120 this.Size = new System.Drawing.Size(490, 365); 155 121 this.Controls.SetChildIndex(this.tabControl1, 0); 156 122 this.Controls.SetChildIndex(this.importButton, 0); … … 159 125 this.Controls.SetChildIndex(this.descriptionLabel, 0); 160 126 this.Controls.SetChildIndex(this.descriptionTextBox, 0); 161 this.Controls.SetChildIndex(this.importButton2, 0);162 this.Controls.SetChildIndex(this.importButton3, 0);163 this.Controls.SetChildIndex(this.importBestButton, 0);164 127 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 165 128 this.tabControl1.ResumeLayout(false); … … 179 142 private Core.Views.ParameterCollectionView parameterCollectionView; 180 143 private VRPSolutionView vrpSolutionView; 181 private System.Windows.Forms.Button importButton2;182 private System.Windows.Forms.Button importButton3;183 private System.Windows.Forms.Button importBestButton;184 144 } 185 145 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs
r4722 r4847 27 27 using HeuristicLab.MainForm; 28 28 using HeuristicLab.Parameters; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Views { … … 32 33 [Content(typeof(VehicleRoutingProblem), true)] 33 34 public partial class VehicleRoutingProblemView : NamedItemView { 35 private VRPImportDialog vrpImportDialog; 36 34 37 public new VehicleRoutingProblem Content { 35 38 get { return (VehicleRoutingProblem)base.Content; } … … 67 70 parameterCollectionView.Enabled = Content != null; 68 71 vrpSolutionView.Enabled = Content != null; 69 importB estButton.Enabled = importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;72 importButton.Enabled = Content != null && !ReadOnly; 70 73 } 71 74 72 75 private void importButton_Click(object sender, EventArgs e) { 73 OpenFileDialog dialog = new OpenFileDialog(); 74 dialog.Filter = "Solomon files (*.txt)|*.txt"; 76 if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog(); 75 77 76 if (dialog.ShowDialog() == DialogResult.OK) { 77 Content.ImportFromSolomon(dialog.FileName); 78 if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) { 79 try { 80 switch (vrpImportDialog.Format) { 81 case VRPFormat.TSPLib: 82 Content.ImportFromTSPLib(vrpImportDialog.VRPFileName); 83 break; 84 85 case VRPFormat.Solomon: 86 Content.ImportFromSolomon(vrpImportDialog.VRPFileName); 87 break; 88 89 case VRPFormat.ORLib: 90 Content.ImportFromORLib(vrpImportDialog.VRPFileName); 91 break; 92 } 93 94 if(!string.IsNullOrEmpty(vrpImportDialog.TourFileName)) 95 Content.ImportSolution(vrpImportDialog.TourFileName); 96 } 97 catch (Exception ex) { 98 ErrorHandling.ShowErrorDialog(this, ex); 99 } 78 100 } 79 101 } 80 81 private void importButton2_Click(object sender, EventArgs e) {82 OpenFileDialog dialog = new OpenFileDialog();83 dialog.Filter = "TSPLib files (*.vrp)|*.vrp";84 85 if (dialog.ShowDialog() == DialogResult.OK) {86 Content.ImportFromTSPLib(dialog.FileName);87 }88 }89 90 private void importBestButton_Click(object sender, EventArgs e) {91 OpenFileDialog dialog = new OpenFileDialog();92 dialog.Filter = "VRP solution files (*.opt)|*.opt";93 94 if (dialog.ShowDialog() == DialogResult.OK) {95 Content.ImportSolution(dialog.FileName);96 }97 }98 99 private void importButton3_Click(object sender, EventArgs e) {100 OpenFileDialog dialog = new OpenFileDialog();101 dialog.Filter = "ORLib files (*.txt)|*.txt";102 103 if (dialog.ShowDialog() == DialogResult.OK) {104 Content.ImportFromORLib(dialog.FileName);105 }106 }107 102 108 103 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs
r4722 r4847 116 116 DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, 117 117 DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 118 DoubleMatrix coordinates, I LookupParameter<DoubleMatrix>distanceMatrix, BoolValue useDistanceMatrix) {118 DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) { 119 119 TourEvaluation eval = new TourEvaluation(); 120 120 … … 190 190 DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, 191 191 DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 192 DoubleMatrix coordinates, I LookupParameter<DoubleMatrix>distanceMatrix, BoolValue useDistanceMatrix) {192 DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) { 193 193 TourEvaluation sumEval = new TourEvaluation(); 194 194 sumEval.Distance = 0; … … 199 199 sumEval.Tardiness = 0; 200 200 201 foreach (Tour tour in solution.GetTours(distanceMatrix )) {201 foreach (Tour tour in solution.GetTours(distanceMatrix as ILookupParameter<DoubleMatrix>)) { 202 202 TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, 203 203 fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty, -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs
r4722 r4847 57 57 58 58 if (useDistanceMatrix.Value) { 59 if (distanceMatrix is IValue LookupParameter<DoubleMatrix>) {60 if ((distanceMatrix as IValue LookupParameter<DoubleMatrix>).Value == null) {61 (distanceMatrix as IValue LookupParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates);59 if (distanceMatrix is IValueParameter<DoubleMatrix>) { 60 if ((distanceMatrix as IValueParameter<DoubleMatrix>).Value == null) { 61 (distanceMatrix as IValueParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates); 62 62 } 63 63 64 distance = (distanceMatrix as IValue LookupParameter<DoubleMatrix>).Value[start, end];64 distance = (distanceMatrix as IValueParameter<DoubleMatrix>).Value[start, end]; 65 65 } else { 66 66 if (distanceMatrix.ActualValue == null) { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs
r4722 r4847 620 620 this.Name = parser.ProblemName; 621 621 622 BestKnownSolution = null; 622 623 Coordinates = new DoubleMatrix(parser.Coordinates); 623 624 Vehicles.Value = parser.Vehicles; … … 636 637 637 638 this.Name = parser.Name; 638 639 639 int problemSize = parser.Demands.Length; 640 640 641 BestKnownSolution = null; 641 642 Coordinates = new DoubleMatrix(parser.Vertices); 642 643 if (parser.Vehicles != -1) … … 661 662 662 663 if (parser.Depot != 1) 663 throw new Exception("Invalid depot specification");664 ErrorHandling.ShowErrorDialog(new Exception("Invalid depot specification")); 664 665 665 666 if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) 666 throw new Exception("Invalid weight type");667 ErrorHandling.ShowErrorDialog(new Exception("Invalid weight type")); 667 668 668 669 OnReset(); … … 672 673 if (BestKnownSolution != null) { 673 674 //call evaluator 674 IValue LookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix",675 IValueParameter<DoubleMatrix> distMatrix = new ValueParameter<DoubleMatrix>("DistMatrix", 675 676 DistanceMatrix); 676 677 … … 716 717 717 718 if (cities != Coordinates.Rows - 1) 718 throw new Exception("Invalid solution");719 720 BestKnownSolutionParameter.Value = encoding;719 ErrorHandling.ShowErrorDialog(new Exception("Invalid solution")); 720 else 721 BestKnownSolutionParameter.Value = encoding; 721 722 } 722 723 … … 728 729 int problemSize = parser.Demands.Length; 729 730 731 BestKnownSolution = null; 730 732 Coordinates = new DoubleMatrix(parser.Vertices); 731 733 Vehicles.Value = problemSize - 1;
Note: See TracChangeset
for help on using the changeset viewer.