Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/Expression.cs @ 16958

Last change on this file since 16958 was 15344, checked in by pkimmesw, 7 years ago

#2665 Fixed Integer Overflow Exceptions, Adjusted Offspring Selection Experiments

File size: 1.3 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using System;
3
4  using HeuristicLab.Common;
5  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6  using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;
7
8  using Interpreter;
9
10  [Serializable]
11  [StorableClass]
12  public abstract class Expression : IDeepCloneable, IPooledObject {
13
14    protected Expression() { }
15
16    [StorableConstructor]
17    protected Expression(bool deserializing) { }
18    protected Expression(Expression origin, Cloner cloner) { }
19
20    public bool IsProgram { get { return GetType() == typeof(PushProgram); } }
21
22    public abstract string StringRepresentation { get; }
23
24    public abstract bool IsNoop(IInternalPushInterpreter interpreter);
25    public abstract void Eval(IInternalPushInterpreter interpreter);
26
27    public bool TryEval(IInternalPushInterpreter interpreter) {
28      if (IsNoop(interpreter))
29        return false;
30
31      Eval(interpreter);
32      return true;
33    }
34
35    public override string ToString() {
36      return StringRepresentation;
37    }
38
39    public object Clone() {
40      return this;
41    }
42
43    public virtual IDeepCloneable Clone(Cloner cloner) {
44      return this;
45    }
46
47    void IPooledObject.Reset() { }
48  }
49}
Note: See TracBrowser for help on using the repository browser.