Rev | Line | |
---|
[4997] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.Data;
|
---|
| 6 | using HeuristicLab.Common;
|
---|
[5009] | 7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 8 | using HeuristicLab.Core;
|
---|
[4997] | 9 |
|
---|
| 10 | namespace HeuristicLab.Problems.MetaOptimization {
|
---|
[5009] | 11 | [StorableClass]
|
---|
[4997] | 12 | public class DoubleValueRange : Range<DoubleValue> {
|
---|
| 13 |
|
---|
| 14 | public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { }
|
---|
| 15 | public DoubleValueRange() { }
|
---|
[5009] | 16 | [StorableConstructor]
|
---|
| 17 | protected DoubleValueRange(bool deserializing) : base(deserializing) { }
|
---|
[4997] | 18 | protected DoubleValueRange(DoubleValueRange original, Cloner cloner) : base(original, cloner) { }
|
---|
| 19 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 20 | return new DoubleValueRange(this, cloner);
|
---|
| 21 | }
|
---|
| 22 |
|
---|
[5023] | 23 | protected override DoubleValue GetRandomSample(IRandom random) {
|
---|
[4997] | 24 | double val;
|
---|
| 25 | do {
|
---|
[5009] | 26 | val = Math.Round((random.NextDouble() * (UpperBound.Value - LowerBound.Value) + LowerBound.Value) / StepSize.Value, 0) * StepSize.Value;
|
---|
[4997] | 27 | } while (val < LowerBound.Value || val > UpperBound.Value);
|
---|
| 28 | return new DoubleValue(val);
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.