Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7316


Ignore:
Timestamp:
01/11/12 15:07:10 (13 years ago)
Author:
svonolfe
Message:

Added Picture generator (#1696)

Location:
branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/Program.cs

    r7315 r7316  
    55using System.Text;
    66using System.IO;
     7using System.Drawing;
    78
    89namespace VRPProblemAnalyzer {
    910 
    1011  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     }
    1712
    1813    private static double[] GetDistances(double[,] vertices) {
     
    2318        for (int j = 0; j < cities; j++) {
    2419          if (i != j) {
    25             result.Add(GetDistance(vertices, i, j));
     20            result.Add(Utils.GetDistance(vertices, i, j));
    2621          }
    2722        }
     
    3934        for (int j = 0; j < cities; j++) {
    4035          if (i != j) {
    41             distance += GetDistance(vertices, i, j);
     36            distance += Utils.GetDistance(vertices, i, j);
    4237          }
    4338        }
     
    187182          instance.Demands[i] = instance.Demands[i] / instance.Capacity;
    188183      }
     184      instance.Capacity = 1.0;
    189185
    190186      //normalize coordinates
     
    199195      var factor = Math.Sqrt(0.5)/Math.Max(rangeX, rangeY);
    200196
    201 
    202197      for (int i = 0; i < instance.Vertices.GetLength(0); i++) {
    203198        instance.Vertices[i, 0] = (cities[i].X-minX)*factor;
     
    221216          Normalize(parser);
    222217
    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);
    224225          sw.Write(';');
    225226          sw.Write(parser.Vertices.Length / 2 - 1);
     
    242243          sw.Write(';');
    243244          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();
    248253    }
    249254  }
  • branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/TSPLIBParser.cs

    r7231 r7316  
    8989      get {
    9090        return capacity;
     91      }
     92      set {
     93        capacity = value;
    9194      }
    9295    }
  • branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/Utils.cs

    r7315 r7316  
    1515      return points;
    1616    }
     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    }
    1723  }
    1824}
  • branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/VRPProblemAnalyzer.csproj

    r7315 r7316  
    104104    <Reference Include="System" />
    105105    <Reference Include="System.Core" />
     106    <Reference Include="System.Drawing" />
     107    <Reference Include="System.Windows.Forms" />
     108    <Reference Include="System.Windows.Forms.DataVisualization" />
    106109    <Reference Include="System.Xml.Linq" />
    107110    <Reference Include="System.Data.DataSetExtensions" />
     
    112115  <ItemGroup>
    113116    <Compile Include="EnumerableExtensions.cs" />
     117    <Compile Include="PictureGenerator.cs" />
    114118    <Compile Include="PointD.cs" />
    115119    <Compile Include="DepotExcentricityCalculator.cs" />
     
    117121    <Compile Include="Program.cs" />
    118122    <Compile Include="Properties\AssemblyInfo.cs" />
     123    <Compile Include="SolutionParser.cs" />
    119124    <Compile Include="TSPLIBParser.cs" />
    120125    <Compile Include="Utils.cs" />
Note: See TracChangeset for help on using the changeset viewer.