Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/EmptyExpression.cs @ 18242

Last change on this file since 18242 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

File size: 7.2 KB
Line 
1using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
2
3namespace HeuristicLab.Problems.ProgramSynthesis {
4  /// <summary>
5  /// Tells whether that stack is empty.
6  /// </summary>
7  [StorableClass]
8  public abstract class EmptyExpression : StatelessExpression {
9    protected EmptyExpression() { }
10    [StorableConstructor]
11    protected EmptyExpression(bool deserializing) : base(deserializing) { }
12
13    public override bool IsNoop(IInternalPushInterpreter interpreter) {
14      return false;
15    }
16
17    public void Eval(IPushStack stack, IPushStack<bool> booleanStack) {
18      booleanStack.Push(stack.IsEmpty);
19    }
20  }
21
22  [StorableClass]
23  [PushExpression(
24    StackTypes.Exec,
25    "EXEC.EMPTY",
26    "Pushes TRUE onto the BOOLEAN stack if the EXEC stack is empty, otherwise FALSE.",
27    StackTypes.Boolean)]
28  public class ExecEmptyExpression : EmptyExpression {
29    public ExecEmptyExpression() { }
30    [StorableConstructor]
31    protected ExecEmptyExpression(bool deserializing) : base(deserializing) { }
32
33    public override void Eval(IInternalPushInterpreter interpreter) {
34      Eval(interpreter.ExecStack, interpreter.BooleanStack);
35    }
36  }
37
38  [StorableClass]
39  [PushExpression(
40    StackTypes.Code,
41    "CODE.EMPTY",
42    "Pushes TRUE onto the BOOLEAN stack if the CODE stack is empty, otherwise FALSE.",
43    StackTypes.Boolean)]
44  public class CodeEmptyExpression : EmptyExpression {
45    public CodeEmptyExpression() { }
46    [StorableConstructor]
47    protected CodeEmptyExpression(bool deserializing) : base(deserializing) { }
48    public override void Eval(IInternalPushInterpreter interpreter) {
49      Eval(interpreter.CodeStack, interpreter.BooleanStack);
50    }
51  }
52
53  [StorableClass]
54  [PushExpression(
55    StackTypes.Integer,
56    "INTEGER.EMPTY",
57    "Pushes TRUE onto the BOOLEAN stack if the INTEGER stack is empty, otherwise FALSE.",
58    StackTypes.Boolean)]
59  public class IntegerEmptyExpression : EmptyExpression {
60    public IntegerEmptyExpression() { }
61    [StorableConstructor]
62    protected IntegerEmptyExpression(bool deserializing) : base(deserializing) { }
63    public override void Eval(IInternalPushInterpreter interpreter) {
64      Eval(interpreter.IntegerStack, interpreter.BooleanStack);
65    }
66  }
67
68  [StorableClass]
69  [PushExpression(
70    StackTypes.Float,
71    "FLOAT.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the FLOAT stack is empty, otherwise FALSE.",
72    StackTypes.Boolean)]
73  public class FloatEmptyExpression : EmptyExpression {
74    public FloatEmptyExpression() { }
75    [StorableConstructor]
76    protected FloatEmptyExpression(bool deserializing) : base(deserializing) { }
77    public override void Eval(IInternalPushInterpreter interpreter) {
78      Eval(interpreter.FloatStack, interpreter.BooleanStack);
79    }
80  }
81
82  [StorableClass]
83  [PushExpression(
84    StackTypes.Boolean,
85    "BOOLEAN.EMPTY",
86    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN stack is empty, otherwise FALSE.")]
87  public class BooleanEmptyExpression : EmptyExpression {
88    public BooleanEmptyExpression() { }
89    [StorableConstructor]
90    protected BooleanEmptyExpression(bool deserializing) : base(deserializing) { }
91    public override void Eval(IInternalPushInterpreter interpreter) {
92      Eval(interpreter.BooleanStack, interpreter.BooleanStack);
93    }
94  }
95
96  [StorableClass]
97  [PushExpression(
98    StackTypes.Char,
99    "CHAR.EMPTY",
100    "Pushes TRUE onto the BOOLEAN stack if the CHAR stack is empty, otherwise FALSE.",
101    StackTypes.Boolean)]
102  public class CharEmptyExpression : EmptyExpression {
103    public CharEmptyExpression() { }
104    [StorableConstructor]
105    protected CharEmptyExpression(bool deserializing) : base(deserializing) { }
106    public override void Eval(IInternalPushInterpreter interpreter) {
107      Eval(interpreter.CharStack, interpreter.BooleanStack);
108    }
109  }
110
111  [StorableClass]
112  [PushExpression(
113    StackTypes.String,
114    "STRING.EMPTY",
115    "Pushes TRUE onto the BOOLEAN stack if the STRING stack is empty, otherwise FALSE.",
116    StackTypes.Boolean)]
117  public class StringEmptyExpression : EmptyExpression {
118    public StringEmptyExpression() { }
119    [StorableConstructor]
120    protected StringEmptyExpression(bool deserializing) : base(deserializing) { }
121    public override void Eval(IInternalPushInterpreter interpreter) {
122      Eval(interpreter.StringStack, interpreter.BooleanStack);
123    }
124  }
125
126  [StorableClass]
127  [PushExpression(
128    StackTypes.IntegerVector,
129    "INTEGER[].EMPTY",
130    "Pushes TRUE onto the BOOLEAN stack if the INTEGER[] stack is empty, otherwise FALSE.",
131    StackTypes.Boolean)]
132  public class IntegerVectorEmptyExpression : EmptyExpression {
133    public IntegerVectorEmptyExpression() { }
134    [StorableConstructor]
135    protected IntegerVectorEmptyExpression(bool deserializing) : base(deserializing) { }
136    public override void Eval(IInternalPushInterpreter interpreter) {
137      Eval(interpreter.IntegerVectorStack, interpreter.BooleanStack);
138    }
139  }
140
141  [StorableClass]
142  [PushExpression(
143    StackTypes.FloatVector,
144    "FLOAT[].EMPTY",
145    "Pushes TRUE onto the BOOLEAN stack if the FLOAT[] stack is empty, otherwise FALSE.",
146    StackTypes.Boolean)]
147  public class FloatVectorEmptyExpression : EmptyExpression {
148    public FloatVectorEmptyExpression() { }
149    [StorableConstructor]
150    protected FloatVectorEmptyExpression(bool deserializing) : base(deserializing) { }
151    public override void Eval(IInternalPushInterpreter interpreter) {
152      Eval(interpreter.FloatVectorStack, interpreter.BooleanStack);
153    }
154  }
155
156  [StorableClass]
157  [PushExpression(
158    StackTypes.BooleanVector,
159    "BOOLEAN[].EMPTY",
160    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN[] stack is empty, otherwise FALSE.",
161    StackTypes.Boolean)]
162  public class BooleanVectorEmptyExpression : EmptyExpression {
163    public BooleanVectorEmptyExpression() { }
164    [StorableConstructor]
165    protected BooleanVectorEmptyExpression(bool deserializing) : base(deserializing) { }
166    public override void Eval(IInternalPushInterpreter interpreter) {
167      Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack);
168    }
169  }
170
171  [StorableClass]
172  [PushExpression(
173    StackTypes.StringVector,
174    "STRING[].EMPTY",
175    "Pushes TRUE onto the BOOLEAN stack if the STRING[] stack is empty, otherwise FALSE.",
176    StackTypes.Boolean)]
177  public class StringVectorEmptyExpression : EmptyExpression {
178    public StringVectorEmptyExpression() { }
179    [StorableConstructor]
180    protected StringVectorEmptyExpression(bool deserializing) : base(deserializing) { }
181    public override void Eval(IInternalPushInterpreter interpreter) {
182      Eval(interpreter.StringVectorStack, interpreter.BooleanStack);
183    }
184  }
185
186  [StorableClass]
187  [PushExpression(
188  StackTypes.Print,
189  "PRINT.EMPTY",
190  "Pushes TRUE onto the BOOLEAN stack if the PRINT stack is empty, otherwise FALSE.",
191  StackTypes.Boolean)]
192  public class PrintEmptyExpression : EmptyExpression {
193    public PrintEmptyExpression() { }
194    [StorableConstructor]
195    protected PrintEmptyExpression(bool deserializing) : base(deserializing) { }
196    public override void Eval(IInternalPushInterpreter interpreter) {
197      Eval(interpreter.PrintStack, interpreter.BooleanStack);
198    }
199  }
200}
Note: See TracBrowser for help on using the repository browser.