Changeset 7316
- Timestamp:
- 01/11/12 15:07:10 (13 years ago)
- Location:
- branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/Program.cs
r7315 r7316 5 5 using System.Text; 6 6 using System.IO; 7 using System.Drawing; 7 8 8 9 namespace VRPProblemAnalyzer { 9 10 10 11 public class Program { 11 12 private static double GetDistance(double[,] vertices, int source, int target) {13 return Math.Sqrt(14 Math.Pow((vertices[source, 0] - vertices[target, 0]), 2) +15 Math.Pow((vertices[source, 1] - vertices[target, 1]), 2));16 }17 12 18 13 private static double[] GetDistances(double[,] vertices) { … … 23 18 for (int j = 0; j < cities; j++) { 24 19 if (i != j) { 25 result.Add( GetDistance(vertices, i, j));20 result.Add(Utils.GetDistance(vertices, i, j)); 26 21 } 27 22 } … … 39 34 for (int j = 0; j < cities; j++) { 40 35 if (i != j) { 41 distance += GetDistance(vertices, i, j);36 distance += Utils.GetDistance(vertices, i, j); 42 37 } 43 38 } … … 187 182 instance.Demands[i] = instance.Demands[i] / instance.Capacity; 188 183 } 184 instance.Capacity = 1.0; 189 185 190 186 //normalize coordinates … … 199 195 var factor = Math.Sqrt(0.5)/Math.Max(rangeX, rangeY); 200 196 201 202 197 for (int i = 0; i < instance.Vertices.GetLength(0); i++) { 203 198 instance.Vertices[i, 0] = (cities[i].X-minX)*factor; … … 221 216 Normalize(parser); 222 217 223 sw.Write(Path.GetFileNameWithoutExtension(instance)); 218 string instanceName = Path.GetFileNameWithoutExtension(instance); 219 220 string solutionName = Path.Combine(Path.GetDirectoryName(instance), Path.GetFileNameWithoutExtension(instance) + ".opt"); 221 SolutionParser solution = new SolutionParser(solutionName); 222 solution.Parse(); 223 224 sw.Write(instanceName); 224 225 sw.Write(';'); 225 226 sw.Write(parser.Vertices.Length / 2 - 1); … … 242 243 sw.Write(';'); 243 244 sw.WriteLine(); 244 } 245 } 246 Console.WriteLine("Done. Press Enter..."); 247 Console.ReadLine(); 245 246 247 Image picture = PictureGenerator.GeneratePicture(parser, solution); 248 picture.Save(Path.Combine(path, instanceName + ".png")); 249 } 250 } 251 //Console.WriteLine("Done. Press Enter..."); 252 //Console.ReadLine(); 248 253 } 249 254 } -
branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/TSPLIBParser.cs
r7231 r7316 89 89 get { 90 90 return capacity; 91 } 92 set { 93 capacity = value; 91 94 } 92 95 } -
branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/Utils.cs
r7315 r7316 15 15 return points; 16 16 } 17 18 public static double GetDistance(double[,] vertices, int source, int target) { 19 return Math.Sqrt( 20 Math.Pow((vertices[source, 0] - vertices[target, 0]), 2) + 21 Math.Pow((vertices[source, 1] - vertices[target, 1]), 2)); 22 } 17 23 } 18 24 } -
branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/VRPProblemAnalyzer.csproj
r7315 r7316 104 104 <Reference Include="System" /> 105 105 <Reference Include="System.Core" /> 106 <Reference Include="System.Drawing" /> 107 <Reference Include="System.Windows.Forms" /> 108 <Reference Include="System.Windows.Forms.DataVisualization" /> 106 109 <Reference Include="System.Xml.Linq" /> 107 110 <Reference Include="System.Data.DataSetExtensions" /> … … 112 115 <ItemGroup> 113 116 <Compile Include="EnumerableExtensions.cs" /> 117 <Compile Include="PictureGenerator.cs" /> 114 118 <Compile Include="PointD.cs" /> 115 119 <Compile Include="DepotExcentricityCalculator.cs" /> … … 117 121 <Compile Include="Program.cs" /> 118 122 <Compile Include="Properties\AssemblyInfo.cs" /> 123 <Compile Include="SolutionParser.cs" /> 119 124 <Compile Include="TSPLIBParser.cs" /> 120 125 <Compile Include="Utils.cs" />
Note: See TracChangeset
for help on using the changeset viewer.