Changeset 7143 for trunk/sources
- Timestamp:
- 12/06/11 19:41:26 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
r7124 r7143 46 46 private const string UpdateIntervalParameterName = "UpdateInterval"; 47 47 private const string UpdateCounterParameterName = "UpdateCounter"; 48 private const string GenerationCounterParameterName = "GenerationCounter"; 48 49 49 50 #region Parameter properties … … 67 68 get { return (ValueParameter<IntValue>)Parameters[UpdateIntervalParameterName]; } 68 69 } 69 public LookupParameter<IntValue> UpdateCounterParameter { 70 get { return (LookupParameter<IntValue>)Parameters[UpdateCounterParameterName]; } 71 } 70 public ValueParameter<IntValue> UpdateCounterParameter { 71 get { return (ValueParameter<IntValue>)Parameters[UpdateCounterParameterName]; } 72 } 73 public ValueParameter<IntValue> GenerationCounterParameter { 74 get { return (ValueParameter<IntValue>)Parameters[GenerationCounterParameterName]; } 75 } 76 #endregion 77 78 #region Properties 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 public IntValue GenerationCounter { 89 get { return GenerationCounterParameter.Value; } 90 } 91 72 92 #endregion 73 93 … … 90 110 Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false))); 91 111 Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1))); 92 Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", "MinMaxAverageSymbolicExpressionTreeLengthAnalyzerUpdateCounter")); 112 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 113 Parameters.Add(new ValueParameter<IntValue>(GenerationCounterParameterName, "The value of the total number of generations this operator has been applied.", new IntValue(0))); 93 114 94 115 UpdateCounterParameter.Hidden = true; … … 107 128 } 108 129 if (!Parameters.ContainsKey(UpdateCounterParameterName)) { 109 Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", "MinMaxAverageSymbolicExpressionTreeLengthAnalyzerUpdateCounter")); 130 Parameters.Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update")); 131 } 132 if (!Parameters.ContainsKey(GenerationCounterParameterName)) { 133 Parameters.Add(new ValueParameter<IntValue>(GenerationCounterParameterName, "The value of the total number of generations this operator has been applied.", new IntValue(1))); 110 134 } 111 135 } 112 136 113 137 public override IOperation Apply() { 114 int updateInterval = UpdateIntervalParameter.Value.Value; 115 IntValue updateCounter = UpdateCounterParameter.ActualValue; 138 //IntValue updateCounter = UpdateCounterParameter.Value; 116 139 // if the counter doesn't exist yet, we initialize it here with the current update interval 117 if (updateCounter == null) { 118 updateCounter = new IntValue(updateInterval); 119 UpdateCounterParameter.ActualValue = updateCounter; 120 } else updateCounter.Value++; 140 GenerationCounter.Value++; 141 UpdateCounter.Value++; 121 142 122 143 // the analyzer runs periodically, every 'updateInterval' times 123 if ( updateCounter.Value == updateInterval) {124 updateCounter.Value = 0; // reset counter144 if (UpdateCounter.Value == UpdateInterval.Value) { 145 UpdateCounter.Value = 0; // reset counter 125 146 126 147 // compute all tree lengths and store them in the lengthsTable … … 202 223 const string treeLengthHistoryTableName = "Tree lengths history"; 203 224 const string treeLengthHistoryRowPrefix = "Tree lengths "; 204 int currentGeneration = ((IntValue)results["Generations"].Value).Value;205 225 206 226 if (storeHistory) { 207 227 // store tree lengths for each generation 208 var historyDataRow = new DataRow(treeLengthHistoryRowPrefix + currentGeneration, "Symbolic expression tree lengths at generation " + currentGeneration, treeLengthsTableRow.Values);228 var historyDataRow = new DataRow(treeLengthHistoryRowPrefix + GenerationCounter.Value, "Symbolic expression tree lengths at generation " + GenerationCounter.Value, treeLengthsTableRow.Values); 209 229 historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 210 230 historyDataRow.VisualProperties.ExactBins = false;
Note: See TracChangeset
for help on using the changeset viewer.