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 CharErcOptions : ErcOption, IReadOnlyCharErcOptions {
|
---|
14 | private const string ConstantsParameterName = "Constants";
|
---|
15 | private const string RangeParameterName = "Range";
|
---|
16 |
|
---|
17 | public CharErcOptions() : this('a', 'Z') {
|
---|
18 | }
|
---|
19 |
|
---|
20 | public CharErcOptions(int start, int end, params char[] constants) {
|
---|
21 | Parameters.Add(new FixedValueParameter<StringValue>(ConstantsParameterName, new StringValue(new string(constants))));
|
---|
22 | Parameters.Add(new FixedValueParameter<IntRange>(RangeParameterName, new IntRange(start, end)));
|
---|
23 | }
|
---|
24 |
|
---|
25 | [StorableConstructor]
|
---|
26 | private CharErcOptions(bool deserializing) : base(deserializing) { }
|
---|
27 |
|
---|
28 | public CharErcOptions(CharErcOptions origin, Cloner cloner) : base(origin, cloner) { }
|
---|
29 |
|
---|
30 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
31 | return new CharErcOptions(this, cloner);
|
---|
32 | }
|
---|
33 |
|
---|
34 | public IValueParameter<StringValue> ConstantsParameter
|
---|
35 | {
|
---|
36 | get { return (IValueParameter<StringValue>)Parameters[ConstantsParameterName]; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public IReadOnlyList<char> Constants
|
---|
40 | {
|
---|
41 | get { return ConstantsParameter.Value.Value.ToCharArray(); }
|
---|
42 | set { ConstantsParameter.Value.Value = new string(value.ToArray()); }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public IValueParameter<IntRange> RangeParameter
|
---|
46 | {
|
---|
47 | get { return (IValueParameter<IntRange>)Parameters[RangeParameterName]; }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public int Start
|
---|
51 | {
|
---|
52 | get { return RangeParameter.Value.Start; }
|
---|
53 | set { RangeParameter.Value.Start = value; }
|
---|
54 | }
|
---|
55 |
|
---|
56 | public int End
|
---|
57 | {
|
---|
58 | get { return RangeParameter.Value.End; }
|
---|
59 | set { RangeParameter.Value.End = value; }
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|