Changeset 4860
- Timestamp:
- 11/19/10 15:43:21 (14 years ago)
- Location:
- branches/VRP
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj
r4374 r4860 125 125 <DependentUpon>SingleDepotVRPView.cs</DependentUpon> 126 126 </Compile> 127 <Compile Include="VRPImportDialog.cs"> 128 <SubType>Form</SubType> 129 </Compile> 130 <Compile Include="VRPImportDialog.Designer.cs"> 131 <DependentUpon>VRPImportDialog.cs</DependentUpon> 132 </Compile> 127 133 <Compile Include="VRPProblemInstanceView.cs"> 128 134 <SubType>UserControl</SubType> -
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs
r4362 r4860 25 25 private void InitializeComponent() { 26 26 this.importButton = new System.Windows.Forms.Button(); 27 this.importButton2 = new System.Windows.Forms.Button();28 this.importButton3 = new System.Windows.Forms.Button();29 27 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 30 28 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 38 36 // importButton 39 37 // 38 this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 39 | System.Windows.Forms.AnchorStyles.Right))); 40 40 this.importButton.Location = new System.Drawing.Point(0, 55); 41 41 this.importButton.Name = "importButton"; 42 this.importButton.Size = new System.Drawing.Size( 139, 23);42 this.importButton.Size = new System.Drawing.Size(490, 23); 43 43 this.importButton.TabIndex = 5; 44 this.importButton.Text = "Import from Solomon";44 this.importButton.Text = "Import"; 45 45 this.importButton.UseVisualStyleBackColor = true; 46 46 this.importButton.Click += new System.EventHandler(this.importButton_Click); 47 //48 // importButton249 //50 this.importButton2.Location = new System.Drawing.Point(145, 55);51 this.importButton2.Name = "importButton2";52 this.importButton2.Size = new System.Drawing.Size(126, 23);53 this.importButton2.TabIndex = 7;54 this.importButton2.Text = "Import from TSPLib";55 this.importButton2.UseVisualStyleBackColor = true;56 this.importButton2.Click += new System.EventHandler(this.importButton2_Click);57 //58 // importButton359 //60 this.importButton3.Location = new System.Drawing.Point(277, 55);61 this.importButton3.Name = "importButton3";62 this.importButton3.Size = new System.Drawing.Size(131, 23);63 this.importButton3.TabIndex = 8;64 this.importButton3.Text = "Import from ORLib";65 this.importButton3.UseVisualStyleBackColor = true;66 this.importButton3.Click += new System.EventHandler(this.importButton3_Click);67 47 // 68 48 // parameterCollectionView … … 83 63 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 84 64 this.Controls.Add(this.parameterCollectionView); 85 this.Controls.Add(this.importButton3);86 this.Controls.Add(this.importButton2);87 65 this.Controls.Add(this.importButton); 88 66 this.Name = "VehicleRoutingProblemView"; 89 67 this.Size = new System.Drawing.Size(490, 352); 90 68 this.Controls.SetChildIndex(this.importButton, 0); 91 this.Controls.SetChildIndex(this.importButton2, 0); 92 this.Controls.SetChildIndex(this.importButton3, 0); 69 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 93 70 this.Controls.SetChildIndex(this.nameTextBox, 0); 94 71 this.Controls.SetChildIndex(this.nameLabel, 0); 95 72 this.Controls.SetChildIndex(this.descriptionLabel, 0); 96 73 this.Controls.SetChildIndex(this.descriptionTextBox, 0); 97 this.Controls.SetChildIndex(this.parameterCollectionView, 0);98 74 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 99 75 this.ResumeLayout(false); … … 105 81 106 82 private System.Windows.Forms.Button importButton; 107 private System.Windows.Forms.Button importButton2;108 private System.Windows.Forms.Button importButton3;109 83 private Core.Views.ParameterCollectionView parameterCollectionView; 110 84 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs
r4362 r4860 26 26 using HeuristicLab.Core.Views; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.PluginInfrastructure; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Views { … … 31 32 [Content(typeof(VehicleRoutingProblem), true)] 32 33 public partial class VehicleRoutingProblemView : NamedItemView { 34 private VRPImportDialog vrpImportDialog; 35 33 36 public new VehicleRoutingProblem Content { 34 37 get { return (VehicleRoutingProblem)base.Content; } … … 59 62 base.SetEnabledStateOfControls(); 60 63 parameterCollectionView.Enabled = Content != null; 61 importButton.Enabled = importButton2.Enabled = importButton3.Enabled =Content != null && !ReadOnly;64 importButton.Enabled = Content != null && !ReadOnly; 62 65 } 63 66 64 67 private void importButton_Click(object sender, EventArgs e) { 65 OpenFileDialog dialog = new OpenFileDialog(); 66 dialog.Filter = "Solomon files (*.txt)|*.txt"; 68 if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog(); 67 69 68 if (dialog.ShowDialog() == DialogResult.OK) { 69 Content.ImportFromSolomon(dialog.FileName); 70 if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) { 71 try { 72 switch (vrpImportDialog.Format) { 73 case VRPFormat.TSPLib: 74 Content.ImportFromTSPLib(vrpImportDialog.VRPFileName); 75 break; 76 77 case VRPFormat.Solomon: 78 Content.ImportFromSolomon(vrpImportDialog.VRPFileName); 79 break; 80 81 case VRPFormat.ORLib: 82 Content.ImportFromORLib(vrpImportDialog.VRPFileName); 83 break; 84 } 85 86 if (!string.IsNullOrEmpty(vrpImportDialog.TourFileName)) 87 Content.ImportSolution(vrpImportDialog.TourFileName); 88 } 89 catch (Exception ex) { 90 ErrorHandling.ShowErrorDialog(this, ex); 91 } 70 92 } 71 } 72 73 private void importButton2_Click(object sender, EventArgs e) { 74 OpenFileDialog dialog = new OpenFileDialog(); 75 dialog.Filter = "TSPLib files (*.vrp)|*.vrp"; 76 77 if (dialog.ShowDialog() == DialogResult.OK) { 78 Content.ImportFromTSPLib(dialog.FileName); 79 } 80 } 81 82 private void importButton3_Click(object sender, EventArgs e) { 83 OpenFileDialog dialog = new OpenFileDialog(); 84 dialog.Filter = "ORLib files (*.txt)|*.txt"; 85 86 if (dialog.ShowDialog() == DialogResult.OK) { 87 Content.ImportFromORLib(dialog.FileName); 88 } 89 } 93 } 90 94 } 91 95 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/BestVRPSolutionAnalyzer.cs
r4752 r4860 62 62 } 63 63 64 public LookupParameter<DoubleValue> BestKnownQualityParameter { 65 get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 66 } 67 public LookupParameter<VRPSolution> BestKnownSolutionParameter { 68 get { return (LookupParameter<VRPSolution>)Parameters["BestKnownSolution"]; } 69 } 70 64 71 [StorableConstructor] 65 72 private BestVRPSolutionAnalyzer(bool deserializing) : base(deserializing) { } … … 69 76 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance.")); 70 77 Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("VRPTours", "The VRP tours which should be evaluated.")); 78 79 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 80 Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 71 81 72 82 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed.")); … … 86 96 } 87 97 98 [StorableHook(HookType.AfterDeserialization)] 99 private void AfterDeserializationHook() { 100 #region Backwards Compatibility 101 if (!Parameters.ContainsKey("BestKnownQuality")) { 102 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 103 } 104 if (!Parameters.ContainsKey("BestKnownSolution")) { 105 Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 106 } 107 #endregion 108 } 109 88 110 public override IOperation Apply() { 89 111 IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue; … … 96 118 97 119 int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index; 120 121 DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue; 98 122 99 123 IVRPEncoding best = solutions[i].Clone() as IVRPEncoding; … … 116 140 } 117 141 142 if (bestKnownQuality == null || 143 qualities[i].Value < bestKnownQuality.Value) { 144 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value); 145 BestKnownSolutionParameter.ActualValue = (VRPSolution)solution.Clone(); 146 } 147 118 148 return base.Apply(); 119 149 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r4383 r4860 227 227 <Compile Include="Interfaces\IVRPEncoding.cs" /> 228 228 <Compile Include="Interfaces\IVRPProblemInstance.cs" /> 229 <Compile Include="SolutionParser.cs" /> 229 230 <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedProblemInstance.cs" /> 230 231 <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedOperator.cs" /> -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs
r4363 r4860 32 32 IValueParameter<IVRPEvaluator> EvaluatorParameter { get; } 33 33 IValueParameter<IVRPCreator> SolutionCreatorParameter { get; } 34 IValueParameter<DoubleValue> BestKnownQualityParameter { get; } 35 IValueParameter<VRPSolution> BestKnownSolutionParameter { get; } 34 36 IEnumerable<IOperator> Operators { get; } 35 37 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPProblemInstance.cs
r4752 r4860 77 77 Parameters.Add(new ValueParameter<DoubleValue>("Capacity", "The capacity of each vehicle.", new DoubleValue(0))); 78 78 Parameters.Add(new ValueParameter<DoubleValue>("EvalOverloadPenalty", "The overload penalty considered in the evaluation.", new DoubleValue(100))); 79 80 AttachEventHandlers(); 79 81 } 80 82 … … 85 87 protected CVRPProblemInstance(CVRPProblemInstance original, Cloner cloner) 86 88 : base(original, cloner) { 89 AttachEventHandlers(); 87 90 } 91 92 [StorableHook(HookType.AfterDeserialization)] 93 private void AfterDeserializationHook() { 94 AttachEventHandlers(); 95 } 96 97 private void AttachEventHandlers() { 98 CapacityParameter.ValueChanged += new EventHandler(CapacityParameter_ValueChanged); 99 CapacityParameter.Value.ValueChanged += new EventHandler(Capacity_ValueChanged); 100 OverloadPenaltyParameter.ValueChanged += new EventHandler(OverloadPenaltyParameter_ValueChanged); 101 OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged); 102 } 103 104 #region Event handlers 105 void CapacityParameter_ValueChanged(object sender, EventArgs e) { 106 CapacityParameter.Value.ValueChanged += new EventHandler(Capacity_ValueChanged); 107 BestKnownSolution = null; 108 } 109 void Capacity_ValueChanged(object sender, EventArgs e) { 110 BestKnownSolution = null; 111 } 112 void OverloadPenaltyParameter_ValueChanged(object sender, EventArgs e) { 113 OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged); 114 EvalBestKnownSolution(); 115 } 116 void OverloadPenalty_ValueChanged(object sender, EventArgs e) { 117 EvalBestKnownSolution(); 118 } 119 #endregion 88 120 } 89 121 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWProblemInstance.cs
r4752 r4860 103 103 Parameters.Add(new ValueParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation.", new DoubleValue(0))); 104 104 Parameters.Add(new ValueParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation.", new DoubleValue(100))); 105 106 AttachEventHandlers(); 105 107 } 106 108 … … 111 113 protected CVRPTWProblemInstance(CVRPTWProblemInstance original, Cloner cloner) 112 114 : base(original, cloner) { 115 AttachEventHandlers(); 113 116 } 117 118 [StorableHook(HookType.AfterDeserialization)] 119 private void AfterDeserializationHook() { 120 AttachEventHandlers(); 121 } 122 123 private void AttachEventHandlers() { 124 TardinessPenaltyParameter.ValueChanged += new EventHandler(TardinessPenaltyParameter_ValueChanged); 125 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 126 TimeFactorParameter.ValueChanged += new EventHandler(TimeFactorParameter_ValueChanged); 127 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 128 } 129 130 #region Event handlers 131 void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) { 132 TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged); 133 EvalBestKnownSolution(); 134 } 135 void TardinessPenalty_ValueChanged(object sender, EventArgs e) { 136 EvalBestKnownSolution(); 137 } 138 void TimeFactorParameter_ValueChanged(object sender, EventArgs e) { 139 TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged); 140 EvalBestKnownSolution(); 141 } 142 void TimeFactor_ValueChanged(object sender, EventArgs e) { 143 EvalBestKnownSolution(); 144 } 145 #endregion 114 146 } 115 147 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r4752 r4860 77 77 } 78 78 79 protected OptionalValueParameter<DoubleValue> BestKnownQualityParameter { 80 get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 81 } 82 protected OptionalValueParameter<VRPSolution> BestKnownSolutionParameter { 83 get { return (OptionalValueParameter<VRPSolution>)Parameters["BestKnownSolution"]; } 84 } 85 86 IValueParameter<DoubleValue> IVRPProblemInstance.BestKnownQualityParameter { 87 get { return BestKnownQualityParameter; } 88 } 89 90 IValueParameter<VRPSolution> IVRPProblemInstance.BestKnownSolutionParameter { 91 get { return BestKnownSolutionParameter; } 92 } 93 79 94 public DoubleMatrix Coordinates { 80 95 get { return CoordinatesParameter.Value; } … … 109 124 get { return DistanceFactorParameter.Value; } 110 125 set { DistanceFactorParameter.Value = value; } 126 } 127 128 public DoubleValue BestKnownQuality { 129 get { return BestKnownQualityParameter.Value; } 130 set { BestKnownQualityParameter.Value = value; } 131 } 132 public VRPSolution BestKnownSolution { 133 get { return BestKnownSolutionParameter.Value; } 134 set { BestKnownSolutionParameter.Value = value; } 111 135 } 112 136 … … 171 195 public double Evaluate(Tour tour) { 172 196 return EvaluatorParameter.Value.Evaluate(this, tour).Quality; 197 } 198 199 protected void EvalBestKnownSolution() { 200 if (BestKnownSolution != null) { 201 //call evaluator 202 BestKnownQuality = new DoubleValue(Evaluate(BestKnownSolution.Solution)); 203 BestKnownSolution.Quality = BestKnownQuality; 204 } else { 205 BestKnownQuality = null; 206 } 173 207 } 174 208 … … 192 226 Parameters.Add(new ValueParameter<IVRPCreator>("SolutionCreator", "The operator which should be used to create new VRP solutions.", Creator)); 193 227 Parameters.Add(new ValueParameter<IVRPEvaluator>("Evaluator", "The operator which should be used to evaluate VRP solutions.", Evaluator)); 228 229 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 230 Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 231 232 AttachEventHandlers(); 194 233 } 195 234 196 235 protected VRPProblemInstance(VRPProblemInstance original, Cloner cloner) 197 236 : base(original, cloner) { 198 } 237 AttachEventHandlers(); 238 } 239 240 [StorableHook(HookType.AfterDeserialization)] 241 private void AfterDeserializationHook() { 242 #region Backwards Compatibility 243 if (!Parameters.ContainsKey("BestKnownSolution")) { 244 Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this TSP instance.")); 245 } 246 #endregion 247 248 AttachEventHandlers(); 249 } 250 251 private void AttachEventHandlers() { 252 BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged); 253 DistanceFactorParameter.ValueChanged += new EventHandler(DistanceFactorParameter_ValueChanged); 254 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged); 255 FleetUsageFactorParameter.ValueChanged += new EventHandler(FleetUsageFactorParameter_ValueChanged); 256 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged); 257 DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged); 258 if (DistanceMatrix != null) { 259 DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged); 260 DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset); 261 } 262 UseDistanceMatrixParameter.ValueChanged += new EventHandler(UseDistanceMatrixParameter_ValueChanged); 263 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged); 264 } 265 266 #region Event handlers 267 void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) { 268 EvalBestKnownSolution(); 269 } 270 void DistanceFactorParameter_ValueChanged(object sender, EventArgs e) { 271 DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged); 272 EvalBestKnownSolution(); 273 } 274 void DistanceFactor_ValueChanged(object sender, EventArgs e) { 275 EvalBestKnownSolution(); 276 } 277 void FleetUsageFactorParameter_ValueChanged(object sender, EventArgs e) { 278 FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged); 279 EvalBestKnownSolution(); 280 } 281 void FleetUsageFactor_ValueChanged(object sender, EventArgs e) { 282 EvalBestKnownSolution(); 283 } 284 void DistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 285 if (DistanceMatrix != null) { 286 DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged); 287 DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset); 288 } 289 EvalBestKnownSolution(); 290 } 291 void DistanceMatrix_Reset(object sender, EventArgs e) { 292 EvalBestKnownSolution(); 293 } 294 void DistanceMatrix_ItemChanged(object sender, EventArgs<int, int> e) { 295 EvalBestKnownSolution(); 296 } 297 void UseDistanceMatrixParameter_ValueChanged(object sender, EventArgs e) { 298 UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged); 299 EvalBestKnownSolution(); 300 } 301 void UseDistanceMatrix_ValueChanged(object sender, EventArgs e) { 302 EvalBestKnownSolution(); 303 } 304 #endregion 199 305 } 200 306 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r4752 r4860 64 64 get { return BestKnownQualityParameter; } 65 65 } 66 public OptionalValueParameter<VRPSolution> BestKnownSolutionParameter { 67 get { return (OptionalValueParameter<VRPSolution>)Parameters["BestKnownSolution"]; } 68 } 66 69 public IValueParameter<IVRPCreator> SolutionCreatorParameter { 67 70 get { return (IValueParameter<IVRPCreator>)Parameters["SolutionCreator"]; } … … 82 85 get { return ProblemInstanceParameter.Value; } 83 86 set { ProblemInstanceParameter.Value = value; } 87 } 88 89 public VRPSolution BestKnownSolution { 90 get { return BestKnownSolutionParameter.Value; } 91 set { BestKnownSolutionParameter.Value = value; } 84 92 } 85 93 … … 111 119 Parameters.Add(new ValueParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance")); 112 120 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 121 Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance.")); 113 122 114 123 operators = new List<IOperator>(); … … 172 181 Parameters.Remove("SolutionCreator"); 173 182 183 if (Parameters.ContainsKey("BestKnownSolution")) 184 Parameters.Remove("BestKnownSolution"); 185 186 if (Parameters.ContainsKey("BestKnownQuality")) 187 Parameters.Remove("BestKnownQuality"); 188 189 174 190 if (ProblemInstance != null) { 175 191 ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); … … 177 193 Parameters.Add(ProblemInstance.EvaluatorParameter); 178 194 Parameters.Add(ProblemInstance.SolutionCreatorParameter); 195 196 Parameters.Add(ProblemInstance.BestKnownQualityParameter); 197 Parameters.Add(ProblemInstance.BestKnownSolutionParameter); 179 198 } 180 199 } … … 251 270 int problemSize = parser.Demands.Length; 252 271 253 if (parser.Depot != 1) 254 throw new Exception("Invalid depot specification"); 255 256 if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) 257 throw new Exception("Invalid weight type"); 272 if (parser.Depot != 1) { 273 ErrorHandling.ShowErrorDialog(new Exception("Invalid depot specification")); 274 return; 275 } 276 277 if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) { 278 ErrorHandling.ShowErrorDialog(new Exception("Invalid weight type")); 279 return; 280 } 258 281 259 282 CVRPTWProblemInstance problem = new CVRPTWProblemInstance(); … … 337 360 this.ProblemInstance = problem; 338 361 } 362 363 public void ImportSolution(string solutionFileName) { 364 SolutionParser parser = new SolutionParser(solutionFileName); 365 parser.Parse(); 366 367 HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinEncoding encoding = new Encodings.Potvin.PotvinEncoding(ProblemInstance); 368 369 int cities = 0; 370 foreach (List<int> route in parser.Routes) { 371 Tour tour = new Tour(); 372 tour.Stops.AddRange(route); 373 cities += tour.Stops.Count; 374 375 encoding.Tours.Add(tour); 376 } 377 378 if (cities != ProblemInstance.Coordinates.Rows - 1) 379 ErrorHandling.ShowErrorDialog(new Exception("The optimal solution does not seem to correspond with the problem data")); 380 else { 381 VRPSolution solution = new VRPSolution(ProblemInstance, encoding, new DoubleValue(0)); 382 ProblemInstance.BestKnownSolutionParameter.Value = solution; 383 } 384 } 339 385 } 340 386 }
Note: See TracChangeset
for help on using the changeset viewer.