Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Data;
|
---|
6 | using HeuristicLab.Common;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.MetaOptimization {
|
---|
9 | public class PercentValueRange : Range<PercentValue> {
|
---|
10 |
|
---|
11 | public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { }
|
---|
12 | public PercentValueRange() { }
|
---|
13 | protected PercentValueRange(PercentValueRange original, Cloner cloner) : base(original, cloner) { }
|
---|
14 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
15 | return new PercentValueRange(this, cloner);
|
---|
16 | }
|
---|
17 |
|
---|
18 | public override PercentValue GetRandomValue() {
|
---|
19 | Random rand = new Random(); // todo: use common random
|
---|
20 | double val;
|
---|
21 | do {
|
---|
22 | val = Math.Round((rand.NextDouble() * (UpperBound.Value - LowerBound.Value) + LowerBound.Value) / StepSize.Value, 0) * StepSize.Value;
|
---|
23 | } while (val < LowerBound.Value || val > UpperBound.Value);
|
---|
24 | return new PercentValue(val);
|
---|
25 | }
|
---|
26 | }
|
---|
27 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.