Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Erc/IntegerErcOptions.cs @ 14834

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

#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,

File size: 2.3 KB
Line 
1namespace 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}
Note: See TracBrowser for help on using the repository browser.