Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/12 15:18:03 (12 years ago)
Author:
bburlacu
Message:

#1682: New branch format: removed unnecessary files, merged remaining.

Location:
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
1 deleted
69 edited

Legend:

Unmodified
Added
Removed
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeLengthAnalyzer.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    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/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    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/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs

    r6978 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using System;
    3233
    3334namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5253    }
    5354    public ValueLookupParameter<DataTable> SymbolicExpressionTreeLengthsParameter {
    54       get {
    55         return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName];
    56       }
     55      get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName]; }
    5756    }
    5857    public ValueLookupParameter<DataTableHistory> SymbolicExpressionTreeLengthsHistoryParameter {
    59       get {
    60         return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName];
    61       }
     58      get { return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName]; }
    6259    }
    6360    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    7168      get { return (ValueParameter<IntValue>)Parameters[UpdateIntervalParameterName]; }
    7269    }
    73     public LookupParameter<IntValue> UpdateCounterParameter {
    74       get { return (LookupParameter<IntValue>)Parameters[UpdateCounterParameterName]; }
     70    public ValueParameter<IntValue> UpdateCounterParameter {
     71      get { return (ValueParameter<IntValue>)Parameters[UpdateCounterParameterName]; }
    7572    }
    7673    #endregion
     74
     75    #region Properties
     76    public bool EnabledByDefault {
     77      get { return true; }
     78    }
     79    public IntValue UpdateInterval {
     80      get { return UpdateIntervalParameter.Value; }
     81    }
     82    public IntValue UpdateCounter {
     83      get { return UpdateCounterParameter.Value; }
     84    }
     85    public BoolValue StoreHistory {
     86      get { return StoreHistoryParameter.Value; }
     87    }
     88    #endregion
     89
    7790    [StorableConstructor]
    7891    private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base() { }
    7992    private SymbolicExpressionTreeLengthAnalyzer(SymbolicExpressionTreeLengthAnalyzer original, Cloner cloner)
    8093      : base(original, cloner) {
    81       AfterDeserialization();
    8294    }
    8395    public override IDeepCloneable Clone(Cloner cloner) {
     
    91103      Parameters.Add(new ValueLookupParameter<DataTableHistory>(SymbolicExpressionTreeLengthsHistoryParameterName, "The data table to store the symbolic expression tree lengths history."));
    92104      Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    93 
    94       #region Add parameters for history
    95105      Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false)));
    96106      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 
     107      Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
     108
     109      SymbolicExpressionTreeLengthsParameter.Hidden = true;
     110      SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true;
     111      ResultsParameter.Hidden = true;
    100112      UpdateCounterParameter.Hidden = true;
    101 
    102       AfterDeserialization();
    103113    }
    104114
     
    112122        Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
    113123      }
     124      //necessary code to correct UpdateCounterParameter - type was changed from LookupParameter to ValueParameter
     125      if (Parameters.ContainsKey(UpdateCounterParameterName) && (Parameters[UpdateCounterParameterName] is LookupParameter<IntValue>))
     126        Parameters.Remove(UpdateCounterParameterName);
    114127      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       }
    117     }
     128        Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
     129        UpdateCounterParameter.Hidden = true;
     130      }
     131    }
     132
     133    #region IStatefulItem members
     134    public override void InitializeState() {
     135      base.InitializeState();
     136      UpdateCounter.Value = 0;
     137    }
     138    public override void ClearState() {
     139      base.ClearState();
     140      UpdateCounter.Value = 0;
     141    }
     142    #endregion
    118143
    119144    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 
     145      UpdateCounter.Value++;
    128146      // the analyzer runs periodically, every 'updateInterval' times
    129       if (updateCounter.Value == updateInterval) {
    130         updateCounter.Value = 0; // reset counter
     147      if (UpdateCounter.Value == UpdateInterval.Value) {
     148        UpdateCounter.Value = 0; // reset counter
    131149
    132150        // compute all tree lengths and store them in the lengthsTable
     
    136154        // if the table was not created yet, we create it here
    137155        if (treeLengthsTable == null) {
    138           treeLengthsTable = new DataTable("Tree Length Values");
     156          treeLengthsTable = new DataTable("Histogram");
    139157          SymbolicExpressionTreeLengthsParameter.ActualValue = treeLengthsTable;
    140158        }
    141159
    142160        // 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);
     161        DataRow treeLengthsTableRow;
     162
     163        const string treeLengthsTableRowName = "Symbolic expression tree lengths";
     164        const string treeLengthsTableRowDesc = "The distribution of symbolic expression tree lengths";
     165        const string xAxisTitle = "Symbolic expression tree lengths";
     166        const string yAxisTitle = "Frequency / Number of tree individuals";
     167
     168        var treeLengths = solutions.Select(s => (int)s.Length).ToList();
     169
     170        int maxLength = treeLengths.Max(t => t);
     171        int minLength = treeLengths.Min(t => t);
     172
     173        if (!treeLengthsTable.Rows.ContainsKey(treeLengthsTableRowName)) {
     174          treeLengthsTableRow = new DataRow(treeLengthsTableRowName, treeLengthsTableRowDesc, treeLengths.Select(x => (double)x));
     175          treeLengthsTable.Rows.Add(treeLengthsTableRow);
    150176        } else {
    151           dataRow = treeLengthsTable.Rows["Tree Lengths"];
    152           dataRow.Values.Replace(treeLengths);
     177          treeLengthsTableRow = treeLengthsTable.Rows[treeLengthsTableRowName];
     178          treeLengthsTableRow.Values.Replace(treeLengths.Select(x => (double)x));
    153179        }
    154180
    155181        double maximumAllowedTreeLength = ((LookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]).ActualValue.Value;
    156182
    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;
     183        treeLengthsTableRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     184        treeLengthsTableRow.VisualProperties.ExactBins = false;
     185
     186        int range = maxLength - minLength;
     187        if (range == 0) range = 1;
     188        // the following trick should result in an integer intervalWidth of 1,2,4,...
     189        treeLengthsTableRow.VisualProperties.Bins = range;
     190
     191        if (maxLength <= 25) // [0,25]
     192          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0;
     193        else if (maxLength <= 100) // [26,100]
     194          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 2.0;
     195        else if (maxLength <= 250) // [101,250]
     196          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 5.0;
    170197        else if (maxLength <= 500) // [251,500]
    171           dataRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
     198          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 10.0;
    172199        else
    173           dataRow.VisualProperties.ScaleFactor = 1.0 / 20.0;   // [501,inf]
     200          treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 20.0; // [501,inf]
     201
     202        treeLengthsTableRow.VisualProperties.IsVisibleInLegend = false;
    174203
    175204        // visual properties for the X-axis
     
    178207        treeLengthsTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    179208        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
     209          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    181210        else
    182211          treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
    183         // visual properties for the Y-axis
     212        treeLengthsTable.VisualProperties.XAxisTitle = xAxisTitle;
     213        //visual properties for the Y-axis
    184214        treeLengthsTable.VisualProperties.YAxisMinimumAuto = false;
    185215        treeLengthsTable.VisualProperties.YAxisMaximumAuto = false;
    186216        treeLengthsTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    187         treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
     217        int maxFreq = (int)Math.Round(solutions.GroupBy(s => s.Length).Max(g => g.Count()) / treeLengthsTableRow.VisualProperties.ScaleFactor);
     218        if (maxFreq % 5 != 0)
     219          maxFreq += (5 - maxFreq % 5);
     220        double yAxisMaximumFixedValue = maxFreq;
     221
     222        treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue;
     223        treeLengthsTable.VisualProperties.YAxisTitle = yAxisTitle;
    188224
    189225        var results = ResultsParameter.ActualValue;
    190226
    191         if (!results.ContainsKey("Tree Lengths")) {
    192           results.Add(new Result("Tree Lengths", treeLengthsTable));
     227        if (!results.ContainsKey(treeLengthsTableRowName)) {
     228          results.Add(new Result(treeLengthsTableRowName, treeLengthsTable));
    193229        } else {
    194           results["Tree Lengths"].Value = treeLengthsTable;
     230          results[treeLengthsTableRowName].Value = treeLengthsTable;
    195231        }
    196232
    197233        bool storeHistory = StoreHistoryParameter.Value.Value;
     234        const string treeLengthHistoryTableName = "Tree lengths history";
    198235
    199236        if (storeHistory) {
    200           // store tree lengths for each generation
    201           var historyDataRow = new DataRow("Tree Lengths " + results["Generations"].Value, "", dataRow.Values);
    202           historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    203           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"]);
    207           historyTable.Rows.Add(historyDataRow);
    208           // visual properties for the X-axis
    209           historyTable.VisualProperties.XAxisMinimumAuto = false;
    210           historyTable.VisualProperties.XAxisMaximumAuto = false;
    211           historyTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
    212           if (solutions.Max(s => s.Length) > maximumAllowedTreeLength + 1)
    213             historyTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
    214           else
    215             historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
    216           // visual properties for the Y-axis
    217           historyTable.VisualProperties.YAxisMinimumAuto = false;
    218           historyTable.VisualProperties.YAxisMaximumAuto = false;
    219           historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
    220           historyTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);
    221 
    222237          var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue;
    223238          if (treeLengthsHistory == null) {
     
    225240            SymbolicExpressionTreeLengthsHistoryParameter.ActualValue = treeLengthsHistory;
    226241          }
    227 
    228           treeLengthsHistory.Add(historyTable);
    229 
    230           if (!results.ContainsKey("Tree Lengths History")) {
    231             results.Add(new Result("Tree Lengths History", treeLengthsHistory));
     242          treeLengthsHistory.Add((DataTable)treeLengthsTable.Clone());
     243
     244          if (!results.ContainsKey(treeLengthHistoryTableName)) {
     245            results.Add(new Result(treeLengthHistoryTableName, treeLengthsHistory));
    232246          } else {
    233             results["Tree Lengths History"].Value = treeLengthsHistory;
     247            results[treeLengthHistoryTableName].Value = treeLengthsHistory;
    234248          }
    235249        }
    236250      }
    237 
    238251      return base.Apply();
    239252    }
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthCalculator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r6918 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDeleter.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDuplicater.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/GrammarModifier.cs

    r6918 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/MultiSymbolicExpressionTreeArchitectureManipulator.cs

    r6929 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    9898      List<ISymbolicExpressionTreeManipulator> list = new List<ISymbolicExpressionTreeManipulator>();
    9999      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ISymbolicExpressionTreeManipulator))) {
    100         if (!typeof(IMultiOperator<ISymbolicExpressionTreeManipulator>).IsAssignableFrom(type))
    101           list.Add((ISymbolicExpressionTreeManipulator)Activator.CreateInstance(type));
     100        if (this.GetType().Assembly != type.Assembly) continue;
     101        if (typeof(IMultiOperator<ISymbolicExpressionTreeManipulator>).IsAssignableFrom(type)) continue;
     102        list.Add((ISymbolicExpressionTreeManipulator)Activator.CreateInstance(type));
    102103      }
    103104      CheckedItemList<ISymbolicExpressionTreeManipulator> checkedItemList = new CheckedItemList<ISymbolicExpressionTreeManipulator>();
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r6233 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/Instruction.cs

    r6740 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r6944 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     32  [NonDiscoverableType]
    3133  [StorableClass]
    3234  [Item("FullTreeCreator", "An operator that creates new symbolic expression trees using the 'Full' method")]
     
    6264    }
    6365
    64     public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
     66    public IntValue MaximumSymbolicExpressionTreeLength {
     67      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     68    }
     69
     70    public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    6571      get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    6672    }
     
    7480    public FullTreeCreator()
    7581      : base() {
    76       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    77       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    78       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    79       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
     82      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
     83        "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
     84      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
     85        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     86      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
     87        "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     88      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
     89        "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    8090    }
    8191
     
    91101          globalScope = globalScope.Parent;
    92102
    93         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
     103        globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
     104          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    94105      }
    95106      return base.Apply();
     
    97108
    98109    protected override ISymbolicExpressionTree Create(IRandom random) {
    99       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     110      return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     111    }
     112
     113    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     114      return Create(random, grammar, maxTreeLength, maxTreeDepth);
    100115    }
    101116
     
    108123    /// <param name="grammar">Available tree grammar</param>
    109124    /// <param name="maxTreeDepth">Maximum tree depth</param>
     125    /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param>
    110126    /// <returns></returns>
    111     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     127    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    112128      var tree = new SymbolicExpressionTree();
    113129      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
     
    116132
    117133      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
     134      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    118135      startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    119       if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    120136
    121137      rootNode.AddSubtree(startNode);
    122138
    123       Grow(random, startNode, maxTreeDepth - 2);
     139      Create(random, startNode, maxTreeDepth - 2);
    124140      tree.Root = rootNode;
    125141      return tree;
    126142    }
    127143
    128     public static void Grow(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {
     144    public static void Create(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {
    129145      // make sure it is possible to create a trees smaller than maxDepth
    130146      if (seedNode.Grammar.GetMinimumExpressionDepth(seedNode.Symbol) > maxDepth)
     
    137153        throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero.");
    138154
    139       for (var i = 0; i != arity; ++i) {
    140         var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol,i).Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0);
     155      var allowedSymbols = seedNode.Grammar.AllowedSymbols
     156        .Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0)
     157        .ToList();
     158
     159      for (var i = 0; i < arity; i++) {
     160        var possibleSymbols = allowedSymbols
     161          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
     162          .ToList();
    141163        var selectedSymbol = possibleSymbols.SelectRandom(random);
    142164        var tree = selectedSymbol.CreateTreeNode();
     
    147169      // Only iterate over the non-terminal nodes (those which have arity > 0)
    148170      // Start from depth 2 since the first two levels are formed by the rootNode and the seedNode
    149       foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
    150         RecursiveGrowFull(random, subTree, 2, maxDepth);
    151     }
    152 
    153     public static void RecursiveGrowFull(IRandom random, ISymbolicExpressionTreeNode root, int currentDepth, int maxDepth) {
     171      foreach (var subTree in seedNode.Subtrees)
     172        if (subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0)
     173          RecursiveCreate(random, subTree, 2, maxDepth);
     174    }
     175
     176    private static void RecursiveCreate(IRandom random, ISymbolicExpressionTreeNode root, int currentDepth, int maxDepth) {
    154177      var arity = root.Grammar.GetMaximumSubtreeCount(root.Symbol);
    155178      // In the 'Full' grow method, we cannot have terminals on the intermediate tree levels.
     
    157180        throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
    158181
    159 
    160       for (var i = 0; i != arity; ++i) {
    161         var possibleSymbols = currentDepth < maxDepth ?
    162           root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) > 0) :
    163           root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0);
     182      var allowedSymbols = root.Grammar.AllowedSymbols
     183        .Where(s => s.InitialFrequency > 0.0)
     184        .ToList();
     185
     186      for (var i = 0; i < arity; i++) {
     187        var possibleSymbols = allowedSymbols
     188          .Where(s => root.Grammar.IsAllowedChildSymbol(root.Symbol, s, i) &&
     189            root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth &&
     190            root.Grammar.GetMaximumExpressionDepth(s) > maxDepth - currentDepth)
     191          .ToList();
     192        if (!possibleSymbols.Any())
     193          throw new InvalidOperationException("No symbols are available for the tree.");
     194
    164195        var selectedSymbol = possibleSymbols.SelectRandom(random);
    165196        var tree = selectedSymbol.CreateTreeNode();
     
    168199      }
    169200
    170       foreach (var subTree in root.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
    171         RecursiveGrowFull(random, subTree, currentDepth + 1, maxDepth);
     201      foreach (var subTree in root.Subtrees)
     202        if (subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0)
     203          RecursiveCreate(random, subTree, currentDepth + 1, maxDepth);
    172204    }
    173205  }
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r6944 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     32  [NonDiscoverableType]
    3133  [StorableClass]
    3234  [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")]
     
    6264    }
    6365
    64     public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
     66    public IntValue MaximumSymbolicExpressionTreeLength {
     67      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     68    }
     69
     70    public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    6571      get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    6672    }
     
    7480    public GrowTreeCreator()
    7581      : base() {
    76       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    77       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    78       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    79       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
     82      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
     83        "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
     84      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
     85        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     86      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
     87        "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     88      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
     89        "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    8090    }
    8191
     
    91101          globalScope = globalScope.Parent;
    92102
    93         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
     103        globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
     104          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    94105      }
    95106      return base.Apply();
     
    97108
    98109    protected override ISymbolicExpressionTree Create(IRandom random) {
    99       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     110      return Create(random, ClonedSymbolicExpressionTreeGrammar,
     111        MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     112    }
     113
     114    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     115      return Create(random, grammar, maxTreeLength, maxTreeDepth);
    100116    }
    101117
     
    107123    /// <param name="grammar">Available tree grammar</param>
    108124    /// <param name="maxTreeDepth">Maximum tree depth</param>
     125    /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param>
    109126    /// <returns></returns>
    110     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     127    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    111128      var tree = new SymbolicExpressionTree();
    112129      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
     
    115132
    116133      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
     134      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    117135      startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    118       if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    119136
    120137      rootNode.AddSubtree(startNode);
    121138
    122       Grow(random, startNode, maxTreeDepth - 2);
     139      Create(random, startNode, maxTreeDepth - 2);
    123140      tree.Root = rootNode;
    124141      return tree;
    125142    }
    126143
    127     public static void Grow(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {
     144    public static void Create(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {
    128145      // make sure it is possible to create a trees smaller than maxDepth
    129146      if (seedNode.Grammar.GetMinimumExpressionDepth(seedNode.Symbol) > maxDepth)
     
    135152        throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero.");
    136153
    137 
    138       for (var i = 0; i != arity; ++i) {
    139         var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol, i).Where(s => s.InitialFrequency > 0.0);
     154      var allowedSymbols = seedNode.Grammar.AllowedSymbols
     155        .Where(s => s.InitialFrequency > 0.0)
     156        .ToList();
     157
     158      for (var i = 0; i < arity; i++) {
     159        var possibleSymbols = allowedSymbols
     160          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
     161          .ToList();
    140162        var selectedSymbol = possibleSymbols.SelectRandom(random);
    141163        var tree = selectedSymbol.CreateTreeNode();
     
    146168      // Only iterate over the non-terminal nodes (those which have arity > 0)
    147169      // Start from depth 2 since the first two levels are formed by the rootNode and the seedNode
    148       foreach (var subTree in seedNode.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
    149         RecursiveGrow(random, subTree, 2, maxDepth);
    150     }
    151 
    152     public static void RecursiveGrow(IRandom random, ISymbolicExpressionTreeNode root, int currentDepth, int maxDepth) {
     170      foreach (var subTree in seedNode.Subtrees)
     171        if (subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) > 0)
     172          RecursiveCreate(random, subTree, 2, maxDepth);
     173    }
     174
     175    private static void RecursiveCreate(IRandom random, ISymbolicExpressionTreeNode root, int currentDepth, int maxDepth) {
    153176      var arity = SampleArity(random, root);
    154177      if (arity <= 0)
    155178        throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
    156179
    157 
    158       for (var i = 0; i != arity; ++i) {
    159         var possibleSymbols = currentDepth < maxDepth
    160                                 ? root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0)
    161                                 : root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(
    162                                   s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0);
     180      var allowedSymbols = root.Grammar.AllowedSymbols
     181        .Where(s => s.InitialFrequency > 0.0)
     182        .ToList();
     183
     184      for (var i = 0; i < arity; i++) {
     185        var possibleSymbols = allowedSymbols
     186          .Where(s => root.Grammar.IsAllowedChildSymbol(root.Symbol, s, i) &&
     187            root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth)
     188          .ToList();
     189        if (!possibleSymbols.Any())
     190          throw new InvalidOperationException("No symbols are available for the tree.");
    163191        var selectedSymbol = possibleSymbols.SelectRandom(random);
    164192        var tree = selectedSymbol.CreateTreeNode();
     
    167195      }
    168196
    169       foreach (var subTree in root.Subtrees.Where(subTree => subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0))
    170         RecursiveGrow(random, subTree, currentDepth + 1, maxDepth);
     197      foreach (var subTree in root.Subtrees)
     198        if (subTree.Grammar.GetMaximumSubtreeCount(subTree.Symbol) != 0)
     199          RecursiveCreate(random, subTree, currentDepth + 1, maxDepth);
    171200    }
    172201
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r6911 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.PluginInfrastructure;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     33  [NonDiscoverableType]
    3234  [StorableClass]
    3335  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")]
     
    101103    }
    102104
    103     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar,
    104       int maxTreeLength, int maxTreeDepth) {
     105    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     106      return Create(random, grammar, maxTreeLength, maxTreeDepth);
     107    }
     108
     109    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    105110      SymbolicExpressionTree tree = new SymbolicExpressionTree();
    106111      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r6887 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.ComponentModel;
    25 using System.Linq;
    2622using HeuristicLab.Common;
    2723using HeuristicLab.Core;
     
    2925using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.PluginInfrastructure;
    3128
    3229namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     30  [NonDiscoverableType]
    3331  [StorableClass]
    3432  [Item("RampedHalfAndHalfTreeCreator", "An operator that creates new symbolic expression trees in an alternate way: half the trees are created usign the 'Grow' method while the other half are created using the 'Full' method")]
     
    5250    public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    5351      get {
    54         return
    55             (IValueLookupParameter<ISymbolicExpressionGrammar>)
    56             Parameters[SymbolicExpressionTreeGrammarParameterName];
     52        return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName];
    5753      }
    5854    }
     
    6056    public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    6157      get {
    62         return
    63             (ILookupParameter<ISymbolicExpressionGrammar>)
    64             Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
     58        return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
    6559      }
    6660    }
     
    7266    }
    7367
    74     public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
     68    public IntValue MaximumSymbolicExpressionTreeLength {
     69      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     70    }
     71
     72    public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    7573      get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    7674    }
     
    8381    public RampedHalfAndHalfTreeCreator()
    8482      : base() {
    85       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    86       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    87       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    88       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
     83      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
     84        "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
     85      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
     86        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     87      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
     88        "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     89      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
     90        "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    8991    }
    9092
     
    100102          globalScope = globalScope.Parent;
    101103
    102         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
     104        globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
     105          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    103106      }
    104107      return base.Apply();
     
    106109
    107110    protected override ISymbolicExpressionTree Create(IRandom random) {
    108       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     111      return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     112    }
     113
     114    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     115      return Create(random, grammar, maxTreeLength, maxTreeDepth);
    109116    }
    110117
     
    115122    /// <param name="random">Random generator</param>
    116123    /// <param name="grammar">Available tree grammar</param>
     124    /// <param name="maxTreeLength">Maximum tree length (this parameter is ignored)</param>
    117125    /// <param name="maxTreeDepth">Maximum tree depth</param>
    118126    /// <returns></returns>
    119     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     127    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    120128      var tree = new SymbolicExpressionTree();
    121129      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
     
    124132
    125133      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
     134      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    126135      startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    127       if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    128136
    129137      rootNode.AddSubtree(startNode);
     
    132140
    133141      if (p < 0.5)
    134         GrowTreeCreator.Grow(random, startNode, maxTreeDepth - 2);
     142        GrowTreeCreator.Create(random, startNode, maxTreeDepth - 2);
    135143      else
    136         FullTreeCreator.Grow(random, startNode, maxTreeDepth - 2);
     144        FullTreeCreator.Create(random, startNode, maxTreeDepth - 2);
    137145
    138146      tree.Root = rootNode;
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs

    r6233 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3939    #endregion
    4040
    41     #region Propeties
     41    #region Properties
    4242    public ISymbolicExpressionTree SymbolicExpressionTree {
    4343      get { return SymbolicExpressionTreeParameter.ActualValue; }
     
    6060
    6161    protected abstract ISymbolicExpressionTree Create(IRandom random);
     62    public abstract ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
    6263  }
    6364}
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r7119 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs

    r7035 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Formatters/SymbolicExpressionTreeStringFormatter.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r6978 r7344  
    9494  </PropertyGroup>
    9595  <ItemGroup>
     96    <Reference Include="HeuristicLab.Analysis-3.3">
     97      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     98    </Reference>
     99    <Reference Include="HeuristicLab.Collections-3.3">
     100      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     101    </Reference>
     102    <Reference Include="HeuristicLab.Common-3.3">
     103      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     104    </Reference>
     105    <Reference Include="HeuristicLab.Common.Resources-3.3">
     106      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     107    </Reference>
     108    <Reference Include="HeuristicLab.Core-3.3">
     109      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     110    </Reference>
     111    <Reference Include="HeuristicLab.Data-3.3">
     112      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     113    </Reference>
     114    <Reference Include="HeuristicLab.Operators-3.3">
     115      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     116    </Reference>
     117    <Reference Include="HeuristicLab.Optimization-3.3">
     118      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     119    </Reference>
     120    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
     121      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     122    </Reference>
     123    <Reference Include="HeuristicLab.Parameters-3.3">
     124      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     125    </Reference>
     126    <Reference Include="HeuristicLab.Persistence-3.3">
     127      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     128    </Reference>
     129    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     130      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     131    </Reference>
     132    <Reference Include="HeuristicLab.Random-3.3">
     133      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     134    </Reference>
    96135    <Reference Include="System" />
    97136    <Reference Include="System.Core">
     
    190229  </ItemGroup>
    191230  <ItemGroup>
    192     <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
    193       <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
    194       <Name>HeuristicLab.Analysis-3.3</Name>
    195       <Private>False</Private>
    196     </ProjectReference>
    197     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    198       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    199       <Name>HeuristicLab.Collections-3.3</Name>
    200       <Private>False</Private>
    201     </ProjectReference>
    202     <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    203       <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    204       <Name>HeuristicLab.Common.Resources-3.3</Name>
    205       <Private>False</Private>
    206     </ProjectReference>
    207     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    208       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    209       <Name>HeuristicLab.Common-3.3</Name>
    210       <Private>False</Private>
    211     </ProjectReference>
    212     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    213       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    214       <Name>HeuristicLab.Core-3.3</Name>
    215       <Private>False</Private>
    216     </ProjectReference>
    217     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    218       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    219       <Name>HeuristicLab.Data-3.3</Name>
    220       <Private>False</Private>
    221     </ProjectReference>
    222     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    223       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    224       <Name>HeuristicLab.Operators-3.3</Name>
    225       <Private>False</Private>
    226     </ProjectReference>
    227     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    228       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    229       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    230       <Private>False</Private>
    231     </ProjectReference>
    232     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    233       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    234       <Name>HeuristicLab.Optimization-3.3</Name>
    235       <Private>False</Private>
    236     </ProjectReference>
    237     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    238       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    239       <Name>HeuristicLab.Parameters-3.3</Name>
    240       <Private>False</Private>
    241     </ProjectReference>
    242     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    243       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    244       <Name>HeuristicLab.Persistence-3.3</Name>
    245       <Private>False</Private>
    246     </ProjectReference>
    247     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    248       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    249       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    250       <Private>False</Private>
    251     </ProjectReference>
    252     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    253       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    254       <Name>HeuristicLab.Random-3.3</Name>
    255       <Private>False</Private>
    256     </ProjectReference>
    257   </ItemGroup>
    258   <ItemGroup>
    259231    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
    260232      <Visible>False</Visible>
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/IReadOnlySymbol.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammarBase.cs

    r6911 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4040
    4141    int GetMinimumExpressionDepth(ISymbol start);
     42    int GetMaximumExpressionDepth(ISymbol start);
    4243    int GetMinimumExpressionLength(ISymbol start);
    4344    int GetMaximumExpressionLength(ISymbol start, int maxDepth);
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeGrammar.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs

    r7035 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeStringFormatter.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeAnalyzer.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeArchitectureAlteringOperator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeArchitectureManipulator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2929  public interface ISymbolicExpressionTreeCreator : ISymbolicExpressionTreeOperator, ISolutionCreator {
    3030    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
     31    ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
    3132  }
    3233}
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCrossover.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeGrammarBasedOperator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeOperator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeSizeConstraintOperator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs

    r5925 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs

    r6439 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs

    r6929 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    7474      List<ISymbolicExpressionTreeManipulator> list = new List<ISymbolicExpressionTreeManipulator>();
    7575      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ISymbolicExpressionTreeManipulator))) {
    76         if (!typeof(IMultiOperator<ISymbolicExpressionTreeManipulator>).IsAssignableFrom(type) &&
    77             !typeof(ISymbolicExpressionTreeArchitectureAlteringOperator).IsAssignableFrom(type))
    78           list.Add((ISymbolicExpressionTreeManipulator)Activator.CreateInstance(type));
     76        if (this.GetType().Assembly != type.Assembly) continue;
     77        if (typeof(IMultiOperator<ISymbolicExpressionTreeManipulator>).IsAssignableFrom(type)) continue;
     78        if (typeof(ISymbolicExpressionTreeArchitectureAlteringOperator).IsAssignableFrom(type)) continue;
     79        list.Add((ISymbolicExpressionTreeManipulator)Activator.CreateInstance(type));
    7980      }
    8081      CheckedItemList<ISymbolicExpressionTreeManipulator> checkedItemList = new CheckedItemList<ISymbolicExpressionTreeManipulator>();
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r6439 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs

    r6817 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame

    r6866 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.1.$WCREV$")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame

    r6866 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3232[assembly: AssemblyCompany("")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2011 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2012 HEAL")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
     
    4545
    4646[assembly: AssemblyVersion("3.4.0.0")]
    47 [assembly: AssemblyFileVersion("3.4.1.$WCREV$")]
     47[assembly: AssemblyFileVersion("3.4.2.$WCREV$")]
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs

    r6911 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8282      cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
    8383      cachedMinExpressionDepth = new Dictionary<string, int>();
     84      cachedMaxExpressionDepth = new Dictionary<string, int>();
    8485
    8586      cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
     
    9495      cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
    9596      cachedMinExpressionDepth = new Dictionary<string, int>();
     97      cachedMaxExpressionDepth = new Dictionary<string, int>();
    9698
    9799      cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
     
    117119      cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
    118120      cachedMinExpressionDepth = new Dictionary<string, int>();
     121      cachedMaxExpressionDepth = new Dictionary<string, int>();
    119122
    120123      cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
     
    134137      foreach (var s in symbol.Flatten()) {
    135138        symbols.Add(s.Name, s);
    136         symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, s.MaximumArity));
     139        int maxSubTreeCount = Math.Min(s.MinimumArity + 1, s.MaximumArity);
     140        symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, maxSubTreeCount));
    137141      }
    138142      ClearCaches();
     
    371375      cachedMaxExpressionLength.Clear();
    372376      cachedMinExpressionDepth.Clear();
     377      cachedMaxExpressionDepth.Clear();
    373378
    374379      cachedIsAllowedChildSymbol.Clear();
     
    427432    }
    428433
     434    private readonly Dictionary<string, int> cachedMaxExpressionDepth;
     435    public int GetMaximumExpressionDepth(ISymbol symbol) {
     436      int temp;
     437      if (!cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) {
     438        cachedMaxExpressionDepth[symbol.Name] = int.MaxValue;
     439        long maxDepth = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol))
     440                             let maxForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex)
     441                                                     where s.InitialFrequency > 0.0
     442                                                     select GetMaximumExpressionDepth(s)).DefaultIfEmpty(0).Max()
     443                             select maxForSlot).DefaultIfEmpty(0).Max();
     444        cachedMaxExpressionDepth[symbol.Name] = (int)Math.Min(maxDepth, int.MaxValue);
     445        return cachedMaxExpressionDepth[symbol.Name];
     446      }
     447      return temp;
     448    }
     449
    429450    public event EventHandler Changed;
    430451    protected virtual void OnChanged() {
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    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    }
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs

    r6911 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4545    private ISymbolicExpressionGrammar grammar;
    4646    public SymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar)
    47       : base("SymbolicExpressionTreeGrammar", "A grammar that is used held by symbolic expression trees and allows extensions to the wraped grammar.") {
     47      : base("SymbolicExpressionTreeGrammar", "A grammar that is used held by symbolic expression trees and allows extensions to the wrapped grammar.") {
    4848      if (grammar == null) throw new ArgumentNullException();
    4949      this.grammar = grammar;
     
    119119      else return base.GetMinimumExpressionDepth(symbol);
    120120    }
     121    int ISymbolicExpressionGrammarBase.GetMaximumExpressionDepth(ISymbol symbol) {
     122      if (symbols.Count == 0) return grammar.GetMaximumExpressionDepth(symbol);
     123      else return base.GetMaximumExpressionDepth(symbol);
     124    }
    121125    int ISymbolicExpressionGrammarBase.GetMinimumExpressionLength(ISymbol symbol) {
    122126      if (symbols.Count == 0) return grammar.GetMinimumExpressionLength(symbol);
     
    127131      else return base.GetMaximumExpressionLength(symbol, maxDepth);
    128132    }
     133
    129134  }
    130135}
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r7035 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeOperator.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs

    r6684 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs

    r6233 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ArgumentTreeNode.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/DefunTreeNode.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/GroupSymbol.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunctionTreeNode.cs

    r5809 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs

    r6803 r7344  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
Note: See TracChangeset for help on using the changeset viewer.