Changeset 4675
- Timestamp:
- 10/29/10 18:58:23 (14 years ago)
- Location:
- branches/CloningRefactoring
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Random/3.3/FastRandom.cs
r4258 r4675 54 54 55 55 #region Constructors 56 /// <summary> 57 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization. 58 /// </summary> 59 /// <param name="deserializing">true, if the constructor is called during deserialization.</param> 60 [StorableConstructor] 61 private FastRandom(bool deserializing) : base(deserializing) { } 62 63 /// <summary> 64 /// Initializes a new instance from an existing one (copy constructor). 65 /// </summary> 66 /// <param name="original">The original <see cref="FastRandom"/> instance which is used to initialize the new instance.</param> 67 /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param> 68 private FastRandom(FastRandom original, Cloner cloner) 69 : base(original, cloner) { 70 x = original.x; 71 y = original.y; 72 z = original.z; 73 w = original.w; 74 bitBuffer = original.bitBuffer; 75 bitMask = original.bitMask; 76 } 56 77 57 78 /// <summary> … … 71 92 Reinitialise(seed); 72 93 } 73 74 /// <summary>75 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.76 /// </summary>77 /// <param name="deserializing">true, if the constructor is called during deserialization.</param>78 [StorableConstructor]79 private FastRandom(bool deserializing) : base(deserializing) { }80 81 94 #endregion 82 95 … … 351 364 352 365 public override IDeepCloneable Clone(Cloner cloner) { 353 FastRandom clone = (FastRandom)base.Clone(cloner); 354 clone.x = x; 355 clone.y = y; 356 clone.z = z; 357 clone.w = w; 358 clone.bitBuffer = bitBuffer; 359 clone.bitMask = bitMask; 360 return clone; 366 return new FastRandom(this, cloner); 361 367 } 362 368 } -
branches/CloningRefactoring/HeuristicLab.Random/3.3/MersenneTwister.cs
r4477 r4675 55 55 56 56 /// <summary> 57 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization. 58 /// </summary> 59 /// <param name="deserializing">true, if the constructor is called during deserialization.</param> 60 [StorableConstructor] 61 private MersenneTwister(bool deserializing) : base(deserializing) { } 62 /// <summary> 63 /// Initializes a new instance from an existing one (copy constructor). 64 /// </summary> 65 /// <param name="original">The original <see cref="MersenneTwister"/> instance which is used to initialize the new instance.</param> 66 /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param> 67 private MersenneTwister(MersenneTwister original, Cloner cloner) 68 : base(original, cloner) { 69 state = (uint[])original.state.Clone(); 70 p = original.p; 71 init = original.init; 72 } 73 /// <summary> 57 74 /// Initializes a new instance of <see cref="MersenneTwister"/>. 58 75 /// </summary> … … 78 95 init = true; 79 96 } 80 /// <summary>81 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.82 /// </summary>83 /// <param name="deserializing">true, if the constructor is called during deserialization.</param>84 [StorableConstructor]85 private MersenneTwister(bool deserializing) : base(deserializing) { }86 97 87 98 /// <summary> … … 91 102 /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns> 92 103 public override IDeepCloneable Clone(Cloner cloner) { 93 MersenneTwister clone = (MersenneTwister)base.Clone(cloner); 94 clone.state = (uint[])state.Clone(); 95 clone.p = p; 96 clone.init = init; 97 return clone; 104 return new MersenneTwister(this, cloner); 98 105 } 99 106 -
branches/CloningRefactoring/HeuristicLab.Random/3.3/NormalDistributedRandom.cs
r4477 r4675 450 450 451 451 /// <summary> 452 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization. 453 /// </summary> 454 /// <param name="deserializing">true, if the constructor is called during deserialization.</param> 455 [StorableConstructor] 456 private NormalDistributedRandom(bool deserializing) : base(deserializing) { } 457 458 /// <summary> 459 /// Initializes a new instance from an existing one (copy constructor). 460 /// </summary> 461 /// <param name="original">The original <see cref="NormalDistributedRandom"/> instance which is used to initialize the new instance.</param> 462 /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param> 463 private NormalDistributedRandom(NormalDistributedRandom original, Cloner cloner) 464 : base(original, cloner) { 465 uniform = cloner.Clone(original.uniform); 466 mu = original.mu; 467 sigma = original.sigma; 468 } 469 470 /// <summary> 452 471 /// Initializes a new instance of <see cref="NormalDistributedRandom"/> with µ = 0 and sigma = 1 453 472 /// and a new random number generator. … … 471 490 this.uniform = uniformRandom; 472 491 } 473 /// <summary>474 /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.475 /// </summary>476 /// <param name="deserializing">true, if the constructor is called during deserialization.</param>477 [StorableConstructor]478 private NormalDistributedRandom(bool deserializing) : base(deserializing) { }479 492 480 493 #region IRandom Members … … 529 542 /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns> 530 543 public override IDeepCloneable Clone(Cloner cloner) { 531 NormalDistributedRandom clone = (NormalDistributedRandom)base.Clone(cloner); 532 clone.uniform = (IRandom)cloner.Clone(uniform); 533 clone.mu = mu; 534 clone.sigma = sigma; 535 return clone; 544 return new NormalDistributedRandom(this, cloner); 536 545 } 537 546 -
branches/CloningRefactoring/HeuristicLab.Random/3.3/NormalRandomizer.cs
r4477 r4675 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 33 34 [Item("NormalRandomizer", "Initializes the value of variable 'Value' to a random value normally distributed with parameters 'Mu' and 'Sigma'")] 34 35 public class NormalRandomizer : SingleSuccessorOperator { 35 #region parameter properties36 #region Parameter Properties 36 37 public ILookupParameter<IRandom> RandomParameter { 37 38 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 47 48 } 48 49 #endregion 50 49 51 #region Properties 50 52 public DoubleValue Mu { … … 57 59 } 58 60 #endregion 61 62 [StorableConstructor] 63 protected NormalRandomizer(bool deserializing) : base(deserializing) { } 64 protected NormalRandomizer(NormalRandomizer original, Cloner cloner) : base(original, cloner) { } 59 65 /// <summary> 60 66 /// Initializes a new instance of <see cref="NormalRandomizer"/> with four variable infos … … 67 73 Parameters.Add(new LookupParameter<DoubleValue>("Value", "The value that should be set to a random value.")); 68 74 } 69 [StorableConstructor] 70 protected NormalRandomizer(bool deserializing) : base(deserializing) { } 75 76 public override IDeepCloneable Clone(Cloner cloner) { 77 return new NormalRandomizer(this, cloner); 78 } 71 79 72 80 /// <summary> -
branches/CloningRefactoring/HeuristicLab.Random/3.3/RandomCreator.cs
r4258 r4675 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 33 34 [StorableClass] 34 35 public sealed class RandomCreator : SingleSuccessorOperator { 36 #region Parameter Properties 35 37 public ValueLookupParameter<BoolValue> SetSeedRandomlyParameter { 36 38 get { return (ValueLookupParameter<BoolValue>)Parameters["SetSeedRandomly"]; } … … 45 47 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 46 48 } 49 #endregion 50 51 #region Properties 47 52 public BoolValue SetSeedRandomly { 48 53 get { return SetSeedRandomlyParameter.Value; } … … 57 62 set { RandomTypeParameter.Value = value; } 58 63 } 64 #endregion 59 65 66 [StorableConstructor] 67 private RandomCreator(bool deserializing) : base(deserializing) { } 68 private RandomCreator(RandomCreator original, Cloner cloner) : base(original, cloner) { } 60 69 public RandomCreator() 61 70 : base() { … … 65 74 Parameters.Add(new LookupParameter<IRandom>("Random", "The new pseudo random number generator which is initialized with the given seed.")); 66 75 } 67 [StorableConstructor]68 private RandomCreator(bool deserializing) : base(deserializing) { }69 76 70 77 // BackwardsCompatibility3.3 71 78 #region Backwards compatible code (remove with 3.4) 72 79 [StorableHook(HookType.AfterDeserialization)] 73 private void AfterDeserialization Hook() {80 private void AfterDeserialization() { 74 81 if (!Parameters.ContainsKey("RandomType")) 75 82 Parameters.Add(new ValueParameter<IRandom>("RandomType", "The type of pseudo random number generator which is created.", new MersenneTwister())); 76 83 } 77 84 #endregion 85 86 public override IDeepCloneable Clone(Cloner cloner) { 87 return new RandomCreator(this, cloner); 88 } 78 89 79 90 public override IOperation Apply() { -
branches/CloningRefactoring/HeuristicLab.Random/3.3/UniformRandomizer.cs
r4477 r4675 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 33 34 [Item("UniformRandomizer", "Initializes the value of variable 'Value' to a random value uniformly distributed between 'Min' and 'Max'")] 34 35 public class UniformRandomizer : SingleSuccessorOperator { 35 #region parameter properties36 #region Parameter Properties 36 37 public ILookupParameter<IRandom> RandomParameter { 37 38 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 47 48 } 48 49 #endregion 50 49 51 #region Properties 50 52 public DoubleValue Min { … … 58 60 #endregion 59 61 62 [StorableConstructor] 63 protected UniformRandomizer(bool deserializing) : base(deserializing) { } 64 protected UniformRandomizer(UniformRandomizer original, Cloner cloner) : base(original, cloner) { } 60 65 /// <summary> 61 66 /// Initializes a new instance of <see cref="UniformRandomizer"/> with four variable infos … … 70 75 Parameters.Add(new LookupParameter<DoubleValue>("Value", "The value that should be set to a random value.")); 71 76 } 72 [StorableConstructor] 73 protected UniformRandomizer(bool deserializing) : base(deserializing) { } 77 78 public override IDeepCloneable Clone(Cloner cloner) { 79 return new UniformRandomizer(this, cloner); 80 } 74 81 75 82 /// <summary> -
branches/CloningRefactoring/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs
r4477 r4675 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 34 public class SequentialEngine : Engine { 34 35 private IOperator currentOperator; 36 37 [StorableConstructor] 38 protected SequentialEngine(bool deserializing) : base(deserializing) { } 39 protected SequentialEngine(SequentialEngine original, Cloner cloner) : base(original, cloner) { } 40 public SequentialEngine() : base() { } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new SequentialEngine(this, cloner); 44 } 35 45 36 46 /// <summary>
Note: See TracChangeset
for help on using the changeset viewer.