Changeset 12573 for branches/FitnessLandscapeAnalysis
- Timestamp:
- 07/02/15 12:50:44 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs
r12569 r12573 48 48 get { return (IValueParameter<BoolMatrix>)Parameters["GeneInteractions"]; } 49 49 } 50 public IValueParameter<IntValue> SeedParameter { 51 get { return (IValueParameter<IntValue>)Parameters["Seed"]; } 52 } 50 53 public IValueParameter<IntValue> InteractionSeedParameter { 51 54 get { return (IValueParameter<IntValue>)Parameters["InteractionSeed"]; } … … 90 93 get { return WeightsInitializerParameter.Value; } 91 94 } 92 #endregion 93 94 [ThreadStatic] 95 private static MersenneTwister random; 96 public static MersenneTwister Random { 97 get { 98 if (random == null) { 99 random = new MersenneTwister(); 100 } 101 return random; 102 } 103 } 95 public IntValue Seed { 96 get { return SeedParameter.Value; } 97 } 98 #endregion 99 100 [Storable] 101 private MersenneTwister random; 104 102 105 103 [ThreadStatic] … … 119 117 private NKLandscape(NKLandscape original, Cloner cloner) 120 118 : base(original, cloner) { 119 random = (MersenneTwister)original.random.Clone(cloner); 121 120 RegisterEventHandlers(); 122 121 } 123 122 public NKLandscape() 124 123 : base() { 124 random = new MersenneTwister(); 125 125 126 Parameters.Add(new ValueParameter<BoolMatrix>("GeneInteractions", "Every column gives the participating genes for each fitness component")); 126 Parameters.Add(new ValueParameter<IntValue>("InteractionSeed", "The seed used for the hash function to generate interaction tables.", new IntValue(Random.Next()))); 127 Parameters.Add(new ValueParameter<IntValue>("Seed", "The seed used for the random number generator.", new IntValue(0))); 128 random.Reset(Seed.Value); 129 130 Parameters.Add(new ValueParameter<IntValue>("InteractionSeed", "The seed used for the hash function to generate interaction tables.", new IntValue(random.Next()))); 127 131 Parameters.Add(new ValueParameter<IntValue>("NrOfFitnessComponents", "Number of fitness component functions. (nr of columns in the interaction column)", new IntValue(10))); 128 132 Parameters.Add(new ValueParameter<IntValue>("NrOfInteractions", "Number of genes interacting with each other. (nr of True values per column in the interaction matrix)", new IntValue(3))); … … 175 179 InteractionInitializerParameter.ValueChanged += InteractionInitializerParameter_ValueChanged; 176 180 WeightsInitializerParameter.ValueChanged += WeightsInitializerParameter_ValueChanged; 181 SeedParameter.ValueChanged += SeedParameter_ValueChanged; 182 SeedParameter.Value.ValueChanged += SeedParameter_ValueChanged; 183 } 184 185 private void SeedParameter_ValueChanged(object sender, EventArgs e) { 186 random.Reset(Seed.Value); 187 InteractionSeed.Value = random.Next(); 188 InitializeInteractions(); 177 189 } 178 190 … … 200 212 Length, 201 213 NrOfFitnessComponents.Value, 202 NrOfInteractions.Value, Random);214 NrOfInteractions.Value, random); 203 215 } 204 216
Note: See TracChangeset
for help on using the changeset viewer.