Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Trail.cs @ 12961

Last change on this file since 12961 was 12911, checked in by gkronber, 9 years ago

#2472: created project structure for HeuristicLab.Problems.GeneticProgramming and added implementations of ArtificialAnt and LawnMower

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Drawing;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.GeneticProgramming.ArtificialAnt {
31  /// <summary>
32  /// Represents a trail of an artificial ant which can be visualized in the GUI.
33  /// </summary>
34  [Item("AntTrail", "Represents a trail of an artificial ant which can be visualized in the GUI.")]
35  [StorableClass]
36  public sealed class Solution : Item {
37    public static new Image StaticItemImage {
38      get { return HeuristicLab.Common.Resources.VSImageLibrary.Image; }
39    }
40    [Storable]
41    public ISymbolicExpressionTree SymbolicExpressionTree { get; private set; }
42    [Storable]
43    public BoolMatrix World { get; private set; }
44    [Storable]
45    public int MaxTimeSteps { get; private set; }
46    [Storable]
47    public double Quality { get; private set; }
48
49    public Solution(BoolMatrix world, ISymbolicExpressionTree expression, int maxTimeSteps, double quality) {
50      this.World = world;
51      this.SymbolicExpressionTree = expression;
52      this.MaxTimeSteps = maxTimeSteps;
53      this.Quality = quality;
54    }
55
56    [StorableConstructor]
57    private Solution(bool deserializing) : base(deserializing) { }
58    [StorableHook(HookType.AfterDeserialization)]
59    private void AfterDeserialization() { }
60
61    private Solution(Solution original, Cloner cloner)
62      : base(original, cloner) {
63      SymbolicExpressionTree = cloner.Clone(original.SymbolicExpressionTree);
64      World = cloner.Clone(original.World);
65      MaxTimeSteps = original.MaxTimeSteps;
66      Quality = original.Quality;
67    }
68
69    public override IDeepCloneable Clone(Cloner cloner) {
70      return new Solution(this, cloner);
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.