Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/19/15 17:33:06 (9 years ago)
Author:
pfleck
Message:

#2269 When creating a new layer, reset the old results (e.g. quality chart) to NaN to symbolize that the layer did not exist during that time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/LayerCreator.cs

    r12018 r13037  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Analysis;
     
    2827using HeuristicLab.Data;
    2928using HeuristicLab.Operators;
     29using HeuristicLab.Optimization;
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    7373      scopes.Add(clone);
    7474
     75      // Set new layernumber
    7576      clone.Variables["Layer"].Value = new IntValue(OpenLayersParameter.ActualValue.Value);
     77
     78      // Decrement ages, because MainOperator is goint to increment it
    7679      foreach (var solution in clone.SubScopes)
    77         ((IntValue)solution.Variables["Age"].Value).Value -= 1; // Decrement age, because MainOperator is goint to increment it
    78       //foreach (var variable in clone.Variables.Where(v => !SavedVariables.Contains(v.Name)))
    79       //  variable.Value = null;
     80        ((IntValue)solution.Variables["Age"].Value).Value -= 1;
    8081
    81       //HACK: delete old values from quality table
    82       /*var rows = ((DataTable)clone.Variables["Qualities"].Value).Rows;
    83       var last = rows.Last();
    84       rows.Clear();
    85       rows.Add(last);*/
     82      // Reset existing values in the results to NaN to symbolize that no layer existed during that duration
     83      var results = (ResultCollection)clone.Variables["LayerResults"].Value;
     84      ResetResults(results);
    8685
    8786      return base.Apply();
    8887    }
    8988
     89    private void ResetResults(ResultCollection results) {
     90      var values = results.Select(r => r.Value);
     91
     92      // Reset all values within results in results
     93      foreach (var resultsCollection in values.OfType<ResultCollection>())
     94        ResetResults(resultsCollection);
     95
     96      // Reset values
     97      foreach (var dataTable in values.OfType<DataTable>()) {
     98        foreach (var row in dataTable.Rows)
     99          for (int i = 0; i < row.Values.Count; i++)
     100            row.Values[i] = double.NaN;
     101      }
     102    }
     103
    90104  }
    91105}
Note: See TracChangeset for help on using the changeset viewer.