Line | |
---|
1 | namespace HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Float {
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Data;
|
---|
5 | using HeuristicLab.Parameters;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 |
|
---|
8 | [StorableClass]
|
---|
9 | public class FloatRangeErcValue : WeightedErcValueItem<double> {
|
---|
10 | private const string RangeParameterName = "Range";
|
---|
11 |
|
---|
12 | public FloatRangeErcValue() {
|
---|
13 | Name = "Float range";
|
---|
14 | this.Parameters.Add(new FixedValueParameter<DoubleRange>(RangeParameterName));
|
---|
15 | }
|
---|
16 |
|
---|
17 | public FloatRangeErcValue(double start, double end) : this() {
|
---|
18 | this.Start = start;
|
---|
19 | this.End = end;
|
---|
20 | }
|
---|
21 |
|
---|
22 | [StorableConstructor]
|
---|
23 | public FloatRangeErcValue(bool deseralizing) : base(deseralizing) { }
|
---|
24 |
|
---|
25 | public FloatRangeErcValue(FloatRangeErcValue origin, Cloner cloner) : base(origin, cloner) { }
|
---|
26 |
|
---|
27 | public IValueParameter<DoubleRange> RangeParameter
|
---|
28 | {
|
---|
29 | get { return (IValueParameter<DoubleRange>)this.Parameters[RangeParameterName]; }
|
---|
30 | }
|
---|
31 |
|
---|
32 | public double Start
|
---|
33 | {
|
---|
34 | get { return this.RangeParameter.Value.Start; }
|
---|
35 | set { this.RangeParameter.Value.Start = value; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public double End
|
---|
39 | {
|
---|
40 | get { return this.RangeParameter.Value.End; }
|
---|
41 | set { this.RangeParameter.Value.End = value; }
|
---|
42 | }
|
---|
43 |
|
---|
44 | public override double GetErcValue(IRandom random) {
|
---|
45 | return Start < End && IsEnabled ? random.NextDouble() * (End - Start) + Start : 0d;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
49 | return new FloatRangeErcValue(this, cloner);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.