Changeset 12319 for branches/SymbolicExpressionTreeEncoding
- Timestamp:
- 04/16/15 11:05:23 (10 years ago)
- Location:
- branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r12012 r12319 308 308 } 309 309 public virtual IEnumerable<ISymbol> AllowedSymbols { 310 get { foreach (var s in Symbols) if (s.Enabled) yield return s; }310 get { return Symbols.Where(s => s.Enabled); } 311 311 } 312 312 public virtual bool ContainsSymbol(ISymbol symbol) { … … 510 510 if (suppressEvents) return; 511 511 var handler = Changed; 512 if (handler != null) Changed(this, EventArgs.Empty);512 if (handler != null) handler(this, EventArgs.Empty); 513 513 } 514 514 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
r12196 r12319 187 187 <Compile Include="Formatters\SymbolicExpressionTreeHierarchicalFormatter.cs" /> 188 188 <Compile Include="Grammars\EmptySymbolicExpressionTreeGrammar.cs" /> 189 <Compile Include="Grammars\SimpleSymbolicExpressionGrammar.cs" /> 189 190 <Compile Include="Interfaces\IReadOnlySymbol.cs" /> 190 191 <Compile Include="Interfaces\ISymbolicExpressionGrammar.cs" /> … … 236 237 <Compile Include="Symbols\ArgumentTreeNode.cs" /> 237 238 <Compile Include="Symbols\GroupSymbol.cs" /> 239 <Compile Include="Symbols\SimpleSymbol.cs" /> 238 240 <Compile Include="Symbols\StartSymbol.cs" /> 239 241 <Compile Include="Symbols\InvokeFunction.cs" /> -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs
r12316 r12319 36 36 [Item("SymbolicExpressionTreeEncoding", "Describes a symbolic expression tree encoding.")] 37 37 [StorableClass] 38 public class SymbolicExpressionTreeEncoding : Encoding<ISymbolicExpressionTreeCreator> {38 public sealed class SymbolicExpressionTreeEncoding : Encoding<ISymbolicExpressionTreeCreator> { 39 39 #region Encoding Parameters 40 40 [Storable] … … 159 159 160 160 [StorableConstructor] 161 p ublicSymbolicExpressionTreeEncoding(bool deserializing) : base(deserializing) { }162 public SymbolicExpressionTreeEncoding( ) : this("SymbolicExpressionTree") { }163 164 public SymbolicExpressionTreeEncoding(string name )161 private SymbolicExpressionTreeEncoding(bool deserializing) : base(deserializing) { } 162 public SymbolicExpressionTreeEncoding(ISymbolicExpressionGrammar grammar) : this("SymbolicExpressionTree", grammar, 50, 50) { } 163 public SymbolicExpressionTreeEncoding(ISymbolicExpressionGrammar grammar, int maximumLength, int maximumDepth) : this("SymbolicExpressionTree", grammar, maximumLength, maximumDepth) { } 164 public SymbolicExpressionTreeEncoding(string name, ISymbolicExpressionGrammar grammar, int maximumLength, int maximumDepth) 165 165 : base(name) { 166 treeLengthParameter = new FixedValueParameter<IntValue>("Maximium Tree Length", "Maximal length of the symbolic expression.", new IntValue( 50));167 treeDepthParameter = new FixedValueParameter<IntValue>("Maximum Tree Depth", "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.", new IntValue( 50));168 grammarParameter = new ValueParameter<ISymbolicExpressionGrammar>("Grammar", "The grammar that should be used for symbolic expression tree." );166 treeLengthParameter = new FixedValueParameter<IntValue>("Maximium Tree Length", "Maximal length of the symbolic expression.", new IntValue(maximumLength)); 167 treeDepthParameter = new FixedValueParameter<IntValue>("Maximum Tree Depth", "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.", new IntValue(maximumDepth)); 168 grammarParameter = new ValueParameter<ISymbolicExpressionGrammar>("Grammar", "The grammar that should be used for symbolic expression tree.", grammar); 169 169 functionDefinitionsParameter = new FixedValueParameter<IntValue>("Function Definitions", "Maximal number of automatically defined functions", new IntValue(0)); 170 170 functionArgumentsParameter = new FixedValueParameter<IntValue>("Function Arguments", "Maximal number of arguments of automatically defined functions.", new IntValue(0)); 171 172 //TODO set default grammar173 171 174 172 Parameters.Add(treeLengthParameter); … … 185 183 private SymbolicExpressionTreeEncoding(SymbolicExpressionTreeEncoding original, Cloner cloner) 186 184 : base(original, cloner) { 187 TreeLengthParameter = cloner.Clone(original.TreeLengthParameter);188 TreeDepthParameter = cloner.Clone(original.TreeDepthParameter);189 GrammarParameter = cloner.Clone(original.GrammarParameter);190 FunctionDefinitionsParameter = cloner.Clone(original.FunctionDefinitionsParameter);191 FunctionArgumentsParameter = cloner.Clone(original.FunctionArgumentsParameter);185 treeLengthParameter = cloner.Clone(original.TreeLengthParameter); 186 treeDepthParameter = cloner.Clone(original.TreeDepthParameter); 187 grammarParameter = cloner.Clone(original.GrammarParameter); 188 functionDefinitionsParameter = cloner.Clone(original.FunctionDefinitionsParameter); 189 functionArgumentsParameter = cloner.Clone(original.FunctionArgumentsParameter); 192 190 RegisterParameterEvents(); 193 191 } … … 208 206 private void OnGrammarParameterChanged() { 209 207 RegisterGrammarParameterEvents(); 208 FunctionArguments = Grammar.MaximumFunctionArguments; 209 FunctionDefinitions = Grammar.MaximumFunctionDefinitions; 210 210 ConfigureOperators(Operators); 211 211 } … … 230 230 231 231 232 private void RegisterLengthParameterEvents() { 233 TreeLengthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 234 } 235 236 private void RegisterDepthParameterEvents() { 237 TreeDepthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 238 } 232 private void RegisterLengthParameterEvents() { } 233 private void RegisterDepthParameterEvents() { } 234 239 235 private void RegisterGrammarParameterEvents() { 240 GrammarParameter.ValueChanged += (o, s) => ConfigureOperators(Operators); 241 GrammarParameter.Value.Changed += (o, s) => ConfigureOperators(Operators); 236 GrammarParameter.ValueChanged += (o, s) => { 237 FunctionArguments = Grammar.MaximumFunctionArguments; 238 FunctionDefinitions = Grammar.MaximumFunctionDefinitions; 239 ConfigureOperators(Operators); 240 }; 241 GrammarParameter.Value.Changed += (o, s) => { 242 FunctionArguments = Grammar.MaximumFunctionArguments; 243 FunctionDefinitions = Grammar.MaximumFunctionDefinitions; 244 ConfigureOperators(Operators); 245 }; 242 246 } 243 247
Note: See TracChangeset
for help on using the changeset viewer.