Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/Expression.cs @ 14952

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

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

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