1 | namespace HeuristicLab.Problems.ProgramSynthesis.Push.Erc {
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 |
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Data;
|
---|
8 | using HeuristicLab.Parameters;
|
---|
9 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
10 | using HeuristicLab.Problems.ProgramSynthesis.Push.Erc.Interfaces;
|
---|
11 |
|
---|
12 | [StorableClass]
|
---|
13 | public class IntegerErcOptions : ErcOption, IReadOnlyIntegerErcOptions {
|
---|
14 | private const string ConstantsParameterName = "Constants";
|
---|
15 | private const string RangeParameterName = "Range";
|
---|
16 |
|
---|
17 | public IntegerErcOptions() : this(default(int), default(int)) {
|
---|
18 | }
|
---|
19 |
|
---|
20 | public IntegerErcOptions(int start, int end, params int[] constants) {
|
---|
21 | Parameters.Add(new FixedValueParameter<IntArray>(ConstantsParameterName, new IntArray(constants)));
|
---|
22 | Parameters.Add(new FixedValueParameter<IntRange>(RangeParameterName, new IntRange(start, end)));
|
---|
23 | }
|
---|
24 |
|
---|
25 | [StorableConstructor]
|
---|
26 | private IntegerErcOptions(bool deserializing) : base(deserializing) { }
|
---|
27 |
|
---|
28 | public IntegerErcOptions(IntegerErcOptions origin, Cloner cloner) : base(origin, cloner) { }
|
---|
29 |
|
---|
30 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
31 | return new IntegerErcOptions(this, cloner);
|
---|
32 | }
|
---|
33 |
|
---|
34 | public IValueParameter<IntArray> ConstantsParameter
|
---|
35 | {
|
---|
36 | get { return (IValueParameter<IntArray>)Parameters[ConstantsParameterName]; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public IReadOnlyList<int> Constants
|
---|
40 | {
|
---|
41 | get { return ConstantsParameter.Value.Data; }
|
---|
42 | set { ConstantsParameter.Value = new IntArray(value.ToArray()); }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public IValueParameter<IntRange> RangeParameter
|
---|
46 | {
|
---|
47 | get { return (IValueParameter<IntRange>)Parameters[RangeParameterName]; }
|
---|
48 | }
|
---|
49 |
|
---|
50 | /// <summary>
|
---|
51 | /// The minimum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
|
---|
52 | /// </summary>
|
---|
53 | public int Start
|
---|
54 | {
|
---|
55 | get { return RangeParameter.Value.Start; }
|
---|
56 | set { RangeParameter.Value.Start = value; }
|
---|
57 | }
|
---|
58 |
|
---|
59 | /// <summary>
|
---|
60 | /// The maximum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
|
---|
61 | /// </summary>
|
---|
62 | public int End
|
---|
63 | {
|
---|
64 | get { return RangeParameter.Value.End; }
|
---|
65 | set { RangeParameter.Value.End = value; }
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|