Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureAlteringOperators/SymbolicExpressionTreeArchitectureAlteringOperator.cs @ 3462

Last change on this file since 3462 was 3462, checked in by gkronber, 14 years ago

Refactored symbolic expression tree encoding and problem classes for symbolic regression. #937 , #938

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Operators;
28using HeuristicLab.Optimization;
29using HeuristicLab.Parameters;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
32using System.Collections.Generic;
33using System.Text;
34using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
35
36namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureAlteringOperators {
37  /// <summary>
38  /// Base class for architecture altering operators for symbolic expression trees.
39  /// </summary>
40  [StorableClass]
41  public abstract class SymbolicExpressionTreeArchitectureAlteringOperator : SymbolicExpressionTreeManipulator {
42    private const string MaxFunctionArgumentsParameterName = "MaxFunctionArguments";
43    private const string MaxFunctionDefiningBranchesParameterName = "MaxFunctionDefiningBranches";
44    public override bool CanChangeName {
45      get { return false; }
46    }
47
48    public IValueLookupParameter<IntValue> MaxFunctionDefiningBranchesParameter {
49      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionDefiningBranchesParameterName]; }
50    }
51    public IValueLookupParameter<IntValue> MaxFunctionArgumentsParameter {
52      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; }
53    }
54    public IntValue MaxFunctionDefiningBranches {
55      get { return MaxFunctionDefiningBranchesParameter.ActualValue; }
56    }
57    public IntValue MaxFunctionArguments {
58      get { return MaxFunctionArgumentsParameter.ActualValue; }
59    }
60    public SymbolicExpressionTreeArchitectureAlteringOperator()
61      : base() {
62      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionDefiningBranchesParameterName, "The maximal allowed number of function defining branches."));
63      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionArgumentsParameterName, "The maximal allowed number of arguments of a newly created function."));
64    }
65
66    protected override sealed void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar, IntValue maxTreeSize, IntValue maxTreeHeight, out bool success) {
67      ModifyArchitecture(random, symbolicExpressionTree, grammar, maxTreeSize, maxTreeHeight, MaxFunctionDefiningBranches, MaxFunctionArguments, out success);
68    }
69
70    public abstract void ModifyArchitecture(
71      IRandom random,
72      SymbolicExpressionTree tree,
73      ISymbolicExpressionGrammar grammar,
74      IntValue maxTreeSize,
75      IntValue maxTreeHeight,
76      IntValue maxFunctionDefiningBranches,
77      IntValue maxFunctionArguments,
78      out bool success
79      );
80  }
81}
Note: See TracBrowser for help on using the repository browser.