Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/17 21:02:01 (7 years ago)
Author:
abeham
Message:

#2666, #2706, #2730, #2736: merged revisions 14412, 14475, 14476, 14659, 14660, 14663, 14779, 14780, 14912, 15050, 15067, 15069, 15079, 15162, 15166, 15172, 15173 to stable

Location:
stable
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs

    r15050 r15217  
    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
Note: See TracChangeset for help on using the changeset viewer.