Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7124


Ignore:
Timestamp:
12/05/11 15:02:42 (13 years ago)
Author:
bburlacu
Message:

#1661: Improved naming of variables and replaced literals with constants. Added new IsVisibleInLegend visual property for data rows.

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r6978 r7124  
    203203        case DataRowVisualProperties.DataRowChartType.Histogram:
    204204          series.ChartType = SeriesChartType.Column;
     205          series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
    205206          series.SetCustomProperty("PointWidth", "1");
    206207          if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25)
  • trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs

    r6978 r7124  
    152152      }
    153153    }
     154    private bool isVisibleInLegend;
     155    public bool IsVisibleInLegend {
     156      get { return isVisibleInLegend; }
     157      set {
     158        if (isVisibleInLegend != value) {
     159          isVisibleInLegend = value;
     160          OnPropertyChanged("IsVisibleInLegend");
     161        }
     162      }
     163    }
    154164    private string displayName;
    155165    public string DisplayName {
     
    218228      get { return scaleFactor; }
    219229      set { scaleFactor = value; }
     230    }
     231    [Storable(Name = "IsVisibleInLegend")]
     232    private bool StorableIsVisibleInLegend {
     233      get { return isVisibleInLegend; }
     234      set { isVisibleInLegend = value; }
    220235    }
    221236    [Storable(Name = "DisplayName")]
     
    241256      this.scaleFactor = original.scaleFactor;
    242257      this.displayName = original.displayName;
     258      this.isVisibleInLegend = original.isVisibleInLegend;
    243259    }
    244260    public DataRowVisualProperties() {
     
    254270      scaleFactor = 1.0;
    255271      displayName = String.Empty;
     272      isVisibleInLegend = true;
    256273    }
    257274    public DataRowVisualProperties(string displayName)
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs

    r6978 r7124  
    5252    }
    5353    public ValueLookupParameter<DataTable> SymbolicExpressionTreeLengthsParameter {
    54       get {
    55         return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName];
    56       }
     54      get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName]; }
    5755    }
    5856    public ValueLookupParameter<DataTableHistory> SymbolicExpressionTreeLengthsHistoryParameter {
    59       get {
    60         return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName];
    61       }
     57      get { return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName]; }
    6258    }
    6359    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    7571    }
    7672    #endregion
     73
    7774    [StorableConstructor]
    7875    private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base() { }
     
    9188      Parameters.Add(new ValueLookupParameter<DataTableHistory>(SymbolicExpressionTreeLengthsHistoryParameterName, "The data table to store the symbolic expression tree lengths history."));
    9289      Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    93 
    94       #region Add parameters for history
    9590      Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false)));
    9691      Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
    9792      Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", "MinMaxAverageSymbolicExpressionTreeLengthAnalyzerUpdateCounter"));
    98       #endregion
    9993
    10094      UpdateCounterParameter.Hidden = true;
     
    136130        // if the table was not created yet, we create it here
    137131        if (treeLengthsTable == null) {
    138           treeLengthsTable = new DataTable("Tree Length Values");
     132          treeLengthsTable = new DataTable("Histogram");
    139133          SymbolicExpressionTreeLengthsParameter.ActualValue = treeLengthsTable;
    140134        }
    141135
    142136        // data table which stores tree length values
    143         DataRow dataRow;
     137        DataRow treeLengthsTableRow;
     138
     139        const string treeLengthsTableRowName = "Symbolic expression tree lengths";
     140        const string treeLengthsTableRowDesc = "The distribution of symbolic expression tree lengths";
     141        const string xAxisTitle = "Symbolic expression tree lengths";
     142        const string yAxisTitle = "Frequency / Number of tree individuals";
    144143
    145144        var treeLengths = solutions.Select(s => (double)s.Length);
    146 
    147         if (!treeLengthsTable.Rows.ContainsKey("Tree Lengths")) {
    148           dataRow = new DataRow("Tree Lengths", "", treeLengths);
    149           treeLengthsTable.Rows.Add(dataRow);
     145        int maxLength = solutions.Max(s => s.Length);
     146        int minLength = solutions.Min(s => s.Length);
     147
     148        if (!treeLengthsTable.Rows.ContainsKey(treeLengthsTableRowName)) {
     149          treeLengthsTableRow = new DataRow(treeLengthsTableRowName, treeLengthsTableRowDesc, treeLengths);
     150          treeLengthsTable.Rows.Add(treeLengthsTableRow);
    150151        } else {
    151           dataRow = treeLengthsTable.Rows["Tree Lengths"];
    152           dataRow.Values.Replace(treeLengths);
     152          treeLengthsTableRow = treeLengthsTable.Rows[treeLengthsTableRowName];
     153          treeLengthsTableRow.Values.Replace(treeLengths);
    153154        }
    154155
    155156        double maximumAllowedTreeLength = ((LookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]).ActualValue.Value;
    156157
    157         dataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    158         dataRow.VisualProperties.ExactBins = false;
    159 
    160         // the following trick should result in an intervalWidth of 1,2,4,... (an int value)
    161         dataRow.VisualProperties.Bins = solutions.Max(s => s.Length) - solutions.Min(s => s.Length);
    162 
    163         int maxLength = solutions.Max(s => s.Length);
    164         if (maxLength <= 25)      // [0,25]
    165           dataRow.VisualProperties.ScaleFactor = 1.0;
     158        treeLengthsTableRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     159        treeLengthsTableRow.VisualProperties.ExactBins = false;
     160
     161        // the following trick should result in an integer intervalWidth of 1,2,4,...
     162        treeLengthsTableRow.VisualProperties.Bins = maxLength - minLength;
     163
     164        if (maxLength <= 25) // [0,25]
     165          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0;
    166166        else if (maxLength <= 100) // [26,100])
    167           dataRow.VisualProperties.ScaleFactor = 1.0 / 2.0;
     167          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 2.0;
    168168        else if (maxLength <= 250) // [100,250]
    169           dataRow.VisualProperties.ScaleFactor = 1.0 / 5.0;
     169          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 5.0;
    170170        else if (maxLength <= 500) // [251,500]
    171           dataRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
     171          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
    172172        else
    173           dataRow.VisualProperties.ScaleFactor = 1.0 / 20.0;   // [501,inf]
     173          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 20.0; // [501,inf]
     174
     175        treeLengthsTableRow.VisualProperties.IsVisibleInLegend = false;
    174176
    175177        // visual properties for the X-axis
     
    178180        treeLengthsTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    179181        if (maxLength > maximumAllowedTreeLength + 1)
    180           treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = solutions.Max(s => s.Length) + 1; // +1 so the histogram column for the maximum length won't get trimmed
     182          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    181183        else
    182184          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
     185        treeLengthsTable.VisualProperties.XAxisTitle = xAxisTitle;
    183186        // visual properties for the Y-axis
    184187        treeLengthsTable.VisualProperties.YAxisMinimumAuto = false;
     
    186189        treeLengthsTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    187190        treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
     191        treeLengthsTable.VisualProperties.YAxisTitle = yAxisTitle;
    188192
    189193        var results = ResultsParameter.ActualValue;
    190194
    191         if (!results.ContainsKey("Tree Lengths")) {
    192           results.Add(new Result("Tree Lengths", treeLengthsTable));
     195        if (!results.ContainsKey(treeLengthsTableRowName)) {
     196          results.Add(new Result(treeLengthsTableRowName, treeLengthsTable));
    193197        } else {
    194           results["Tree Lengths"].Value = treeLengthsTable;
     198          results[treeLengthsTableRowName].Value = treeLengthsTable;
    195199        }
    196200
    197201        bool storeHistory = StoreHistoryParameter.Value.Value;
     202        const string treeLengthHistoryTableName = "Tree lengths history";
     203        const string treeLengthHistoryRowPrefix = "Tree lengths ";
     204        int currentGeneration = ((IntValue)results["Generations"].Value).Value;
    198205
    199206        if (storeHistory) {
    200207          // store tree lengths for each generation
    201           var historyDataRow = new DataRow("Tree Lengths " + results["Generations"].Value, "", dataRow.Values);
     208          var historyDataRow = new DataRow(treeLengthHistoryRowPrefix + currentGeneration, "Symbolic expression tree lengths at generation " + currentGeneration, treeLengthsTableRow.Values);
    202209          historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    203210          historyDataRow.VisualProperties.ExactBins = false;
    204           historyDataRow.VisualProperties.Bins = solutions.Max(s => s.Length) - solutions.Min(s => s.Length);
    205           historyDataRow.VisualProperties.ScaleFactor = dataRow.VisualProperties.ScaleFactor;
    206           var historyTable = new DataTable("Lengths Table " + results["Generations"]);
     211          historyDataRow.VisualProperties.Bins = maxLength - minLength;
     212          historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor;
     213          var historyTable = new DataTable();
    207214          historyTable.Rows.Add(historyDataRow);
    208215          // visual properties for the X-axis
     
    210217          historyTable.VisualProperties.XAxisMaximumAuto = false;
    211218          historyTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    212           if (solutions.Max(s => s.Length) > maximumAllowedTreeLength + 1)
     219          if (maxLength > maximumAllowedTreeLength + 1)
    213220            historyTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    214221          else
    215222            historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
     223          historyTable.VisualProperties.XAxisTitle = xAxisTitle;
    216224          // visual properties for the Y-axis
    217225          historyTable.VisualProperties.YAxisMinimumAuto = false;
     
    219227          historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    220228          historyTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
     229          historyTable.VisualProperties.YAxisTitle = yAxisTitle;
    221230
    222231          var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue;
     
    228237          treeLengthsHistory.Add(historyTable);
    229238
    230           if (!results.ContainsKey("Tree Lengths History")) {
    231             results.Add(new Result("Tree Lengths History", treeLengthsHistory));
     239          if (!results.ContainsKey(treeLengthHistoryTableName)) {
     240            results.Add(new Result(treeLengthHistoryTableName, treeLengthsHistory));
    232241          } else {
    233             results["Tree Lengths History"].Value = treeLengthsHistory;
     242            results[treeLengthHistoryTableName].Value = treeLengthsHistory;
    234243          }
    235244        }
    236245      }
    237 
    238246      return base.Apply();
    239247    }
Note: See TracChangeset for help on using the changeset viewer.