Last change
on this file since 14897 was
14897,
checked in by pkimmesw, 7 years ago
|
#2665 Dynamic ErcValues, Separate Push from BenchmarkSuite Push
|
File size:
1.6 KB
|
Line | |
---|
1 | namespace HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer {
|
---|
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 IntegerRangeErcValue : WeightedErcValueItem<int> {
|
---|
10 | private const string RangeParameterName = "Range";
|
---|
11 |
|
---|
12 | public IntegerRangeErcValue() {
|
---|
13 | this.Parameters.Add(new FixedValueParameter<IntRange>(RangeParameterName));
|
---|
14 | }
|
---|
15 |
|
---|
16 | public IntegerRangeErcValue(int start, int end) : this() {
|
---|
17 | this.Start = start;
|
---|
18 | this.End = end;
|
---|
19 | }
|
---|
20 |
|
---|
21 | [StorableConstructor]
|
---|
22 | public IntegerRangeErcValue(bool deseralizing) : base(deseralizing) { }
|
---|
23 |
|
---|
24 | public IntegerRangeErcValue(IntegerRangeErcValue origin, Cloner cloner) : base(origin, cloner) { }
|
---|
25 |
|
---|
26 | public IValueParameter<IntRange> RangeParameter
|
---|
27 | {
|
---|
28 | get { return (IValueParameter<IntRange>)this.Parameters[RangeParameterName]; }
|
---|
29 | }
|
---|
30 |
|
---|
31 | public int Start
|
---|
32 | {
|
---|
33 | get { return this.RangeParameter.Value.Start; }
|
---|
34 | set { this.RangeParameter.Value.Start = value; }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public int End
|
---|
38 | {
|
---|
39 | get { return this.RangeParameter.Value.End; }
|
---|
40 | set { this.RangeParameter.Value.End = value; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public override int GetErcValue(IRandom random) {
|
---|
44 |
|
---|
45 | return this.Start < this.End ? random.Next(this.Start, this.End) : 0;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
49 | return new IntegerRangeErcValue(this, cloner);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.