- Timestamp:
- 11/19/10 15:43:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.