Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibrary.cs @ 2202

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

Created a branch for #713

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using HeuristicLab.Data;
29using HeuristicLab.Constraints;
30
31namespace HeuristicLab.GP {
32  public class FunctionLibrary : ItemBase, IEditable {
33    private List<IFunction> functions = new List<IFunction>();
34    public IEnumerable<IFunction> Functions {
35      get { return functions; }
36    }
37
38    public FunctionLibrary()
39      : base() {
40    }
41
42
43    public void AddFunction(IFunction fun) {
44      if (!functions.Contains(fun)) functions.Add(fun);
45      // OnFunctionAdded(fun);
46    }
47
48    //void UpdateTreeBounds(object sender, EventArgs e) {
49    //  RecalculateMinimalTreeBounds();
50    //}
51
52
53    //private void GetMinMaxArity(IOperator op, out int minArity, out int maxArity) {
54    //  foreach (IConstraint constraint in op.Constraints) {
55    //    NumberOfSubOperatorsConstraint theConstraint = constraint as NumberOfSubOperatorsConstraint;
56    //    if (theConstraint != null) {
57    //      minArity = theConstraint.MinOperators.Data;
58    //      maxArity = theConstraint.MaxOperators.Data;
59    //      return;
60    //    }
61    //  }
62    //  // the default arity is 2
63    //  minArity = 2;
64    //  maxArity = 2;
65    //}
66
67    public void RemoveFunction(IFunction fun) {
68      functions.Remove(fun);
69
70      // remove the operator from the allowed sub-functions of the remaining operators
71      foreach (IFunction f in Functions) {
72        if (f != fun) {
73        }
74      }
75      // OnFunctionRemoved(fun);
76    }
77
78    //public event EventHandler FunctionAdded;
79    //public event EventHandler FunctionRemoved;
80
81    //protected virtual void OnFunctionAdded(IFunction fun) {
82    //  if (FunctionAdded != null) {
83    //    FunctionAdded(this, new EventArgs(fun));
84    //  }
85    //}
86    //protected virtual void OnFunctionRemoved(IFunction fun) {
87    //  if (FunctionRemoved != null) {
88    //    FunctionRemoved(this, new EventArgs(fun));
89    //  }
90    //}
91
92    public override IView CreateView() {
93      return new FunctionLibraryEditor(this);
94    }
95
96    #region IEditable Members
97
98    public IEditor CreateEditor() {
99      return new FunctionLibraryEditor(this);
100    }
101
102    #endregion
103  }
104}
Note: See TracBrowser for help on using the repository browser.