Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/09/17 13:59:36 (7 years ago)
Author:
abeham
Message:

#2736:

  • Implemented review comments
  • I had to restructure the parser to a greater extent because I found out that some instances defined nodes without edges (which I decided to filter)
  • I added a unit test that loads all instances
  • I also added export of instances
Location:
trunk/sources/HeuristicLab.Problems.GraphColoring/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs

    r15050 r15172  
    3838  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 135)]
    3939  [StorableClass]
    40   public sealed class GraphColoringProblem : SingleObjectiveBasicProblem<LinearLinkageEncoding>, IProblemInstanceConsumer<GCPData> {
     40  public sealed class GraphColoringProblem : SingleObjectiveBasicProblem<LinearLinkageEncoding>, IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> {
    4141
    4242    public override bool Maximization {
     
    115115    private void FitnessFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) {
    116116      fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;
    117       OnReset();
     117      FitnessFunctionOnValueChanged(sender, eventArgs);
    118118    }
    119119
    120120    private void FitnessFunctionOnValueChanged(object sender, EventArgs eventArgs) {
    121121      BestKnownQualityParameter.Value = null;
     122      if (FitnessFunction == FitnessFunction.Prioritized
     123        && BestKnownColorsParameter.Value != null
     124        && Encoding.Length > 0) {
     125        var mag = Math.Pow(10, -(int)Math.Ceiling(Math.Log10(Encoding.Length)));
     126        // the value is e.g. 0.051 for 0 conflicts with 51 colors (and less than 1000 nodes)
     127        BestKnownQuality = BestKnownColorsParameter.Value.Value * mag;
     128      } else BestKnownQualityParameter.Value = null;
    122129      OnReset();
    123130    }
     
    242249      Description = data.Description;
    243250      OnReset();
     251    }
     252
     253    public GCPData Export() {
     254      var instance = new GCPData();
     255      instance.Name = Name;
     256      instance.Description = Description;
     257      instance.Nodes = Encoding.Length;
     258      var adjList = AdjacencyListParameter.Value;
     259      instance.Adjacencies = new int[adjList.Rows, 2];
     260      for (var r = 0; r < adjList.Rows; r++) {
     261        instance.Adjacencies[r, 0] = adjList[r, 0];
     262        instance.Adjacencies[r, 1] = adjList[r, 1];
     263      }
     264      if (BestKnownColorsParameter.Value != null)
     265        instance.BestKnownColors = BestKnownColorsParameter.Value.Value;
     266      return instance;
    244267    }
    245268
  • trunk/sources/HeuristicLab.Problems.GraphColoring/3.3/HeuristicLab.Problems.GraphColoring-3.3.csproj

    r15050 r15172  
    125125    </ProjectReference>
    126126    <ProjectReference Include="..\..\HeuristicLab.Encodings.LinearLinkageEncoding\3.4\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj">
    127       <Project>{166507c9-ef26-4370-bb80-699742a29d4f}</Project>
     127      <Project>{be698769-975a-429e-828c-72bb2b6182c8}</Project>
    128128      <Name>HeuristicLab.Encodings.LinearLinkageEncoding-3.4</Name>
    129129      <Private>False</Private>
Note: See TracChangeset for help on using the changeset viewer.