Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/InExpressions.cs

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

#2665 Started Plush Encoding, Added Zero Error Individual Count Analyzer

File size: 4.6 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
3  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
4  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
5  using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
6
7  /// <summary>
8  /// InExpression has a state, but this state is static at compile time and therefore InExpression can be seen as stateless at runtime
9  /// </summary>
10  [StorableClass]
11  public abstract class InExpression : StatelessExpression {
12    private readonly int index;
13
14    protected InExpression(int nr) {
15      index = nr - 1;
16    }
17
18    [StorableConstructor]
19    protected InExpression(bool deserializing) : base(deserializing) { }
20
21    public override bool IsNoop(IInternalPushInterpreter interpreter) {
22      var expression = interpreter.InputExpressions[index];
23
24      return expression.IsNoop(interpreter);
25    }
26
27    public override void Eval(IInternalPushInterpreter interpreter) {
28      var expression = interpreter.InputExpressions[index];
29
30      expression.Eval(interpreter);
31    }
32  }
33
34  [PushExpression(
35    StackTypes.None,
36    "IN1",
37    "Pushes first input parameter.",
38    isHidden: true,
39    inExpressionNr: 1)]
40  [StorableClass]
41  public class In1Expression : InExpression {
42    public In1Expression() : base(1) { }
43
44    [StorableConstructor]
45    protected In1Expression(bool deserializing) : base(deserializing) { }
46  }
47
48  [PushExpression(
49    StackTypes.None,
50    "IN2",
51    "Pushes second input parameter.",
52    isHidden: true,
53    inExpressionNr: 2)]
54  [StorableClass]
55  public class In2Expression : InExpression {
56    public In2Expression() : base(2) { }
57
58    [StorableConstructor]
59    protected In2Expression(bool deserializing) : base(deserializing) { }
60  }
61
62  [PushExpression(
63   StackTypes.None,
64   "IN3",
65   "Pushes third input parameter.",
66    isHidden: true,
67    inExpressionNr: 3)]
68  [StorableClass]
69  public class In3Expression : InExpression {
70    public In3Expression() : base(3) { }
71
72    [StorableConstructor]
73    protected In3Expression(bool deserializing) : base(deserializing) { }
74  }
75
76  [PushExpression(
77    StackTypes.None,
78    "IN4",
79    "Pushes fourth input parameter.",
80    isHidden: true,
81    inExpressionNr: 4)]
82  [StorableClass]
83  public class In4Expression : InExpression {
84    public In4Expression() : base(4) { }
85
86    [StorableConstructor]
87    protected In4Expression(bool deserializing) : base(deserializing) { }
88  }
89
90  [PushExpression(
91    StackTypes.None,
92    "IN5",
93    "Pushes fifth input parameter.",
94    isHidden: true,
95    inExpressionNr: 5)]
96  [StorableClass]
97  public class In5Expression : InExpression {
98    public In5Expression() : base(5) { }
99
100    [StorableConstructor]
101    protected In5Expression(bool deserializing) : base(deserializing) { }
102  }
103
104  [PushExpression(
105    StackTypes.None,
106    "IN6",
107    "Pushes sixth input parameter.",
108    isHidden: true,
109    inExpressionNr: 6)]
110  [StorableClass]
111  public class In6Expression : InExpression {
112    public In6Expression() : base(6) { }
113
114    [StorableConstructor]
115    protected In6Expression(bool deserializing) : base(deserializing) { }
116  }
117
118  [PushExpression(
119    StackTypes.None,
120    "IN7",
121    "Pushes seventh input parameter.",
122    isHidden: true,
123    inExpressionNr: 7)]
124  [StorableClass]
125  public class In7Expression : InExpression {
126    public In7Expression() : base(7) { }
127
128    [StorableConstructor]
129    protected In7Expression(bool deserializing) : base(deserializing) { }
130  }
131
132  [PushExpression(
133    StackTypes.None,
134    "IN8",
135    "Pushes eighth input parameter.",
136    isHidden: true,
137    inExpressionNr: 8)]
138  [StorableClass]
139  public class In8Expression : InExpression {
140    public In8Expression() : base(8) { }
141
142    [StorableConstructor]
143    protected In8Expression(bool deserializing) : base(deserializing) { }
144  }
145
146  [PushExpression(
147    StackTypes.None,
148    "IN9",
149    "Pushes nineth input parameter.",
150    isHidden: true,
151    inExpressionNr: 9)]
152  [StorableClass]
153  public class In9Expression : InExpression {
154    public In9Expression() : base(9) { }
155
156    [StorableConstructor]
157    protected In9Expression(bool deserializing) : base(deserializing) { }
158  }
159
160  [PushExpression(
161    StackTypes.None,
162    "IN10",
163    "Pushes tenth input parameter.",
164    isHidden: true,
165    inExpressionNr: 10)]
166  [StorableClass]
167  public class In10Expression : InExpression {
168    public In10Expression() : base(10) { }
169
170    [StorableConstructor]
171    protected In10Expression(bool deserializing) : base(deserializing) { }
172  }
173}
Note: See TracBrowser for help on using the repository browser.