- Timestamp:
- 01/17/12 15:18:03 (13 years ago)
- 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 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 43 43 private const string MaxTreeLengthParameterName = "Maximal symbolic expression tree length"; 44 44 private const string ResultsParameterName = "Results"; 45 46 public bool EnabledByDefault { 47 get { return true; } 48 } 45 49 46 50 #region parameter properties -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 59 59 #endregion 60 60 #region properties 61 public virtual bool EnabledByDefault { 62 get { return true; } 63 } 61 64 public BoolValue AggregrateSymbolsWithDifferentSubtreeCount { 62 65 get { return AggregateSymbolsWithDifferentSubtreeCountParameter.Value; } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
r6978 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System; 32 33 33 34 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 52 53 } 53 54 public ValueLookupParameter<DataTable> SymbolicExpressionTreeLengthsParameter { 54 get { 55 return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName]; 56 } 55 get { return (ValueLookupParameter<DataTable>)Parameters[SymbolicExpressionTreeLengthsParameterName]; } 57 56 } 58 57 public ValueLookupParameter<DataTableHistory> SymbolicExpressionTreeLengthsHistoryParameter { 59 get { 60 return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName]; 61 } 58 get { return (ValueLookupParameter<DataTableHistory>)Parameters[SymbolicExpressionTreeLengthsHistoryParameterName]; } 62 59 } 63 60 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 71 68 get { return (ValueParameter<IntValue>)Parameters[UpdateIntervalParameterName]; } 72 69 } 73 public LookupParameter<IntValue> UpdateCounterParameter {74 get { return ( LookupParameter<IntValue>)Parameters[UpdateCounterParameterName]; }70 public ValueParameter<IntValue> UpdateCounterParameter { 71 get { return (ValueParameter<IntValue>)Parameters[UpdateCounterParameterName]; } 75 72 } 76 73 #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 77 90 [StorableConstructor] 78 91 private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base() { } 79 92 private SymbolicExpressionTreeLengthAnalyzer(SymbolicExpressionTreeLengthAnalyzer original, Cloner cloner) 80 93 : base(original, cloner) { 81 AfterDeserialization();82 94 } 83 95 public override IDeepCloneable Clone(Cloner cloner) { … … 91 103 Parameters.Add(new ValueLookupParameter<DataTableHistory>(SymbolicExpressionTreeLengthsHistoryParameterName, "The data table to store the symbolic expression tree lengths history.")); 92 104 Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored.")); 93 94 #region Add parameters for history95 105 Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false))); 96 106 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; 100 112 UpdateCounterParameter.Hidden = true; 101 102 AfterDeserialization();103 113 } 104 114 … … 112 122 Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1))); 113 123 } 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); 114 127 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 118 143 119 144 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++; 128 146 // the analyzer runs periodically, every 'updateInterval' times 129 if ( updateCounter.Value == updateInterval) {130 updateCounter.Value = 0; // reset counter147 if (UpdateCounter.Value == UpdateInterval.Value) { 148 UpdateCounter.Value = 0; // reset counter 131 149 132 150 // compute all tree lengths and store them in the lengthsTable … … 136 154 // if the table was not created yet, we create it here 137 155 if (treeLengthsTable == null) { 138 treeLengthsTable = new DataTable(" Tree Length Values");156 treeLengthsTable = new DataTable("Histogram"); 139 157 SymbolicExpressionTreeLengthsParameter.ActualValue = treeLengthsTable; 140 158 } 141 159 142 160 // 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); 150 176 } 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)); 153 179 } 154 180 155 181 double maximumAllowedTreeLength = ((LookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]).ActualValue.Value; 156 182 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; 170 197 else if (maxLength <= 500) // [251,500] 171 dataRow.VisualProperties.ScaleFactor = 1.0 / 10.0;198 treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 10.0; 172 199 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; 174 203 175 204 // visual properties for the X-axis … … 178 207 treeLengthsTable.VisualProperties.XAxisMinimumFixedValue = 0.0; 179 208 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 trimmed209 treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed 181 210 else 182 211 treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1; 183 // visual properties for the Y-axis 212 treeLengthsTable.VisualProperties.XAxisTitle = xAxisTitle; 213 //visual properties for the Y-axis 184 214 treeLengthsTable.VisualProperties.YAxisMinimumAuto = false; 185 215 treeLengthsTable.VisualProperties.YAxisMaximumAuto = false; 186 216 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; 188 224 189 225 var results = ResultsParameter.ActualValue; 190 226 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)); 193 229 } else { 194 results[ "Tree Lengths"].Value = treeLengthsTable;230 results[treeLengthsTableRowName].Value = treeLengthsTable; 195 231 } 196 232 197 233 bool storeHistory = StoreHistoryParameter.Value.Value; 234 const string treeLengthHistoryTableName = "Tree lengths history"; 198 235 199 236 if (storeHistory) { 200 // store tree lengths for each generation201 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-axis209 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 trimmed214 else215 historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;216 // visual properties for the Y-axis217 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 222 237 var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue; 223 238 if (treeLengthsHistory == null) { … … 225 240 SymbolicExpressionTreeLengthsHistoryParameter.ActualValue = treeLengthsHistory; 226 241 } 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)); 232 246 } else { 233 results[ "Tree Lengths History"].Value = treeLengthsHistory;247 results[treeLengthHistoryTableName].Value = treeLengthsHistory; 234 248 } 235 249 } 236 250 } 237 238 251 return base.Apply(); 239 252 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthCalculator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs
r6918 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDeleter.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDuplicater.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/GrammarModifier.cs
r6918 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/MultiSymbolicExpressionTreeArchitectureManipulator.cs
r6929 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 98 98 List<ISymbolicExpressionTreeManipulator> list = new List<ISymbolicExpressionTreeManipulator>(); 99 99 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)); 102 103 } 103 104 CheckedItemList<ISymbolicExpressionTreeManipulator> checkedItemList = new CheckedItemList<ISymbolicExpressionTreeManipulator>(); -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs
r6233 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/Instruction.cs
r6740 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
r6944 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 [NonDiscoverableType] 31 33 [StorableClass] 32 34 [Item("FullTreeCreator", "An operator that creates new symbolic expression trees using the 'Full' method")] … … 62 64 } 63 65 64 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 68 } 69 70 public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar { 65 71 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } 66 72 } … … 74 80 public FullTreeCreator() 75 81 : 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.")); 80 90 } 81 91 … … 91 101 globalScope = globalScope.Parent; 92 102 93 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 103 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, 104 (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 94 105 } 95 106 return base.Apply(); … … 97 108 98 109 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); 100 115 } 101 116 … … 108 123 /// <param name="grammar">Available tree grammar</param> 109 124 /// <param name="maxTreeDepth">Maximum tree depth</param> 125 /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param> 110 126 /// <returns></returns> 111 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {127 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 112 128 var tree = new SymbolicExpressionTree(); 113 129 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); … … 116 132 117 133 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 134 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 118 135 startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar)); 119 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);120 136 121 137 rootNode.AddSubtree(startNode); 122 138 123 Grow(random, startNode, maxTreeDepth - 2);139 Create(random, startNode, maxTreeDepth - 2); 124 140 tree.Root = rootNode; 125 141 return tree; 126 142 } 127 143 128 public static void Grow(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {144 public static void Create(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) { 129 145 // make sure it is possible to create a trees smaller than maxDepth 130 146 if (seedNode.Grammar.GetMinimumExpressionDepth(seedNode.Symbol) > maxDepth) … … 137 153 throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero."); 138 154 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(); 141 163 var selectedSymbol = possibleSymbols.SelectRandom(random); 142 164 var tree = selectedSymbol.CreateTreeNode(); … … 147 169 // Only iterate over the non-terminal nodes (those which have arity > 0) 148 170 // 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) { 154 177 var arity = root.Grammar.GetMaximumSubtreeCount(root.Symbol); 155 178 // In the 'Full' grow method, we cannot have terminals on the intermediate tree levels. … … 157 180 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 158 181 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 164 195 var selectedSymbol = possibleSymbols.SelectRandom(random); 165 196 var tree = selectedSymbol.CreateTreeNode(); … … 168 199 } 169 200 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); 172 204 } 173 205 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r6944 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 [NonDiscoverableType] 31 33 [StorableClass] 32 34 [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")] … … 62 64 } 63 65 64 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 68 } 69 70 public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar { 65 71 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } 66 72 } … … 74 80 public GrowTreeCreator() 75 81 : 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.")); 80 90 } 81 91 … … 91 101 globalScope = globalScope.Parent; 92 102 93 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 103 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, 104 (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 94 105 } 95 106 return base.Apply(); … … 97 108 98 109 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); 100 116 } 101 117 … … 107 123 /// <param name="grammar">Available tree grammar</param> 108 124 /// <param name="maxTreeDepth">Maximum tree depth</param> 125 /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param> 109 126 /// <returns></returns> 110 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {127 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 111 128 var tree = new SymbolicExpressionTree(); 112 129 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); … … 115 132 116 133 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 134 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 117 135 startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar)); 118 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);119 136 120 137 rootNode.AddSubtree(startNode); 121 138 122 Grow(random, startNode, maxTreeDepth - 2);139 Create(random, startNode, maxTreeDepth - 2); 123 140 tree.Root = rootNode; 124 141 return tree; 125 142 } 126 143 127 public static void Grow(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) {144 public static void Create(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxDepth) { 128 145 // make sure it is possible to create a trees smaller than maxDepth 129 146 if (seedNode.Grammar.GetMinimumExpressionDepth(seedNode.Symbol) > maxDepth) … … 135 152 throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero."); 136 153 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(); 140 162 var selectedSymbol = possibleSymbols.SelectRandom(random); 141 163 var tree = selectedSymbol.CreateTreeNode(); … … 146 168 // Only iterate over the non-terminal nodes (those which have arity > 0) 147 169 // 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) { 153 176 var arity = SampleArity(random, root); 154 177 if (arity <= 0) 155 178 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 156 179 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."); 163 191 var selectedSymbol = possibleSymbols.SelectRandom(random); 164 192 var tree = selectedSymbol.CreateTreeNode(); … … 167 195 } 168 196 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); 171 200 } 172 201 -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r6911 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.PluginInfrastructure; 30 31 31 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 33 [NonDiscoverableType] 32 34 [StorableClass] 33 35 [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")] … … 101 103 } 102 104 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) { 105 110 SymbolicExpressionTree tree = new SymbolicExpressionTree(); 106 111 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
r6887 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.ComponentModel;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.PluginInfrastructure; 31 28 32 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 30 [NonDiscoverableType] 33 31 [StorableClass] 34 32 [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")] … … 52 50 public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { 53 51 get { 54 return 55 (IValueLookupParameter<ISymbolicExpressionGrammar>) 56 Parameters[SymbolicExpressionTreeGrammarParameterName]; 52 return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; 57 53 } 58 54 } … … 60 56 public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter { 61 57 get { 62 return 63 (ILookupParameter<ISymbolicExpressionGrammar>) 64 Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; 58 return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; 65 59 } 66 60 } … … 72 66 } 73 67 74 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 68 public IntValue MaximumSymbolicExpressionTreeLength { 69 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 70 } 71 72 public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar { 75 73 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } 76 74 } … … 83 81 public RampedHalfAndHalfTreeCreator() 84 82 : 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.")); 89 91 } 90 92 … … 100 102 globalScope = globalScope.Parent; 101 103 102 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 104 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, 105 (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 103 106 } 104 107 return base.Apply(); … … 106 109 107 110 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); 109 116 } 110 117 … … 115 122 /// <param name="random">Random generator</param> 116 123 /// <param name="grammar">Available tree grammar</param> 124 /// <param name="maxTreeLength">Maximum tree length (this parameter is ignored)</param> 117 125 /// <param name="maxTreeDepth">Maximum tree depth</param> 118 126 /// <returns></returns> 119 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {127 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 120 128 var tree = new SymbolicExpressionTree(); 121 129 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); … … 124 132 125 133 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 134 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 126 135 startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar)); 127 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);128 136 129 137 rootNode.AddSubtree(startNode); … … 132 140 133 141 if (p < 0.5) 134 GrowTreeCreator. Grow(random, startNode, maxTreeDepth - 2);142 GrowTreeCreator.Create(random, startNode, maxTreeDepth - 2); 135 143 else 136 FullTreeCreator. Grow(random, startNode, maxTreeDepth - 2);144 FullTreeCreator.Create(random, startNode, maxTreeDepth - 2); 137 145 138 146 tree.Root = rootNode; -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs
r6233 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 39 39 #endregion 40 40 41 #region Prope ties41 #region Properties 42 42 public ISymbolicExpressionTree SymbolicExpressionTree { 43 43 get { return SymbolicExpressionTreeParameter.ActualValue; } … … 60 60 61 61 protected abstract ISymbolicExpressionTree Create(IRandom random); 62 public abstract ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth); 62 63 } 63 64 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r7119 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs
r7035 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Formatters/SymbolicExpressionTreeStringFormatter.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
r6978 r7344 94 94 </PropertyGroup> 95 95 <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> 96 135 <Reference Include="System" /> 97 136 <Reference Include="System.Core"> … … 190 229 </ItemGroup> 191 230 <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>259 231 <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> 260 232 <Visible>False</Visible> -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/IReadOnlySymbol.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammarBase.cs
r6911 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 40 40 41 41 int GetMinimumExpressionDepth(ISymbol start); 42 int GetMaximumExpressionDepth(ISymbol start); 42 43 int GetMinimumExpressionLength(ISymbol start); 43 44 int GetMaximumExpressionLength(ISymbol start, int maxDepth); -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeGrammar.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs
r7035 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeStringFormatter.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeAnalyzer.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeArchitectureAlteringOperator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeArchitectureManipulator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 public interface ISymbolicExpressionTreeCreator : ISymbolicExpressionTreeOperator, ISolutionCreator { 30 30 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 31 ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth); 31 32 } 32 33 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCrossover.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeGrammarBasedOperator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeOperator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeSizeConstraintOperator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs
r5925 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs
r6439 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs
r6929 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 74 74 List<ISymbolicExpressionTreeManipulator> list = new List<ISymbolicExpressionTreeManipulator>(); 75 75 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)); 79 80 } 80 81 CheckedItemList<ISymbolicExpressionTreeManipulator> checkedItemList = new CheckedItemList<ISymbolicExpressionTreeManipulator>(); -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
r6439 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs
r6817 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame
r6866 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 27 27 namespace 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$")] 29 29 [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame
r6866 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 [assembly: AssemblyCompany("")] 33 33 [assembly: AssemblyProduct("HeuristicLab")] 34 [assembly: AssemblyCopyright("(c) 2002-201 1HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2012 HEAL")] 35 35 [assembly: AssemblyTrademark("")] 36 36 [assembly: AssemblyCulture("")] … … 45 45 46 46 [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 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6911 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 82 82 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 83 83 cachedMinExpressionDepth = new Dictionary<string, int>(); 84 cachedMaxExpressionDepth = new Dictionary<string, int>(); 84 85 85 86 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 94 95 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 95 96 cachedMinExpressionDepth = new Dictionary<string, int>(); 97 cachedMaxExpressionDepth = new Dictionary<string, int>(); 96 98 97 99 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 117 119 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 118 120 cachedMinExpressionDepth = new Dictionary<string, int>(); 121 cachedMaxExpressionDepth = new Dictionary<string, int>(); 119 122 120 123 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 134 137 foreach (var s in symbol.Flatten()) { 135 138 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)); 137 141 } 138 142 ClearCaches(); … … 371 375 cachedMaxExpressionLength.Clear(); 372 376 cachedMinExpressionDepth.Clear(); 377 cachedMaxExpressionDepth.Clear(); 373 378 374 379 cachedIsAllowedChildSymbol.Clear(); … … 427 432 } 428 433 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 429 450 public event EventHandler Changed; 430 451 protected virtual void OnChanged() { -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 [Item("SymbolicExpressionTree", "Represents a symbolic expression tree.")] 32 32 public class SymbolicExpressionTree : Item, ISymbolicExpressionTree { 33 public override ImageItemImage {33 public static new Image StaticItemImage { 34 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; } 35 35 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs
r6911 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 45 45 private ISymbolicExpressionGrammar grammar; 46 46 public SymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar) 47 : base("SymbolicExpressionTreeGrammar", "A grammar that is used held by symbolic expression trees and allows extensions to the wrap ed grammar.") {47 : base("SymbolicExpressionTreeGrammar", "A grammar that is used held by symbolic expression trees and allows extensions to the wrapped grammar.") { 48 48 if (grammar == null) throw new ArgumentNullException(); 49 49 this.grammar = grammar; … … 119 119 else return base.GetMinimumExpressionDepth(symbol); 120 120 } 121 int ISymbolicExpressionGrammarBase.GetMaximumExpressionDepth(ISymbol symbol) { 122 if (symbols.Count == 0) return grammar.GetMaximumExpressionDepth(symbol); 123 else return base.GetMaximumExpressionDepth(symbol); 124 } 121 125 int ISymbolicExpressionGrammarBase.GetMinimumExpressionLength(ISymbol symbol) { 122 126 if (symbols.Count == 0) return grammar.GetMinimumExpressionLength(symbol); … … 127 131 else return base.GetMaximumExpressionLength(symbol, maxDepth); 128 132 } 133 129 134 } 130 135 } -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r7035 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeOperator.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs
r6684 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs
r6233 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ArgumentTreeNode.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/DefunTreeNode.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/GroupSymbol.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunctionTreeNode.cs
r5809 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gp-crossover/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs
r6803 r7344 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.