Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/AntTrail.cs @ 3238

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

Implemented a solution visualizer for the artificial ant problem. #952 (Artificial Ant Problem for 3.3)

File size: 3.3 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 HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
28
29namespace HeuristicLab.Problems.ArtificialAnt {
30  /// <summary>
31  /// Represents a trail of an artificial ant which can be visualized in the GUI.
32  /// </summary>
33  [Item("AntTrail", "Represents a trail of an artificial ant which can be visualized in the GUI.")]
34  [StorableClass]
35  public sealed class AntTrail : Item {
36    private SymbolicExpressionTree expression;
37    [Storable]
38    public SymbolicExpressionTree SymbolicExpressionTree {
39      get { return expression; }
40      set {
41        if (expression != value) {
42          //if (expression != null) DeregisterSymbolicExpressionTreeEvents();
43          expression = value;
44          //if (expression != null) RegisterSymbolicExpressionTreeEvents();
45          OnSymbolicExpressionTreeChanged();
46        }
47      }
48    }
49
50    public AntTrail() : base() { }
51    public AntTrail(SymbolicExpressionTree expression)
52      : this() {
53      SymbolicExpressionTree = expression;
54    }
55
56    public override IDeepCloneable Clone(Cloner cloner) {
57      AntTrail clone = new AntTrail();
58      cloner.RegisterClonedObject(this, clone);
59      clone.expression = (SymbolicExpressionTree)cloner.Clone(expression);
60      return clone;
61    }
62
63    //#region Events
64    public event EventHandler SymbolicExpressionTreeChanged;
65    private void OnSymbolicExpressionTreeChanged() {
66      if (SymbolicExpressionTreeChanged != null)
67        SymbolicExpressionTreeChanged(this, EventArgs.Empty);
68    }
69
70    //private void RegisterSymbolicExpressionTreeEvents() {
71    //  SymbolicExpressionTree.ItemChanged += new EventHandler<EventArgs<int>>(SymbolicExpressionTree_ItemChanged);
72    //  SymbolicExpressionTree.Reset += new EventHandler(SymbolicExpressionTree_Reset);
73    //}
74    //private void DeregisterSymbolicExpressionTreeEvents() {
75    //  SymbolicExpressionTree.ItemChanged -= new EventHandler<EventArgs<int>>(SymbolicExpressionTree_ItemChanged);
76    //  SymbolicExpressionTree.Reset -= new EventHandler(SymbolicExpressionTree_Reset);
77    //}
78
79    //private void SymbolicExpressionTree_ItemChanged(object sender, EventArgs<int> e) {
80    //  OnSymbolicExpressionTreeChanged();
81    //}
82    //private void SymbolicExpressionTree_Reset(object sender, EventArgs e) {
83    //  OnSymbolicExpressionTreeChanged();
84    //}
85    //#endregion
86  }
87}
Note: See TracBrowser for help on using the repository browser.