Changeset 5207 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
- Timestamp:
- 01/04/11 02:18:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
r5184 r5207 25 25 do { 26 26 val = Math.Round((random.NextDouble() * (UpperBound.Value - LowerBound.Value) + LowerBound.Value) / StepSize.Value, 0) * StepSize.Value; 27 } while ( val < LowerBound.Value || val > UpperBound.Value);27 } while (!IsInRange(val)); 28 28 return new PercentValue(val); 29 29 } … … 33 33 } 34 34 35 public void ApplyStepSize(PercentValue value) { 36 value.Value = ((int)Math.Round(value.Value / this.StepSize.Value, 0)) * this.StepSize.Value; 37 } 38 39 public bool IsInRange(double value) { 40 return value <= this.UpperBound.Value && value >= this.LowerBound.Value; 41 } 42 35 43 public override IEnumerable<PercentValue> GetCombinations() { 36 44 var solutions = new List<PercentValue>(); 37 double value = ((int)Math.Round(LowerBound.Value / StepSize.Value, 0)) * StepSize.Value; 38 if (value < LowerBound.Value) value += StepSize.Value; 45 double value = LowerBound.Value; 39 46 40 47 while (value <= UpperBound.Value) {
Note: See TracChangeset
for help on using the changeset viewer.