Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs @ 4047

Last change on this file since 4047 was 3539, checked in by gkronber, 15 years ago

Cosmetic name-space rename. #937 (Data types and operators for symbolic expression tree encoding)

File size: 3.7 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;
35using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
36
37namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators {
38  /// <summary>
39  /// Base class for architecture altering operators for symbolic expression trees.
40  /// </summary>
41  [StorableClass]
42  public abstract class SymbolicExpressionTreeArchitectureManipulator : SymbolicExpressionTreeManipulator, ISymbolicExpressionTreeArchitectureManipulator {
43    private const string MaxFunctionArgumentsParameterName = "MaxFunctionArguments";
44    private const string MaxFunctionDefiningBranchesParameterName = "MaxFunctionDefiningBranches";
45    public override bool CanChangeName {
46      get { return false; }
47    }
48
49    public IValueLookupParameter<IntValue> MaxFunctionDefinitionsParameter {
50      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionDefiningBranchesParameterName]; }
51    }
52    public IValueLookupParameter<IntValue> MaxFunctionArgumentsParameter {
53      get { return (IValueLookupParameter<IntValue>)Parameters[MaxFunctionArgumentsParameterName]; }
54    }
55    public IntValue MaxFunctionDefiningBranches {
56      get { return MaxFunctionDefinitionsParameter.ActualValue; }
57    }
58    public IntValue MaxFunctionArguments {
59      get { return MaxFunctionArgumentsParameter.ActualValue; }
60    }
61    public SymbolicExpressionTreeArchitectureManipulator()
62      : base() {
63      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionDefiningBranchesParameterName, "The maximal allowed number of function defining branches."));
64      Parameters.Add(new ValueLookupParameter<IntValue>(MaxFunctionArgumentsParameterName, "The maximal allowed number of arguments of a newly created function."));
65    }
66
67    protected override sealed void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar, IntValue maxTreeSize, IntValue maxTreeHeight, out bool success) {
68      ModifyArchitecture(random, symbolicExpressionTree, grammar, maxTreeSize, maxTreeHeight, MaxFunctionDefiningBranches, MaxFunctionArguments, out success);
69    }
70
71    public abstract void ModifyArchitecture(
72      IRandom random,
73      SymbolicExpressionTree tree,
74      ISymbolicExpressionGrammar grammar,
75      IntValue maxTreeSize,
76      IntValue maxTreeHeight,
77      IntValue maxFunctionDefinitions,
78      IntValue maxFunctionArguments,
79      out bool success
80      );
81  }
82}
Note: See TracBrowser for help on using the repository browser.