Enabled saving only for some specific items (#1193)
[heuristiclab.git] / HeuristicLab.Encodings.IntegerVectorEncoding / 3.3 / Tests / TestRandom.cs
blobc2f1455f6a99797e674d6f5b9230e4d5a6cf6cb1
1 #region License Information
2 /* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 * This file is part of HeuristicLab.
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 #endregion
22 using System;
23 using HeuristicLab.Common;
24 using HeuristicLab.Core;
26 namespace HeuristicLab.Encodings.IntegerVectorEncoding_33.Tests {
27 public class TestRandom : IRandom {
28 #region Variables and Properties
29 private int[] intNumbers;
30 public int[] IntNumbers {
31 get { return intNumbers; }
32 set {
33 if (value == null) intNumbers = new int[0];
34 else intNumbers = value;
37 private int nextIntIndex;
38 private double[] doubleNumbers;
39 public double[] DoubleNumbers {
40 get { return doubleNumbers; }
41 set {
42 if (value == null) doubleNumbers = new double[0];
43 else doubleNumbers = value;
46 private int nextDoubleIndex;
47 #endregion
49 public TestRandom() {
50 intNumbers = new int[0];
51 doubleNumbers = new double[0];
52 nextIntIndex = 0;
53 nextDoubleIndex = 0;
56 public TestRandom(int[] intNumbers, double[] doubleNumbers) {
57 if (intNumbers == null) intNumbers = new int[0];
58 else this.intNumbers = intNumbers;
59 if (doubleNumbers == null) doubleNumbers = new double[0];
60 else this.doubleNumbers = doubleNumbers;
61 nextIntIndex = 0;
62 nextDoubleIndex = 0;
65 #region IRandom Members
67 public void Reset() {
68 nextIntIndex = 0;
69 nextDoubleIndex = 0;
72 public void Reset(int seed) {
73 throw new NotImplementedException();
76 public int Next() {
77 if (nextIntIndex >= intNumbers.Length) throw new InvalidOperationException("Random: No more integer random numbers available");
78 return intNumbers[nextIntIndex++];
81 public int Next(int maxVal) {
82 if (nextIntIndex >= intNumbers.Length) throw new InvalidOperationException("Random: No more integer random numbers available");
83 if (IntNumbers[nextIntIndex] >= maxVal) throw new InvalidOperationException("Random: Next integer random number (" + IntNumbers[nextIntIndex] + ") is >= " + maxVal);
84 return intNumbers[nextIntIndex++];
87 public int Next(int minVal, int maxVal) {
88 if (nextIntIndex >= intNumbers.Length) throw new InvalidOperationException("Random: No more integer random numbers available");
89 if (IntNumbers[nextIntIndex] < minVal || IntNumbers[nextIntIndex] >= maxVal) throw new InvalidOperationException("Random: Next integer random number (" + IntNumbers[nextIntIndex] + ") is not in the range [" + minVal + ";" + maxVal + ")");
90 return intNumbers[nextIntIndex++];
93 public double NextDouble() {
94 if (nextDoubleIndex >= doubleNumbers.Length) throw new InvalidOperationException("Random: No more double random numbers available");
95 if (doubleNumbers[nextDoubleIndex] < 0.0 || doubleNumbers[nextDoubleIndex] >= 1.0) throw new InvalidOperationException("Random: Next double ranomd number (" + DoubleNumbers[nextDoubleIndex] + ") is not in the range [0;1)");
96 return doubleNumbers[nextDoubleIndex++];
99 #endregion
101 #region IItem Members
103 public string ItemName {
104 get { throw new NotImplementedException(); }
107 public string ItemDescription {
108 get { throw new NotImplementedException(); }
111 public Version ItemVersion {
112 get { throw new NotImplementedException(); }
115 public System.Drawing.Image ItemImage {
116 get { throw new NotImplementedException(); }
119 #pragma warning disable 67
120 public event EventHandler ItemImageChanged;
121 public event EventHandler ToStringChanged;
122 #pragma warning restore 67
123 #endregion
125 #region IDeepCloneable Members
127 public IDeepCloneable Clone(Cloner cloner) {
128 throw new NotImplementedException();
131 #endregion
133 #region ICloneable Members
135 public object Clone() {
136 throw new NotImplementedException();
139 #endregion