Changeset 9265
- Timestamp:
- 03/01/13 13:55:09 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs
r9258 r9265 480 480 get { return secondYAxisMaximumFixedValue; } 481 481 set { secondYAxisMaximumFixedValue = value; } 482 } 483 [Storable(Name = "XAxisLogScale")] 484 private bool StorableXAxisLogScale { 485 get { return xAxisLogScale; } 486 set { xAxisLogScale = value; } 487 } 488 [Storable(Name = "SecondXAxisLogScale")] 489 private bool StorableSecondXAxisLogScale { 490 get { return secondXAxisLogScale; } 491 set { secondXAxisLogScale = value; } 492 } 493 [Storable(Name = "YAxisLogScale")] 494 private bool StorableYAxisLogScale { 495 get { return yAxisLogScale; } 496 set { yAxisLogScale = value; } 497 } 498 [Storable(Name = "SecondYAxisLogScale")] 499 private bool StorableSecondYAxisLogScale { 500 get { return secondYAxisLogScale; } 501 set { secondYAxisLogScale = value; } 482 502 } 483 503 #endregion -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/NormalDistributedRealVectorCreator.cs
r9258 r9265 45 45 } 46 46 47 public IValueParameter<IntValue> MaximumTriesParameter { 48 get { return (IValueParameter<IntValue>)Parameters["MaximumTries"]; } 49 } 50 47 51 [StorableConstructor] 48 52 protected NormalDistributedRealVectorCreator(bool deserializing) : base(deserializing) { } … … 52 56 Parameters.Add(new ValueLookupParameter<RealVector>("Mean", "The mean vector around which the points will be sampled.")); 53 57 Parameters.Add(new ValueLookupParameter<DoubleArray>("Sigma", "The standard deviations for all or for each dimension.")); 58 Parameters.Add(new ValueParameter<IntValue>("MaximumTries", "The maximum number of tries to sample within the specified bounds.", new IntValue(1000))); 54 59 } 55 60 56 61 public override IDeepCloneable Clone(Cloner cloner) { 57 62 return new NormalDistributedRealVectorCreator(this, cloner); 63 } 64 65 [StorableHook(HookType.AfterDeserialization)] 66 private void AfterDeserialization() { 67 if (!Parameters.ContainsKey("MaximumTries")) 68 Parameters.Add(new ValueParameter<IntValue>("MaximumTries", "The maximum number of tries to sample within the specified bounds.", new IntValue(1000))); 58 69 } 59 70 … … 80 91 /// <param name="sigma">The vector of standard deviations, must have at least one row.</param> 81 92 /// <param name="bounds">The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.</param> 93 /// <param name="maximumTries">The maximum number of tries to sample a value inside the bounds for each dimension. If a valid value cannot be obtained, the mean will be used.</param> 82 94 /// <returns>The newly created real vector.</returns> 83 public static RealVector Apply(IRandom random, RealVector mean, DoubleArray sigma, DoubleMatrix bounds ) {84 if (random == null) throw new Argument Exception("Random is not defined", "random");85 if (mean == null || mean.Length == 0) throw new Argument Exception("Mean is not defined", "mean");86 if (sigma == null || sigma.Length == 0) throw new Argument Exception("Sigma is not defined.", "sigma");95 public static RealVector Apply(IRandom random, RealVector mean, DoubleArray sigma, DoubleMatrix bounds, int maximumTries = 1000) { 96 if (random == null) throw new ArgumentNullException("Random is not defined", "random"); 97 if (mean == null || mean.Length == 0) throw new ArgumentNullException("Mean is not defined", "mean"); 98 if (sigma == null || sigma.Length == 0) throw new ArgumentNullException("Sigma is not defined.", "sigma"); 87 99 if (bounds == null || bounds.Rows == 0) bounds = new DoubleMatrix(new[,] { { double.MinValue, double.MaxValue } }); 88 100 var nd = new NormalDistributedRandom(random, 0, 1); … … 94 106 else if (mean[i] > max) result[i] = max; 95 107 else { 108 int count = 0; 109 bool inRange; 96 110 do { 97 111 result[i] = mean[i] + sigma[i % sigma.Length] * nd.NextDouble(); 98 } while (result[i] < bounds[i % sigma.Length, 0] || result[i] > bounds[i % sigma.Length, 1]); 112 inRange = result[i] >= bounds[i % sigma.Length, 0] && result[i] < bounds[i % sigma.Length, 1]; 113 count++; 114 } while (count < maximumTries && !inRange); 115 if (count == maximumTries && !inRange) 116 result[i] = mean[i]; 99 117 } 100 118 } … … 110 128 /// <returns>The newly created real vector.</returns> 111 129 protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) { 112 return Apply(random, MeanParameter.ActualValue, SigmaParameter.ActualValue, bounds );130 return Apply(random, MeanParameter.ActualValue, SigmaParameter.ActualValue, bounds, MaximumTriesParameter.Value.Value); 113 131 } 114 132 }
Note: See TracChangeset
for help on using the changeset viewer.