1 | namespace HeuristicLab.Problems.ProgramSynthesis.Push.Configuration {
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using Base.Erc;
|
---|
4 | using Common;
|
---|
5 | using Persistence.Default.CompositeSerializers.Storable;
|
---|
6 |
|
---|
7 | [StorableClass]
|
---|
8 | public class PushConfiguration : PushConfigurationBase, IReadOnlyPushConfiguration {
|
---|
9 | public PushConfiguration() {
|
---|
10 | Name = "Push Configuration";
|
---|
11 |
|
---|
12 | ErcOptions = new ErcOptions();
|
---|
13 | EvalPushLimit = 1024;
|
---|
14 | MinPointsInProgram = 25;
|
---|
15 | MaxPointsInProgram = 200;
|
---|
16 | TopLevelPushCode = true;
|
---|
17 | TopLevelPopCode = false;
|
---|
18 | MaxPointsInRandomExpression = 64;
|
---|
19 | MaxStringLength = 1000;
|
---|
20 | MaxVectorLength = 500;
|
---|
21 | MaxDepth = 100;
|
---|
22 | FloatStringFormat = "R";
|
---|
23 | MaxParenthesesClose = 4;
|
---|
24 | ParenthesesCloseBiasLevel = 1;
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | [StorableConstructor]
|
---|
29 | public PushConfiguration(bool deserializing)
|
---|
30 | : base(deserializing) {
|
---|
31 | }
|
---|
32 |
|
---|
33 | public PushConfiguration(PushConfiguration origin, Cloner cloner) : base(origin, cloner) {
|
---|
34 |
|
---|
35 | ErcOptions = cloner.Clone(origin.ErcOptions);
|
---|
36 | EvalPushLimit = origin.EvalPushLimit;
|
---|
37 | MinPointsInProgram = origin.MinPointsInProgram;
|
---|
38 | MaxPointsInProgram = origin.MaxPointsInProgram;
|
---|
39 | MaxPointsInRandomExpression = origin.MaxPointsInRandomExpression;
|
---|
40 | TopLevelPushCode = origin.TopLevelPushCode;
|
---|
41 | TopLevelPopCode = origin.TopLevelPopCode;
|
---|
42 | MaxStringLength = origin.MaxStringLength;
|
---|
43 | MaxVectorLength = origin.MaxVectorLength;
|
---|
44 | MaxDepth = origin.MaxDepth;
|
---|
45 | FloatStringFormat = origin.FloatStringFormat;
|
---|
46 | MaxParenthesesClose = origin.MaxParenthesesClose;
|
---|
47 | ParenthesesCloseBiasLevel = origin.ParenthesesCloseBiasLevel;
|
---|
48 | }
|
---|
49 |
|
---|
50 | [Storable]
|
---|
51 | public string FloatStringFormat { get; set; }
|
---|
52 |
|
---|
53 |
|
---|
54 | IReadOnlyList<string> IReadOnlyPushConfiguration.EnabledExpressions { get { return enabledExpressions; } }
|
---|
55 |
|
---|
56 | [Storable]
|
---|
57 | public int MaxParenthesesClose { get; set; }
|
---|
58 | [Storable]
|
---|
59 | public double ParenthesesCloseBiasLevel { get; set; }
|
---|
60 |
|
---|
61 |
|
---|
62 | [Storable]
|
---|
63 | public ErcOptions ErcOptions { get; set; }
|
---|
64 |
|
---|
65 | IReadOnlyErcOptions IReadOnlyPushConfiguration.ErcOptions { get { return ErcOptions; } }
|
---|
66 |
|
---|
67 | /// <summary>
|
---|
68 | /// This is the maximum allowed number of "executions" in a single top-level call to the interpreter.
|
---|
69 | /// The execution of a single Push instruction counts as one execution, as does the processing of a single literal,
|
---|
70 | /// as does the descent into one layer of parentheses (that is, the processing of the "(" counts as one execution).
|
---|
71 | /// When this limit is exceeded the interpreter aborts immediately, leaving its stacks in the states they were in prior
|
---|
72 | /// to the abort (so they may still be examined by a calling program). Whether or not this counts as an "abnormal"
|
---|
73 | /// termination
|
---|
74 | /// is up to the calling program.
|
---|
75 | /// </summary>
|
---|
76 | [Storable]
|
---|
77 | public int EvalPushLimit { get; set; }
|
---|
78 |
|
---|
79 | /// <summary>
|
---|
80 | /// This is the maximum of depth a push program can have. Expressions, which lead to exceed this limit are interpreted as NOOP.
|
---|
81 | /// </summary>
|
---|
82 | [Storable]
|
---|
83 | public int MaxDepth { get; set; }
|
---|
84 |
|
---|
85 | /// <summary>
|
---|
86 | /// This is the minimum size of an item on the CODE stack, expressed as a number of points.
|
---|
87 | /// A point is an instruction, a literal, or a pair of parentheses. Any instruction that would cause this limit to be
|
---|
88 | /// exceeded should instead act as a NOOP, leaving all stacks in the states that they were in before the execution of the
|
---|
89 | /// instruction.
|
---|
90 | /// </summary>
|
---|
91 | [Storable]
|
---|
92 | public int MinPointsInProgram { get; set; }
|
---|
93 |
|
---|
94 | /// <summary>
|
---|
95 | /// This is the maximum size of an item on the CODE stack, expressed as a number of points.
|
---|
96 | /// A point is an instruction, a literal, or a pair of parentheses. Any instruction that would cause this limit to be
|
---|
97 | /// exceeded should instead act as a NOOP, leaving all stacks in the states that they were in before the execution of the
|
---|
98 | /// instruction.
|
---|
99 | /// </summary>
|
---|
100 | [Storable]
|
---|
101 | public int MaxPointsInProgram { get; set; }
|
---|
102 |
|
---|
103 | /// <summary>
|
---|
104 | /// The maximum number of points in an expression produced by the CODE.RAND instruction.
|
---|
105 | /// </summary>
|
---|
106 | [Storable]
|
---|
107 | public int MaxPointsInRandomExpression { get; set; }
|
---|
108 |
|
---|
109 | /// <summary>
|
---|
110 | /// When TRUE (which is the default), code passed to the top level of the interpreter
|
---|
111 | /// will be pushed onto the CODE stack prior to execution.
|
---|
112 | /// </summary>
|
---|
113 | [Storable]
|
---|
114 | public bool TopLevelPushCode { get; set; }
|
---|
115 |
|
---|
116 | /// <summary>
|
---|
117 | /// When TRUE, the CODE stack will be popped at the end of top level calls to the interpreter. The default is FALSE.
|
---|
118 | /// </summary>
|
---|
119 | [Storable]
|
---|
120 | public bool TopLevelPopCode { get; set; }
|
---|
121 |
|
---|
122 | [Storable]
|
---|
123 | public int MaxStringLength { get; set; }
|
---|
124 |
|
---|
125 | [Storable]
|
---|
126 | public int MaxVectorLength { get; set; }
|
---|
127 |
|
---|
128 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
129 | return new PushConfiguration(this, cloner);
|
---|
130 | }
|
---|
131 | }
|
---|
132 | } |
---|