Free cookie consent management tool by TermsFeed Policy Generator

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

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

Added first version of architecture altering operators for ADFs. #290 (Implement ADFs)

File size: 3.5 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.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols;
31using System.Collections.Generic;
32using System.Text;
33
34namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
35  /// <summary>
36  /// Base class for architecture altering operators for symbolic expression trees.
37  /// </summary>
38  [StorableClass]
39  public abstract class SymbolicExpressionTreeArchitectureAlteringOperator : SymbolicExpressionTreeManipulator {
40    private const string MaxFunctionArgumentsParameterName = "MaxFunctionArguments";
41    private const string MaxFunctionDefiningBranchesParameterName = "MaxFunctionDefiningBranches";
42    public override bool CanChangeName {
43      get { return false; }
44    }
45
46    public IValueLookupParameter<IntValue> MaxFunctionDefiningBranchesParameter {
47      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionDefiningBranchesParameterName]; }
48    }
49    public IValueLookupParameter<IntValue> MaxFunctionArgumentsParameter {
50      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; }
51    }
52    public IntValue MaxFunctionDefiningBranches {
53      get { return MaxFunctionDefiningBranchesParameter.ActualValue; }
54    }
55    public IntValue MaxFunctionArguments {
56      get { return MaxFunctionArgumentsParameter.ActualValue; }
57    }
58    public SymbolicExpressionTreeArchitectureAlteringOperator()
59      : base() {
60      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionDefiningBranchesParameterName, "The maximal allowed number of function defining branches."));
61      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionArgumentsParameterName, "The maximal allowed number of arguments of a newly created function."));
62    }
63
64    protected override sealed void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar, IntValue maxTreeSize, IntValue maxTreeHeight, out bool success) {
65      ModifyArchitecture(random, symbolicExpressionTree, grammar, maxTreeSize, maxTreeHeight, MaxFunctionDefiningBranches, MaxFunctionArguments, out success);
66    }
67
68    public abstract void ModifyArchitecture(
69      IRandom random,
70      SymbolicExpressionTree tree,
71      ISymbolicExpressionGrammar grammar,
72      IntValue maxTreeSize,
73      IntValue maxTreeHeight,
74      IntValue maxFunctionDefiningBranches,
75      IntValue maxFunctionArguments,
76      out bool success
77      );
78  }
79}
Note: See TracBrowser for help on using the repository browser.