Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 11:45:18 (13 years ago)
Author:
gkronber
Message:

#1081 merged r7103:7209 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj

    r6866 r7213  
    176176  </ItemGroup>
    177177  <ItemGroup>
    178     <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
    179       <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
    180       <Name>HeuristicLab.Analysis-3.3</Name>
    181       <Private>False</Private>
    182     </ProjectReference>
    183     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    184       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    185       <Name>HeuristicLab.Collections-3.3</Name>
    186       <Private>False</Private>
    187     </ProjectReference>
    188     <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    189       <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    190       <Name>HeuristicLab.Common.Resources-3.3</Name>
    191       <Private>False</Private>
    192     </ProjectReference>
    193     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    194       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    195       <Name>HeuristicLab.Common-3.3</Name>
    196       <Private>False</Private>
    197     </ProjectReference>
    198     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    199       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    200       <Name>HeuristicLab.Core-3.3</Name>
    201       <Private>False</Private>
    202     </ProjectReference>
    203     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    204       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    205       <Name>HeuristicLab.Data-3.3</Name>
    206       <Private>False</Private>
    207     </ProjectReference>
    208     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    209       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    210       <Name>HeuristicLab.Operators-3.3</Name>
    211       <Private>False</Private>
    212     </ProjectReference>
    213     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    214       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    215       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    216       <Private>False</Private>
    217     </ProjectReference>
    218     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    219       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    220       <Name>HeuristicLab.Optimization-3.3</Name>
    221       <Private>False</Private>
    222     </ProjectReference>
    223     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    224       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    225       <Name>HeuristicLab.Parameters-3.3</Name>
    226       <Private>False</Private>
    227     </ProjectReference>
    228     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    229       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    230       <Name>HeuristicLab.Persistence-3.3</Name>
    231       <Private>False</Private>
    232     </ProjectReference>
    233     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    234       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    235       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    236       <Private>False</Private>
    237     </ProjectReference>
    238     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    239       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    240       <Name>HeuristicLab.Random-3.3</Name>
    241       <Private>False</Private>
    242     </ProjectReference>
     178    <Reference Include="HeuristicLab.Analysis-3.3">
     179      <HintPath>..\..\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     180      <Private>False</Private>
     181    </Reference>
     182    <Reference Include="HeuristicLab.Collections-3.3">
     183      <HintPath>..\..\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     184      <Private>False</Private>
     185    </Reference>
     186    <Reference Include="HeuristicLab.Common.Resources-3.3">
     187      <HintPath>..\..\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     188      <Private>False</Private>
     189    </Reference>
     190    <Reference Include="HeuristicLab.Common-3.3">
     191      <HintPath>..\..\bin\HeuristicLab.Common-3.3.dll</HintPath>
     192      <Private>False</Private>
     193    </Reference>
     194    <Reference Include="HeuristicLab.Core-3.3">
     195      <HintPath>..\..\bin\HeuristicLab.Core-3.3.dll</HintPath>
     196      <Private>False</Private>
     197    </Reference>
     198    <Reference Include="HeuristicLab.Data-3.3">
     199      <HintPath>..\..\bin\HeuristicLab.Data-3.3.dll</HintPath>
     200      <Private>False</Private>
     201    </Reference>
     202    <Reference Include="HeuristicLab.Operators-3.3">
     203      <HintPath>..\..\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     204      <Private>False</Private>
     205    </Reference>
     206    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
     207      <HintPath>..\..\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     208      <Private>False</Private>
     209    </Reference>
     210    <Reference Include="HeuristicLab.Optimization-3.3">
     211      <HintPath>..\..\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     212      <Private>False</Private>
     213    </Reference>
     214    <Reference Include="HeuristicLab.Parameters-3.3">
     215      <HintPath>..\..\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     216      <Private>False</Private>
     217    </Reference>
     218    <Reference Include="HeuristicLab.Persistence-3.3">
     219      <HintPath>..\..\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     220      <Private>False</Private>
     221    </Reference>
     222    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     223      <HintPath>..\..\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     224      <Private>False</Private>
     225    </Reference>
     226    <Reference Include="HeuristicLab.Random-3.3">
     227      <HintPath>..\..\bin\HeuristicLab.Random-3.3.dll</HintPath>
     228      <Private>False</Private>
     229    </Reference>
    243230  </ItemGroup>
    244231  <ItemGroup>
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeLengthAnalyzer.cs

    r5809 r7213  
    4343    private const string MaxTreeLengthParameterName = "Maximal symbolic expression tree length";
    4444    private const string ResultsParameterName = "Results";
     45
     46    public bool EnabledByDefault {
     47      get { return true; }
     48    }
    4549
    4650    #region parameter properties
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs

    r6803 r7213  
    5959    #endregion
    6060    #region properties
     61    public virtual bool EnabledByDefault {
     62      get { return true; }
     63    }
    6164    public BoolValue AggregrateSymbolsWithDifferentSubtreeCount {
    6265      get { return AggregateSymbolsWithDifferentSubtreeCountParameter.Value; }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs

    r6978 r7213  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    2423using HeuristicLab.Analysis;
     
    5251    }
    5352    public ValueLookupParameter<DataTable> SymbolicExpressionTreeLengthsParameter {
    54       get {
    55         return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName];
    56       }
     53      get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName]; }
    5754    }
    5855    public ValueLookupParameter<DataTableHistory> SymbolicExpressionTreeLengthsHistoryParameter {
    59       get {
    60         return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName];
    61       }
     56      get { return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName]; }
    6257    }
    6358    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    7166      get { return (ValueParameter<IntValue>)Parameters[UpdateIntervalParameterName]; }
    7267    }
    73     public LookupParameter<IntValue> UpdateCounterParameter {
    74       get { return (LookupParameter<IntValue>)Parameters[UpdateCounterParameterName]; }
     68    public ValueParameter<IntValue> UpdateCounterParameter {
     69      get { return (ValueParameter<IntValue>)Parameters[UpdateCounterParameterName]; }
    7570    }
    7671    #endregion
     72
     73    #region Properties
     74    public bool EnabledByDefault {
     75      get { return true; }
     76    }
     77    public IntValue UpdateInterval {
     78      get { return UpdateIntervalParameter.Value; }
     79    }
     80    public IntValue UpdateCounter {
     81      get { return UpdateCounterParameter.Value; }
     82    }
     83    public BoolValue StoreHistory {
     84      get { return StoreHistoryParameter.Value; }
     85    }
     86    #endregion
     87
    7788    [StorableConstructor]
    7889    private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base() { }
     
    91102      Parameters.Add(new ValueLookupParameter<DataTableHistory>(SymbolicExpressionTreeLengthsHistoryParameterName, "The data table to store the symbolic expression tree lengths history."));
    92103      Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    93 
    94       #region Add parameters for history
    95104      Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false)));
    96105      Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
    97       Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", "MinMaxAverageSymbolicExpressionTreeLengthAnalyzerUpdateCounter"));
    98       #endregion
    99 
    100       UpdateCounterParameter.Hidden = true;
     106      Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
    101107
    102108      AfterDeserialization();
     
    112118        Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
    113119      }
    114       if (!Parameters.ContainsKey(UpdateCounterParameterName)) {
    115         Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", "MinMaxAverageSymbolicExpressionTreeLengthAnalyzerUpdateCounter"));
    116       }
     120      if (Parameters.ContainsKey(UpdateCounterParameterName))
     121        Parameters.Remove(UpdateCounterParameterName);
     122      Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
     123
     124      SymbolicExpressionTreeLengthsParameter.Hidden = true;
     125      SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true;
     126      ResultsParameter.Hidden = true;
     127      UpdateCounterParameter.Hidden = true;
    117128    }
    118129
    119130    public override IOperation Apply() {
    120       int updateInterval = UpdateIntervalParameter.Value.Value;
    121       IntValue updateCounter = UpdateCounterParameter.ActualValue;
    122       // if the counter doesn't exist yet, we initialize it here with the current update interval
    123       if (updateCounter == null) {
    124         updateCounter = new IntValue(updateInterval);
    125         UpdateCounterParameter.ActualValue = updateCounter;
    126       } else updateCounter.Value++;
    127 
     131      UpdateCounter.Value++;
    128132      // the analyzer runs periodically, every 'updateInterval' times
    129       if (updateCounter.Value == updateInterval) {
    130         updateCounter.Value = 0; // reset counter
     133      if (UpdateCounter.Value == UpdateInterval.Value) {
     134        UpdateCounter.Value = 0; // reset counter
    131135
    132136        // compute all tree lengths and store them in the lengthsTable
     
    136140        // if the table was not created yet, we create it here
    137141        if (treeLengthsTable == null) {
    138           treeLengthsTable = new DataTable("Tree Length Values");
     142          treeLengthsTable = new DataTable("Histogram");
    139143          SymbolicExpressionTreeLengthsParameter.ActualValue = treeLengthsTable;
    140144        }
    141145
    142146        // data table which stores tree length values
    143         DataRow dataRow;
    144 
    145         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);
     147        DataRow treeLengthsTableRow;
     148
     149        const string treeLengthsTableRowName = "Symbolic expression tree lengths";
     150        const string treeLengthsTableRowDesc = "The distribution of symbolic expression tree lengths";
     151        const string xAxisTitle = "Symbolic expression tree lengths";
     152        const string yAxisTitle = "Frequency / Number of tree individuals";
     153
     154        var treeLengths = solutions.Select(s => (int)s.Length).ToList();
     155
     156        int maxLength = treeLengths.Max(t => t);
     157        int minLength = treeLengths.Min(t => t);
     158
     159        if (!treeLengthsTable.Rows.ContainsKey(treeLengthsTableRowName)) {
     160          treeLengthsTableRow = new DataRow(treeLengthsTableRowName, treeLengthsTableRowDesc, treeLengths.Select(x => (double)x));
     161          treeLengthsTable.Rows.Add(treeLengthsTableRow);
    150162        } else {
    151           dataRow = treeLengthsTable.Rows["Tree Lengths"];
    152           dataRow.Values.Replace(treeLengths);
     163          treeLengthsTableRow = treeLengthsTable.Rows[treeLengthsTableRowName];
     164          treeLengthsTableRow.Values.Replace(treeLengths.Select(x => (double)x));
    153165        }
    154166
    155167        double maximumAllowedTreeLength = ((LookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]).ActualValue.Value;
    156168
    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;
    166         else if (maxLength <= 100) // [26,100])
    167           dataRow.VisualProperties.ScaleFactor = 1.0 / 2.0;
    168         else if (maxLength <= 250) // [100,250]
    169           dataRow.VisualProperties.ScaleFactor = 1.0 / 5.0;
     169        treeLengthsTableRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     170        treeLengthsTableRow.VisualProperties.ExactBins = false;
     171
     172        int range = maxLength - minLength;
     173        if (range == 0) range = 1;
     174        // the following trick should result in an integer intervalWidth of 1,2,4,...
     175        treeLengthsTableRow.VisualProperties.Bins = range;
     176
     177        if (maxLength <= 25) // [0,25]
     178          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0;
     179        else if (maxLength <= 100) // [26,100]
     180          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 2.0;
     181        else if (maxLength <= 250) // [101,250]
     182          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 5.0;
    170183        else if (maxLength <= 500) // [251,500]
    171           dataRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
     184          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
    172185        else
    173           dataRow.VisualProperties.ScaleFactor = 1.0 / 20.0;   // [501,inf]
     186          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 20.0; // [501,inf]
     187
     188        treeLengthsTableRow.VisualProperties.IsVisibleInLegend = false;
    174189
    175190        // visual properties for the X-axis
     
    178193        treeLengthsTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    179194        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
     195          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    181196        else
    182197          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
    183         // visual properties for the Y-axis
     198        treeLengthsTable.VisualProperties.XAxisTitle = xAxisTitle;
     199        //visual properties for the Y-axis
    184200        treeLengthsTable.VisualProperties.YAxisMinimumAuto = false;
    185201        treeLengthsTable.VisualProperties.YAxisMaximumAuto = false;
    186202        treeLengthsTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    187         treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
     203        int maxFreq = solutions.GroupBy(s => s.Length).Max(g => g.Count());
     204        if (maxFreq % 5 != 0)
     205          maxFreq += (5 - maxFreq % 5);
     206        double yAxisMaximumFixedValue = maxFreq;
     207
     208        treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue;
     209        treeLengthsTable.VisualProperties.YAxisTitle = yAxisTitle;
    188210
    189211        var results = ResultsParameter.ActualValue;
    190212
    191         if (!results.ContainsKey("Tree Lengths")) {
    192           results.Add(new Result("Tree Lengths", treeLengthsTable));
     213        if (!results.ContainsKey(treeLengthsTableRowName)) {
     214          results.Add(new Result(treeLengthsTableRowName, treeLengthsTable));
    193215        } else {
    194           results["Tree Lengths"].Value = treeLengthsTable;
     216          results[treeLengthsTableRowName].Value = treeLengthsTable;
    195217        }
    196218
    197219        bool storeHistory = StoreHistoryParameter.Value.Value;
     220        const string treeLengthHistoryTableName = "Tree lengths history";
    198221
    199222        if (storeHistory) {
    200223          // store tree lengths for each generation
    201           var historyDataRow = new DataRow("Tree Lengths " + results["Generations"].Value, "", dataRow.Values);
     224          var historyDataRow = new DataRow("Tree lengths", "", treeLengthsTableRow.Values);
    202225          historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    203226          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"]);
     227          historyDataRow.VisualProperties.Bins = range;
     228          historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor;
     229          historyDataRow.VisualProperties.IsVisibleInLegend = false;
     230          var historyTable = new DataTable("Tree lengths");
    207231          historyTable.Rows.Add(historyDataRow);
    208232          // visual properties for the X-axis
     
    210234          historyTable.VisualProperties.XAxisMaximumAuto = false;
    211235          historyTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    212           if (solutions.Max(s => s.Length) > maximumAllowedTreeLength + 1)
     236          if (maxLength > maximumAllowedTreeLength + 1)
    213237            historyTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    214238          else
    215239            historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
     240          historyTable.VisualProperties.XAxisTitle = xAxisTitle;
    216241          // visual properties for the Y-axis
    217242          historyTable.VisualProperties.YAxisMinimumAuto = false;
    218243          historyTable.VisualProperties.YAxisMaximumAuto = false;
    219244          historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    220           historyTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
     245          historyTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue;
     246          historyTable.VisualProperties.YAxisTitle = yAxisTitle;
    221247
    222248          var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue;
     
    228254          treeLengthsHistory.Add(historyTable);
    229255
    230           if (!results.ContainsKey("Tree Lengths History")) {
    231             results.Add(new Result("Tree Lengths History", treeLengthsHistory));
     256          if (!results.ContainsKey(treeLengthHistoryTableName)) {
     257            results.Add(new Result(treeLengthHistoryTableName, treeLengthsHistory));
    232258          } else {
    233             results["Tree Lengths History"].Value = treeLengthsHistory;
     259            results[treeLengthHistoryTableName].Value = treeLengthsHistory;
    234260          }
    235261        }
    236262      }
    237 
    238263      return base.Apply();
    239264    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r7076 r7213  
    148148        throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero.");
    149149
     150      var allowedSymbols = seedNode.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0).ToList();
     151
    150152      for (var i = 0; i != arity; ++i) {
    151         var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol, i).Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0);
     153        var possibleSymbols = allowedSymbols.Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)).ToList();
    152154        var selectedSymbol = possibleSymbols.SelectRandom(random);
    153155        var tree = selectedSymbol.CreateTreeNode();
     
    158160      // Only iterate over the non-terminal nodes (those which have arity > 0)
    159161      // Start from depth 2 since the first two levels are formed by the rootNode and the seedNode
    160       foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
     162      foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0))
    161163        RecursiveGrowFull(random, subTree, 2, maxDepth);
    162164    }
     
    168170        throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
    169171
     172      var allowedSymbols = root.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList(); ;
     173
    170174      for (var i = 0; i != arity; ++i) {
    171         var possibleSymbols = root.Grammar.GetAllowedChildSymbols(root.Symbol, i);
    172         possibleSymbols = possibleSymbols.Where(s => s.InitialFrequency > 0.0 &&
    173                                           root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth &&
    174                                           root.Grammar.GetMaximumExpressionDepth(s) > maxDepth - currentDepth);
     175        var possibleSymbols = allowedSymbols.Where(s => root.Grammar.IsAllowedChildSymbol(root.Symbol, s, i) &&
     176                                                   root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth &&
     177                                                   root.Grammar.GetMaximumExpressionDepth(s) > maxDepth - currentDepth).ToList();
     178        if (!possibleSymbols.Any())
     179          throw new InvalidOperationException("No symbols are available for the tree.");
    175180
    176 
    177         if (!possibleSymbols.Any()) throw new InvalidOperationException("No symbols are available for the tree.");
    178181        var selectedSymbol = possibleSymbols.SelectRandom(random);
    179182        var tree = selectedSymbol.CreateTreeNode();
     
    182185      }
    183186
    184       foreach (var subTree in root.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
     187      foreach (var subTree in root.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0))
    185188        RecursiveGrowFull(random, subTree, currentDepth + 1, maxDepth);
    186189    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r7076 r7213  
    146146        throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero.");
    147147
     148      var allowedSymbols = seedNode.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList();
    148149
    149150      for (var i = 0; i != arity; ++i) {
    150         var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol, i).Where(s => s.InitialFrequency > 0.0);
     151        var possibleSymbols = allowedSymbols.Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)).ToList();
    151152        var selectedSymbol = possibleSymbols.SelectRandom(random);
    152153        var tree = selectedSymbol.CreateTreeNode();
     
    157158      // Only iterate over the non-terminal nodes (those which have arity > 0)
    158159      // Start from depth 2 since the first two levels are formed by the rootNode and the seedNode
    159       foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
     160      foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0))
    160161        RecursiveGrow(random, subTree, 2, maxDepth);
    161162    }
     
    166167        throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
    167168
     169      var allowedSymbols = root.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList();
     170
    168171      for (var i = 0; i != arity; ++i) {
    169         var possibleSymbols = root.Grammar.GetAllowedChildSymbols(root.Symbol, i);
    170         possibleSymbols = possibleSymbols.Where(s => s.InitialFrequency > 0.0 &&
    171                                           root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth);
    172         if (!possibleSymbols.Any()) throw new InvalidOperationException("No symbols are available for the tree.");
     172        var possibleSymbols = allowedSymbols.Where(s => root.Grammar.IsAllowedChildSymbol(root.Symbol, s, i) && root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth).ToList();
     173        if (!possibleSymbols.Any())
     174          throw new InvalidOperationException("No symbols are available for the tree.");
    173175        var selectedSymbol = possibleSymbols.SelectRandom(random);
    174176        var tree = selectedSymbol.CreateTreeNode();
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs

    r5809 r7213  
    3131  [Item("SymbolicExpressionTree", "Represents a symbolic expression tree.")]
    3232  public class SymbolicExpressionTree : Item, ISymbolicExpressionTree {
    33     public override Image ItemImage {
     33    public static new Image StaticItemImage {
    3434      get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; }
    3535    }
Note: See TracChangeset for help on using the changeset viewer.