Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

File size: 2.4 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 FloatErcOptions : ErcOption, IReadOnlyFloatErcOptions {
14    private const string ConstantsParameterName = "Constants";
15    private const string RangeParameterName = "Range";
16
17    public FloatErcOptions() : this(default(double), default(double)) {
18    }
19
20    public FloatErcOptions(double start, double end, params double[] constants) {
21      Parameters.Add(new FixedValueParameter<DoubleArray>(ConstantsParameterName, new DoubleArray(constants) { Resizable = true }));
22      Parameters.Add(new FixedValueParameter<DoubleRange>(RangeParameterName, new DoubleRange(start, end)));
23    }
24
25    [StorableConstructor]
26    private FloatErcOptions(bool deserializing) : base(deserializing) { }
27
28    public FloatErcOptions(FloatErcOptions origin, Cloner cloner) : base(origin, cloner) { }
29
30    public override IDeepCloneable Clone(Cloner cloner) {
31      return new FloatErcOptions(this, cloner);
32    }
33
34    public IValueParameter<DoubleArray> ConstantsParameter
35    {
36      get { return (IValueParameter<DoubleArray>)Parameters[ConstantsParameterName]; }
37    }
38
39    public IReadOnlyList<double> Constants
40    {
41      get { return ConstantsParameter.Value.Data; }
42      set { ConstantsParameter.Value = new DoubleArray(value.ToArray()); }
43    }
44
45    public IValueParameter<DoubleRange> RangeParameter
46    {
47      get { return (IValueParameter<DoubleRange>)Parameters[RangeParameterName]; }
48    }
49
50    /// <summary>
51    /// The minimum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
52    /// </summary>
53    public double Start
54    {
55      get { return RangeParameter.Value.Start; }
56      set { RangeParameter.Value.Start = value; }
57    }
58
59    /// <summary>
60    /// The maximum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
61    /// </summary>
62    public double 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.