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
RevLine 
[3294]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;
[3376]24using HeuristicLab.Common;
[3294]25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Operators;
28using HeuristicLab.Optimization;
29using HeuristicLab.Parameters;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[3462]31using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
[3294]32using System.Collections.Generic;
33using System.Text;
[3462]34using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
[3534]35using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
[3294]36
[3539]37namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators {
[3294]38  /// <summary>
39  /// Base class for architecture altering operators for symbolic expression trees.
40  /// </summary>
41  [StorableClass]
[3534]42  public abstract class SymbolicExpressionTreeArchitectureManipulator : SymbolicExpressionTreeManipulator, ISymbolicExpressionTreeArchitectureManipulator {
[3294]43    private const string MaxFunctionArgumentsParameterName = "MaxFunctionArguments";
44    private const string MaxFunctionDefiningBranchesParameterName = "MaxFunctionDefiningBranches";
45    public override bool CanChangeName {
46      get { return false; }
47    }
48
[3534]49    public IValueLookupParameter<IntValue> MaxFunctionDefinitionsParameter {
[3294]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 {
[3534]56      get { return MaxFunctionDefinitionsParameter.ActualValue; }
[3294]57    }
58    public IntValue MaxFunctionArguments {
59      get { return MaxFunctionArgumentsParameter.ActualValue; }
60    }
[3534]61    public SymbolicExpressionTreeArchitectureManipulator()
[3294]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,
[3534]77      IntValue maxFunctionDefinitions,
[3294]78      IntValue maxFunctionArguments,
79      out bool success
80      );
81  }
82}
Note: See TracBrowser for help on using the repository browser.