- Timestamp:
- 08/04/14 14:12:16 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Instances.Orienteering/3.3/HeuristicLab.Problems.Instances.Orienteering-3.3.csproj
r11260 r11261 45 45 <ItemGroup> 46 46 <Compile Include="SchildeOPParser.cs" /> 47 <EmbeddedResource Include="Data\SchildeOP.zip" /> 47 48 <None Include="HeuristicLab.snk" /> 48 49 <None Include="Plugin.cs.frame" /> -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Instances.Orienteering/3.3/SchildeOPParser.cs
r11260 r11261 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Globalization; 23 25 using System.IO; 24 26 using System.Linq; … … 26 28 namespace HeuristicLab.Problems.Instances.Orienteering { 27 29 public class SchildeOPParser { 30 private static readonly IFormatProvider FormatProvider = new CultureInfo("en-US"); 31 28 32 private int currentPoint; 29 33 private int currentDistance; … … 112 116 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 113 117 114 Coordinates[currentPoint, 0] = double.Parse(positionX );115 Coordinates[currentPoint, 1] = double.Parse(positionY );118 Coordinates[currentPoint, 0] = double.Parse(positionX, FormatProvider); 119 Coordinates[currentPoint, 1] = double.Parse(positionY, FormatProvider); 116 120 117 121 // Extract all score values for this point … … 122 126 score = inputString.Substring(0, inputString.IndexOf(',')); 123 127 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 124 Scores[currentPoint, scoreIndex++] = int.Parse(score );128 Scores[currentPoint, scoreIndex++] = int.Parse(score, FormatProvider); 125 129 } else { 126 130 score = inputString; 127 Scores[currentPoint, scoreIndex++] = int.Parse(score );131 Scores[currentPoint, scoreIndex++] = int.Parse(score, FormatProvider); 128 132 break; 129 133 } … … 148 152 distance = inputString.Substring(0, inputString.IndexOf(',')); 149 153 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 150 Distances[currentDistance, distanceIndex++] = double.Parse(distance );154 Distances[currentDistance, distanceIndex++] = double.Parse(distance, FormatProvider); 151 155 } else { 152 156 distance = inputString; 153 Distances[currentDistance, distanceIndex++] = double.Parse(distance );157 Distances[currentDistance, distanceIndex++] = double.Parse(distance, FormatProvider); 154 158 break; 155 159 } … … 165 169 // Extract the number of points 166 170 167 pointCount = int.Parse(inputString );171 pointCount = int.Parse(inputString, FormatProvider); 168 172 Coordinates = new double[pointCount, 2]; 169 173 break; … … 196 200 // Remove the 's,' 197 201 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 198 int scoreCount = int.Parse(inputString );199 200 pointCount = int.Parse(inputString);202 int scoreCount = int.Parse(inputString, FormatProvider); 203 204 pointCount = Coordinates.GetLength(0); 201 205 Scores = new double[pointCount, scoreCount]; 202 206 … … 209 213 // Remove the 'b,' 210 214 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 211 StartingPoint = int.Parse(inputString );215 StartingPoint = int.Parse(inputString, FormatProvider); 212 216 break; 213 217 … … 218 222 // Remove the 'e,' 219 223 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 220 TerminusPoint = int.Parse(inputString );224 TerminusPoint = int.Parse(inputString, FormatProvider); 221 225 break; 222 226 … … 232 236 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 233 237 234 UpperBoundConstraint = double.Parse(inputString );238 UpperBoundConstraint = double.Parse(inputString, FormatProvider); 235 239 break; 236 240 … … 246 250 inputString = inputString.Remove(0, inputString.IndexOf(',') + 1); 247 251 248 LowerConstraint = double.Parse(inputString );252 LowerConstraint = double.Parse(inputString, FormatProvider); 249 253 break; 250 254 -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r11245 r11261 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 32 using HeuristicLab.Problems.Instances; 33 using HeuristicLab.Problems.Instances.Types; 33 34 34 35 namespace HeuristicLab.Problems.Orienteering { … … 39 40 public class OrienteeringProblem 40 41 : SingleObjectiveHeuristicOptimizationProblem<IOrienteeringEvaluator, IIntegerVectorCreator>, 41 IStorableContent, IProblemInstanceConsumer<CVRPData> {42 IStorableContent, IProblemInstanceConsumer<CVRPData>, IProblemInstanceConsumer<OPData> { 42 43 43 44 public string Filename { get; set; } … … 324 325 325 326 public void Load(CVRPData data) { 326 327 327 if (data.Coordinates == null) 328 328 throw new InvalidDataException("The given instance specifies no coordinates!"); … … 353 353 OnReset(); 354 354 } 355 356 public void Load(OPData data) { 357 if (data.Coordinates == null) 358 throw new InvalidDataException("The given instance specifies no coordinates!"); 359 if (data.Coordinates.GetLength(1) != 2) 360 throw new InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates."); 361 362 // Clear old solutions 363 BestKnownQuality = null; 364 BestKnownSolution = null; 365 366 Name = data.Name; 367 Description = data.Description; 368 369 Coordinates = new DoubleMatrix(data.Coordinates); 370 if (data.Distances != null) 371 DistanceMatrix = new DistanceMatrix(data.Distances); 372 else 373 data.GetDistanceMatrix(); 374 375 StartingPoint = new IntValue(data.StartingPoint); 376 TerminusPoint = new IntValue(data.TerminusPoint); 377 378 MaximumDistance = new DoubleValue(data.MaximumDistance); 379 Scores = new DoubleArray(data.Scores); 380 } 355 381 } 356 382 }
Note: See TracChangeset
for help on using the changeset viewer.