Changeset 763
- Timestamp:
- 11/15/08 16:47:45 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data/BoolArrayData.cs
r737 r763 95 95 Data = data; 96 96 } 97 /// <summary>98 /// The point of intersection where an <see cref="IObjectDataVisitor"/>99 /// can change the elements of the array.100 /// </summary>101 /// <param name="visitor">The visitor that changes the element.</param>102 public override void Accept(IObjectDataVisitor visitor) {103 visitor.Visit(this);104 }105 97 } 106 98 } -
trunk/sources/HeuristicLab.Data/BoolData.cs
r737 r763 98 98 Data = bool.Parse(node.InnerText); 99 99 } 100 101 /// <summary>102 /// The point of intersection where an <see cref="IObjectDataVisitor"/>103 /// can change the boolean element.104 /// </summary>105 /// <param name="visitor">The visitor that changes the element.</param>106 public override void Accept(IObjectDataVisitor visitor) {107 visitor.Visit(this);108 }109 100 } 110 101 } -
trunk/sources/HeuristicLab.Data/BoolMatrixData.cs
r737 r763 122 122 return builder.ToString(); 123 123 } 124 /// <summary>125 /// The point of intersection where an <see cref="IObjectDataVisitor"/>126 /// can change the elements of the matrix.127 /// </summary>128 /// <param name="visitor">The visitor that changes the elements.</param>129 public override void Accept(IObjectDataVisitor visitor) {130 visitor.Visit(this);131 }132 124 } 133 125 } -
trunk/sources/HeuristicLab.Data/ConstrainedDoubleData.cs
r737 r763 110 110 base.Data = (DoubleData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects); 111 111 } 112 113 /// <summary>114 /// The point of intersection where an <see cref="IObjectDataVisitor"/>115 /// can change the double value.116 /// </summary>117 /// <param name="visitor">The visitor that changes the element.</param>118 public override void Accept(IObjectDataVisitor visitor) {119 visitor.Visit(this);120 }121 112 } 122 113 } -
trunk/sources/HeuristicLab.Data/ConstrainedIntData.cs
r737 r763 110 110 base.Data = (IntData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects); 111 111 } 112 113 /// <summary>114 /// The point of intersection where an <see cref="IObjectDataVisitor"/>115 /// can change the int element.116 /// </summary>117 /// <param name="visitor">The visitor that changes the element.</param>118 public override void Accept(IObjectDataVisitor visitor) {119 visitor.Visit(this);120 }121 112 } 122 113 } -
trunk/sources/HeuristicLab.Data/ConstrainedObjectData.cs
r737 r763 137 137 return Data.ToString(); 138 138 } 139 140 /// <summary>141 /// The point of intersection where an <see cref="IObjectDataVisitor"/>142 /// can change the element.143 /// </summary>144 /// <param name="visitor">The visitor that changes the element.</param>145 public virtual void Accept(IObjectDataVisitor visitor) {146 visitor.Visit(this);147 }148 139 } 149 140 } -
trunk/sources/HeuristicLab.Data/DoubleArrayData.cs
r737 r763 117 117 return builder.ToString(); 118 118 } 119 120 /// <summary>121 /// The point of intersection where an <see cref="IObjectDataVisitor"/>122 /// can change the elements of the array.123 /// </summary>124 /// <param name="visitor">The visitor that changes the elements.</param>125 public override void Accept(IObjectDataVisitor visitor) {126 visitor.Visit(this);127 }128 119 } 129 120 } -
trunk/sources/HeuristicLab.Data/DoubleData.cs
r737 r763 109 109 } 110 110 } 111 112 /// <summary>113 /// The point of intersection where an <see cref="IObjectDataVisitor"/>114 /// can change the elements of the matrix.115 /// </summary>116 /// <param name="visitor">The visitor that changes the elements.</param>117 public override void Accept(IObjectDataVisitor visitor) {118 visitor.Visit(this);119 }120 111 } 121 112 } -
trunk/sources/HeuristicLab.Data/HeuristicLab.Data.csproj
r737 r763 3 3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 4 4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 5 <ProductVersion>9.0. 21022</ProductVersion>5 <ProductVersion>9.0.30729</ProductVersion> 6 6 <SchemaVersion>2.0</SchemaVersion> 7 7 <ProjectGuid>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</ProjectGuid> … … 180 180 </Compile> 181 181 <Compile Include="IObjectData.cs" /> 182 <Compile Include="IObjectDataVisitor.cs" />183 182 <Compile Include="ItemList.cs" /> 184 183 <Compile Include="ItemListView.cs"> … … 200 199 </Compile> 201 200 <Compile Include="ObjectData.cs" /> 202 <Compile Include="ObjectDataVisitorBase.cs" />203 201 <Compile Include="StringDataView.cs"> 204 202 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Data/IObjectData.cs
r737 r763 34 34 /// </summary> 35 35 object Data { get; set; } 36 37 /// <summary>38 /// The point of intersection where an <see cref="IObjectDataVisitor"/>39 /// can change the object.40 /// </summary>41 /// <param name="visitor">The visitor that changes the element.</param>42 void Accept(IObjectDataVisitor visitor);43 36 } 44 37 } -
trunk/sources/HeuristicLab.Data/IntData.cs
r737 r763 103 103 Data = int.Parse(node.InnerText, CultureInfo.InvariantCulture.NumberFormat); 104 104 } 105 106 /// <summary>107 /// The point of intersection where an <see cref="IObjectDataVisitor"/>108 /// can change the int value.109 /// </summary>110 /// <param name="visitor">The visitor that changes the element.</param>111 public override void Accept(IObjectDataVisitor visitor) {112 visitor.Visit(this);113 }114 105 } 115 106 } -
trunk/sources/HeuristicLab.Data/IntMatrixData.cs
r737 r763 139 139 return builder.ToString(); 140 140 } 141 142 /// <summary>143 /// The point of intersection where an <see cref="IObjectDataVisitor"/>144 /// can change the elements of the matrix.145 /// </summary>146 /// <param name="visitor">The visitor that changes the elements.</param>147 public override void Accept(IObjectDataVisitor visitor) {148 visitor.Visit(this);149 }150 141 } 151 142 } -
trunk/sources/HeuristicLab.Data/NullData.cs
r737 r763 58 58 return clone; 59 59 } 60 61 /// <summary>62 /// The point of intersection where an <see cref="IObjectDataVisitor"/>63 /// can change the value.64 /// </summary>65 /// <param name="visitor">The visitor that changes the element.</param>66 public override void Accept(IObjectDataVisitor visitor) {67 visitor.Visit(this);68 }69 60 } 70 61 } -
trunk/sources/HeuristicLab.Data/ObjectData.cs
r737 r763 120 120 return Data.ToString(); 121 121 } 122 123 /// <summary>124 /// The point of intersection where an <see cref="IObjectDataVisitor"/>125 /// can change the object.126 /// </summary>127 /// <param name="visitor">The visitor that changes the element.</param>128 public virtual void Accept(IObjectDataVisitor visitor) {129 visitor.Visit(this);130 }131 122 } 132 123 } -
trunk/sources/HeuristicLab.Data/StringData.cs
r737 r763 109 109 return Data; 110 110 } 111 112 /// <summary>113 /// The point of intersection where an <see cref="IObjectDataVisitor"/>114 /// can change the string.115 /// </summary>116 /// <param name="visitor">The visitor that changes the element.</param>117 public override void Accept(IObjectDataVisitor visitor) {118 visitor.Visit(this);119 }120 111 } 121 112 } -
trunk/sources/HeuristicLab.GP.Boolean/FunctionLibraryInjector.cs
r722 r763 73 73 And and = new And(); 74 74 Or or = new Or(); 75 Not not = new Not();75 //Not not = new Not(); 76 76 Nand nand = new Nand(); 77 77 Nor nor = new Nor(); 78 Xor xor = new Xor();78 //Xor xor = new Xor(); 79 79 variable = new HeuristicLab.GP.Boolean.Variable(); 80 80 … … 82 82 and, 83 83 or, 84 not,84 //not, 85 85 nand, 86 86 nor, 87 xor,87 //xor, 88 88 variable 89 89 }; … … 91 91 SetAllowedSubOperators(and, allFunctions); 92 92 SetAllowedSubOperators(or, allFunctions); 93 SetAllowedSubOperators(not, allFunctions);93 //SetAllowedSubOperators(not, allFunctions); 94 94 SetAllowedSubOperators(nand, allFunctions); 95 95 SetAllowedSubOperators(nor, allFunctions); 96 SetAllowedSubOperators(xor, allFunctions);96 //SetAllowedSubOperators(xor, allFunctions); 97 97 98 98 operatorLibrary = new GPOperatorLibrary(); 99 99 operatorLibrary.GPOperatorGroup.AddOperator(and); 100 100 operatorLibrary.GPOperatorGroup.AddOperator(or); 101 operatorLibrary.GPOperatorGroup.AddOperator(not);101 //operatorLibrary.GPOperatorGroup.AddOperator(not); 102 102 operatorLibrary.GPOperatorGroup.AddOperator(nand); 103 103 operatorLibrary.GPOperatorGroup.AddOperator(nor); 104 operatorLibrary.GPOperatorGroup.AddOperator(xor);104 //operatorLibrary.GPOperatorGroup.AddOperator(xor); 105 105 operatorLibrary.GPOperatorGroup.AddOperator(variable); 106 106 } -
trunk/sources/HeuristicLab.Random/NormalRandomAdder.cs
r719 r763 71 71 NormalDistributedRandom normal = new NormalDistributedRandom(mt, mu, sigma * factor); 72 72 73 value.Accept(new RandomAdderVisitor(normal)); 74 73 AddNormal(value, normal); 75 74 return null; 76 75 } 77 76 77 private void AddNormal(IObjectData value, NormalDistributedRandom normal) { 78 // dispatch manually based on dynamic type 79 if (value is IntData) 80 AddNormal((IntData)value, normal); 81 else if (value is ConstrainedIntData) 82 AddNormal((ConstrainedIntData)value, normal); 83 else if (value is ConstrainedDoubleData) 84 AddNormal((ConstrainedDoubleData)value, normal); 85 else if (value is DoubleData) 86 AddNormal((DoubleData)value, normal); 87 else throw new InvalidOperationException("Can't handle type " + value.GetType().Name); 88 } 89 public void AddNormal(DoubleData data, NormalDistributedRandom normal) { 90 data.Data += normal.NextDouble(); 91 } 78 92 79 private class RandomAdderVisitor : ObjectDataVisitorBase { 80 private NormalDistributedRandom normal; 81 public RandomAdderVisitor(NormalDistributedRandom normal) { 82 this.normal = normal; 93 public void AddNormal(ConstrainedDoubleData data, NormalDistributedRandom normal) { 94 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 95 double newValue = data.Data + normal.NextDouble(); 96 if (IsIntegerConstrained(data)) { 97 newValue = Math.Round(newValue); 98 } 99 if (data.TrySetData(newValue)) { 100 return; 101 } 83 102 } 103 throw new InvalidProgramException("Coudn't find a valid value"); 104 } 84 105 85 public override void Visit(DoubleData data) { 86 data.Data += normal.NextDouble(); 106 public void AddNormal(IntData data, NormalDistributedRandom normal) { 107 data.Data = (int)Math.Round(data.Data + normal.NextDouble()); 108 } 109 110 public void AddNormal(ConstrainedIntData data, NormalDistributedRandom normal) { 111 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 112 if (data.TrySetData((int)Math.Round(data.Data + normal.NextDouble()))) 113 return; 87 114 } 115 throw new InvalidProgramException("Couldn't find a valid value."); 116 } 88 117 89 public override void Visit(ConstrainedDoubleData data) { 90 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 91 double newValue = data.Data + normal.NextDouble(); 92 if(IsIntegerConstrained(data)) { 93 newValue = Math.Round(newValue); 94 } 95 if(data.TrySetData(newValue)) { 96 return; 97 } 118 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 119 foreach (IConstraint constraint in data.Constraints) { 120 if (constraint is IsIntegerConstraint) { 121 return true; 98 122 } 99 throw new InvalidProgramException("Coudn't find a valid value");100 123 } 101 102 public override void Visit(IntData data) { 103 data.Data = (int)Math.Round(data.Data + normal.NextDouble()); 104 } 105 106 public override void Visit(ConstrainedIntData data) { 107 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 108 if(data.TrySetData((int)Math.Round(data.Data + normal.NextDouble()))) 109 return; 110 } 111 throw new InvalidProgramException("Couldn't find a valid value."); 112 } 113 114 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 115 foreach(IConstraint constraint in data.Constraints) { 116 if(constraint is IsIntegerConstraint) { 117 return true; 118 } 119 } 120 return false; 121 } 124 return false; 122 125 } 123 126 } -
trunk/sources/HeuristicLab.Random/NormalRandomizer.cs
r719 r763 62 62 double mu = GetVariableValue<DoubleData>("Mu", scope, true).Data; 63 63 double sigma = GetVariableValue<DoubleData>("Sigma", scope, true).Data; 64 NormalDistributedRandom normal = new NormalDistributedRandom(mt, mu, sigma);65 64 66 value.Accept(new RandomizerVisitor(normal));67 65 NormalDistributedRandom n = new NormalDistributedRandom(mt, mu, sigma); 66 RandomizeNormal(value, n); 68 67 return null; 69 68 } 70 69 71 private class RandomizerVisitor : ObjectDataVisitorBase { 72 private NormalDistributedRandom normal; 70 private void RandomizeNormal(IObjectData value, NormalDistributedRandom n) { 71 // dispatch manually based on dynamic type 72 if (value is IntData) 73 RandomizeNormal((IntData)value, n); 74 else if (value is ConstrainedIntData) 75 RandomizeNormal((ConstrainedIntData)value, n); 76 else if (value is DoubleData) 77 RandomizeNormal((DoubleData)value, n); 78 else if (value is ConstrainedDoubleData) 79 RandomizeNormal((ConstrainedDoubleData)value, n); 80 else throw new InvalidOperationException("Can't handle type " + value.GetType().Name); 81 } 73 82 74 public RandomizerVisitor(NormalDistributedRandom normal) { 75 this.normal = normal; 83 public void RandomizeNormal(ConstrainedDoubleData data, NormalDistributedRandom normal) { 84 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 85 double r = normal.NextDouble(); 86 if (IsIntegerConstrained(data)) { 87 r = Math.Round(r); 88 } 89 if (data.TrySetData(r)) { 90 return; 91 } 76 92 } 93 throw new InvalidOperationException("Couldn't find a valid value in 100 tries with mu=" + normal.Mu + " sigma=" + normal.Sigma); 94 } 77 95 78 public override void Visit(ConstrainedDoubleData data) { 79 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 80 double r = normal.NextDouble(); 81 if(IsIntegerConstrained(data)) { 82 r = Math.Round(r); 83 } 84 if(data.TrySetData(r)) { 85 return; 86 } 87 } 88 throw new InvalidProgramException("Couldn't find a valid value in 100 tries with mu=" + normal.Mu + " sigma=" + normal.Sigma); 96 public void RandomizeNormal(ConstrainedIntData data, NormalDistributedRandom normal) { 97 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 98 double r = normal.NextDouble(); 99 if (data.TrySetData((int)Math.Round(r))) // since r is a continuous normally distributed random variable rounding should be OK 100 return; 89 101 } 102 throw new InvalidOperationException("Couldn't find a valid value"); 103 } 90 104 91 public override void Visit(ConstrainedIntData data) { 92 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 93 double r = normal.NextDouble(); 94 if(data.TrySetData((int)Math.Round(r))) // since r is a continuous normally distributed random variable rounding should be OK 95 return; 96 } 97 throw new InvalidProgramException("Couldn't find a valid value"); 98 } 105 public void RandomizeNormal(DoubleData data, NormalDistributedRandom normal) { 106 data.Data = normal.NextDouble(); 107 } 99 108 100 public override void Visit(DoubleData data) { 101 data.Data = normal.NextDouble(); 102 } 103 104 public override void Visit(IntData data) { 105 data.Data = (int)Math.Round(normal.NextDouble()); 106 } 109 public void RandomizeNormal(IntData data, NormalDistributedRandom normal) { 110 data.Data = (int)Math.Round(normal.NextDouble()); 111 } 107 112 108 113 109 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 110 foreach(IConstraint constraint in data.Constraints) { 111 if(constraint is IsIntegerConstraint) { 112 return true; 113 } 114 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 115 foreach (IConstraint constraint in data.Constraints) { 116 if (constraint is IsIntegerConstraint) { 117 return true; 114 118 } 115 return false;116 119 } 120 return false; 117 121 } 118 122 } -
trunk/sources/HeuristicLab.Random/UniformRandomAdder.cs
r719 r763 33 33 34 34 public override string Description { 35 get { return @"Samples a uniformly distributed random variable 'U' with range = [min,max] and E(u) = (max-min)/2 35 get { 36 return @"Samples a uniformly distributed random variable 'U' with range = [min,max] and E(u) = (max-min)/2 36 37 and adds the result to the variable 'Value'. ShakingFactor influences the effective range of U. 37 38 If r=(max-min) then the effective range of U is [E(u) - shakingFactor * r/2, E(u) + shakingFactor * r/2]. 38 39 39 40 If a constraint for the allowed range of 'Value' is defined and the result of the operation would be smaller then 40 the smallest allowed value then 'Value' is set to the lower bound and vice versa for the upper bound."; } 41 the smallest allowed value then 'Value' is set to the lower bound and vice versa for the upper bound."; 42 } 41 43 } 42 44 … … 66 68 max = ex + newRange / 2; 67 69 68 value.Accept(new RandomAdderVisitor(mt, min, max)); 69 70 AddUniform(value, mt, min, max); 70 71 return null; 71 72 } 72 73 74 private void AddUniform(IObjectData value, MersenneTwister mt, double min, double max) { 75 // dispatch manually on dynamic type 76 if (value is IntData) 77 AddUniform((IntData)value, mt, min, max); 78 else if (value is ConstrainedIntData) 79 AddUniform((ConstrainedIntData)value, mt, min, max); 80 else if (value is DoubleData) 81 AddUniform((DoubleData)value, mt, min, max); 82 else if (value is ConstrainedDoubleData) 83 AddUniform((ConstrainedDoubleData)value, mt, min, max); 84 else throw new InvalidOperationException("Can't handle type " + value.GetType().Name); 85 } 73 86 74 private class RandomAdderVisitor : ObjectDataVisitorBase {75 private double min;76 private double max;77 private MersenneTwister mt;78 87 79 public RandomAdderVisitor(MersenneTwister mt, double min, double max) { 80 this.mt = mt; 81 this.min = min; 82 this.max = max; 88 public void AddUniform(ConstrainedDoubleData data, MersenneTwister mt, double min, double max) { 89 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 90 double newValue = data.Data + mt.NextDouble() * (max - min) + min; 91 if (IsIntegerConstrained(data)) { 92 newValue = Math.Floor(newValue); 93 } 94 if (data.TrySetData(newValue)) { 95 return; 96 } 83 97 } 98 throw new InvalidProgramException("Couldn't find a valid value"); 99 } 84 100 85 public override void Visit(ConstrainedDoubleData data) { 86 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 87 double newValue = data.Data + mt.NextDouble() * (max - min) + min; 88 if(IsIntegerConstrained(data)) { 89 newValue = Math.Floor(newValue); 90 } 91 if(data.TrySetData(newValue)) { 92 return; 93 } 101 public void AddUniform(ConstrainedIntData data, MersenneTwister mt, double min, double max) { 102 for (int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 103 int newValue = (int)Math.Floor(data.Data + mt.NextDouble() * (max - min) + min); 104 if (data.TrySetData(newValue)) { 105 return; 94 106 } 95 throw new InvalidProgramException("Couldn't find a valid value");96 107 } 108 throw new InvalidProgramException("Couldn't find a valid value"); 109 } 97 110 98 public override void Visit(ConstrainedIntData data) { 99 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 100 int newValue = (int)Math.Floor(data.Data + mt.NextDouble() * (max - min) + min); 101 if(data.TrySetData(newValue)) { 102 return; 103 } 111 public void AddUniform(DoubleData data, MersenneTwister mt, double min, double max) { 112 data.Data = data.Data + mt.NextDouble() * (max - min) + min; 113 } 114 115 public void AddUniform(IntData data, MersenneTwister mt, double min, double max) { 116 data.Data = (int)Math.Floor(data.Data + mt.NextDouble() * (max - min) + min); 117 } 118 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 119 foreach (IConstraint constraint in data.Constraints) { 120 if (constraint is IsIntegerConstraint) { 121 return true; 104 122 } 105 throw new InvalidProgramException("Couldn't find a valid value");106 123 } 107 108 public override void Visit(DoubleData data) { 109 data.Data = data.Data + mt.NextDouble() * (max - min) + min; 110 } 111 112 public override void Visit(IntData data) { 113 data.Data = (int)Math.Floor(data.Data + mt.NextDouble() * (max - min) + min); 114 } 115 private bool IsIntegerConstrained(ConstrainedDoubleData data) { 116 foreach(IConstraint constraint in data.Constraints) { 117 if(constraint is IsIntegerConstraint) { 118 return true; 119 } 120 } 121 return false; 122 } 124 return false; 123 125 } 124 126 } -
trunk/sources/HeuristicLab.Random/UniformRandomizer.cs
r719 r763 61 61 double max = GetVariableValue<DoubleData>("Max", scope, true).Data; 62 62 63 value.Accept(new RandomVisitor(mt, min, max)); 64 63 RandomizeUniform(value, mt, min, max); 65 64 return null; 66 65 } 67 66 68 private class RandomVisitor : ObjectDataVisitorBase { 69 private MersenneTwister mt; 70 private double min; 71 private double max; 67 private void RandomizeUniform(IObjectData value, MersenneTwister mt, double min, double max) { 68 // Dispatch manually based on dynamic type, 69 // a bit awkward but necessary until we create a better type hierarchy for numeric types (gkronber 15.11.2008). 70 if (value is DoubleData) 71 RandomizeUniform((DoubleData)value, mt, min, max); 72 else if (value is ConstrainedDoubleData) 73 RandomizeUniform((ConstrainedDoubleData)value, mt, min, max); 74 else if (value is IntData) 75 RandomizeUniform((IntData)value, mt, min, max); 76 else if (value is ConstrainedIntData) 77 RandomizeUniform((ConstrainedIntData)value, mt, min, max); 78 else throw new ArgumentException("Can't handle type " + value.GetType().Name); 79 } 72 80 73 public RandomVisitor(MersenneTwister mt, double min, double max) {74 this.mt = mt;75 this.min = min;76 this.max = max;77 }78 81 79 public override void Visit(DoubleData data) {82 public void RandomizeUniform(DoubleData data, MersenneTwister mt, double min, double max) { 80 83 data.Data = mt.NextDouble() * (max - min) + min; 81 84 } 82 85 83 public override void Visit(IntData data) {86 public void RandomizeUniform(IntData data, MersenneTwister mt, double min, double max) { 84 87 data.Data = (int)Math.Floor(mt.NextDouble() * (max - min) + min); 85 88 } 86 89 87 public override void Visit(ConstrainedDoubleData data) {90 public void RandomizeUniform(ConstrainedDoubleData data, MersenneTwister mt, double min, double max) { 88 91 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 89 92 double r = mt.NextDouble() * (max - min) + min; … … 95 98 } 96 99 } 97 throw new Invalid ProgramException("Couldn't find a valid value");100 throw new InvalidOperationException("Couldn't find a valid value"); 98 101 } 99 102 100 public override void Visit(ConstrainedIntData data) {103 public void RandomizeUniform(ConstrainedIntData data, MersenneTwister mt, double min, double max) { 101 104 for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) { 102 105 int r = (int)Math.Floor(mt.NextDouble() * (max - min) + min); … … 105 108 } 106 109 } 107 throw new Invalid ProgramException("Couldn't find a valid value");110 throw new InvalidOperationException("Couldn't find a valid value"); 108 111 } 109 112 … … 117 120 } 118 121 } 119 }120 122 }
Note: See TracChangeset
for help on using the changeset viewer.