Changeset 12592 for branches/FitnessLandscapeAnalysis
- Timestamp:
- 07/06/15 10:07:15 (9 years ago)
- Location:
- branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IInteractionInitializer.cs
r12582 r12592 24 24 25 25 namespace HeuristicLab.Problems.NK { 26 public interface IInteractionInitializer : I Item {26 public interface IInteractionInitializer : IParameterizedItem { 27 27 BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random); 28 28 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IncreasingBlockSizeInteractionsInitializer.cs
r12582 r12592 31 31 [Item("IncreasingBlockSizeInteractionsInitializer", "Randomly assignes interactions across all bits but makes sure that different numbers of ineractions are applied to different bits.")] 32 32 [StorableClass] 33 public sealed class IncreasingBlockSizeInteractionsInitializer : Item, IInteractionInitializer {33 public sealed class IncreasingBlockSizeInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer { 34 34 [StorableConstructor] 35 35 private IncreasingBlockSizeInteractionsInitializer(bool serializing) : base(serializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/RandomInteractionsInitializer.cs
r12582 r12592 29 29 [Item("RandomInteractionsInitializer", "Randomly assignes interactions across all bits")] 30 30 [StorableClass] 31 public sealed class RandomInteractionsInitializer : Item, IInteractionInitializer {31 public sealed class RandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer { 32 32 [StorableConstructor] 33 33 private RandomInteractionsInitializer(bool serializing) : base(serializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs
r12582 r12592 34 34 35 35 namespace HeuristicLab.Problems.NK { 36 37 36 [Item("NK Landscape", "Represents an NK landscape optimization problem.")] 38 37 [Creatable("Problems")] … … 156 155 Parameters.Add(new OptionalConstrainedValueParameter<IWeightsInitializer>("WeightsInitializer", "Operator to initialize weights distribution")); 157 156 157 //allow just the standard NK[P,Q] formulations at the moment 158 WeightsParameter.Hidden = true; 159 InteractionInitializerParameter.Hidden = true; 160 WeightsInitializerParameter.Hidden = true; 161 EncodingParameter.Hidden = true; 162 158 163 InitializeInteractionInitializerParameter(); 159 164 InitializeWeightsInitializerParameter(); 160 165 161 166 InitializeOperators(); 167 InitializeInteractions(); 162 168 RegisterEventHandlers(); 163 InitializeInteractions();164 169 } 165 170 … … 180 185 } 181 186 182 #region Events183 protected override void LengthParameter_ValueChanged(object sender, EventArgs e) {184 BestKnownQualityParameter.Value = new DoubleValue(Length);185 NrOfFitnessComponentsParameter.Value = new IntValue(Length);186 }187 #endregion188 189 #region Helpers190 187 [StorableHook(HookType.AfterDeserialization)] 191 188 private void AfterDeserialization() { … … 194 191 195 192 private void RegisterEventHandlers() { 196 NrOfInteractionsParameter.ValueChanged += InteractionParameter Changed;197 NrOfInteractionsParameter.Value.ValueChanged += InteractionParameter Changed;198 NrOfFitnessComponentsParameter.ValueChanged += InteractionParameter Changed;199 NrOfFitnessComponentsParameter.Value.ValueChanged += InteractionParameter Changed;200 InteractionInitializerParameter.ValueChanged += Interaction InitializerParameter_ValueChanged;193 NrOfInteractionsParameter.ValueChanged += InteractionParameter_ValueChanged; 194 NrOfInteractionsParameter.Value.ValueChanged += InteractionParameter_ValueChanged; 195 NrOfFitnessComponentsParameter.ValueChanged += InteractionParameter_ValueChanged; 196 NrOfFitnessComponentsParameter.Value.ValueChanged += InteractionParameter_ValueChanged; 197 InteractionInitializerParameter.ValueChanged += InteractionParameter_ValueChanged; 201 198 WeightsInitializerParameter.ValueChanged += WeightsInitializerParameter_ValueChanged; 202 199 SeedParameter.ValueChanged += SeedParameter_ValueChanged; 203 200 SeedParameter.Value.ValueChanged += SeedParameter_ValueChanged; 201 202 RegisterInteractionInitializerParameterEvents(); 203 RegisterWeightsParameterEvents(); 204 } 205 206 private void RegisterWeightsParameterEvents() { 207 foreach (var vv in WeightsInitializerParameter.ValidValues) { 208 foreach (var p in vv.Parameters) { 209 if (p.ActualValue != null && p.ActualValue is IStringConvertibleValue) { 210 var v = (IStringConvertibleValue)p.ActualValue; 211 v.ValueChanged += WeightsInitializerParameter_ValueChanged; 212 } 213 } 214 } 215 } 216 217 private void RegisterInteractionInitializerParameterEvents() { 218 foreach (var vv in InteractionInitializerParameter.ValidValues) { 219 foreach (var p in vv.Parameters) { 220 if (p.ActualValue != null && p.ActualValue is IStringConvertibleValue) { 221 var v = (IStringConvertibleValue)p.ActualValue; 222 v.ValueChanged += InteractionParameter_ValueChanged; 223 } else if (p.ActualValue != null && p is IConstrainedValueParameter<IBinaryVectorComparer>) { 224 ((IConstrainedValueParameter<IBinaryVectorComparer>)p).ValueChanged += 225 InteractionParameter_ValueChanged; 226 } 227 } 228 } 229 } 230 231 protected override void LengthParameter_ValueChanged(object sender, EventArgs e) { 232 NrOfFitnessComponentsParameter.Value = new IntValue(Length); 204 233 } 205 234 … … 214 243 } 215 244 216 private void InteractionInitializerParameter_ValueChanged(object sender, EventArgs e) { 217 InitializeInteractions(); 218 } 219 220 private void InteractionParameterChanged(object sender, EventArgs e) { 245 private void InteractionParameter_ValueChanged(object sender, EventArgs e) { 221 246 InitializeInteractions(); 222 247 } … … 242 267 .ToArray()); 243 268 } 244 #endregion245 269 246 270 #region Evaluation function -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/EqualWeightsInitializer.cs
r12582 r12592 28 28 [Item("EqualWeightsInitializer", "Initializes all weights to 1.0.")] 29 29 [StorableClass] 30 public sealed class EqualWeightsInitializer : Item, IWeightsInitializer {30 public sealed class EqualWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 31 31 [StorableConstructor] 32 32 private EqualWeightsInitializer(bool deserializing) : base(deserializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialWeightsInitializer.cs
r12582 r12592 29 29 [Item("ExponentialWeightsInitializer", "Assigns exponentially increasing weights.")] 30 30 [StorableClass] 31 public sealed class ExponentialWeightsInitializer : Item, IWeightsInitializer {31 public sealed class ExponentialWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 32 32 [StorableConstructor] 33 33 private ExponentialWeightsInitializer(bool deserializing) : base(deserializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/IWeightsInitializer.cs
r12582 r12592 24 24 25 25 namespace HeuristicLab.Problems.NK { 26 public interface IWeightsInitializer : I Item {26 public interface IWeightsInitializer : IParameterizedItem { 27 27 IEnumerable<double> GetWeights(int nComponents); 28 28 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/LinearWeightsInitializer.cs
r12582 r12592 28 28 [Item("LinearWeightsInitializer", "Assigns linear increasing weights.")] 29 29 [StorableClass] 30 public sealed class LinearWeightsInitializer : Item, IWeightsInitializer {30 public sealed class LinearWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 31 31 [StorableConstructor] 32 32 private LinearWeightsInitializer(bool deserializing) : base(deserializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseExponentialWeightsInitializer.cs
r12582 r12592 29 29 [Item("ReverseExponentialWeightsInitializer", "Assigns exponentially decreasing weights.")] 30 30 [StorableClass] 31 public sealed class ReverseExponentialWeightsInitializer : Item, IWeightsInitializer {31 public sealed class ReverseExponentialWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 32 32 [StorableConstructor] 33 33 private ReverseExponentialWeightsInitializer(bool deserializing) : base(deserializing) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseLinearWeightsInitializer.cs
r12582 r12592 28 28 [Item("ReverseLinearWeightsInitializer", "Assigns exponentially decreasing weights.")] 29 29 [StorableClass] 30 public sealed class ReverseLinearWeightsInitializer : Item, IWeightsInitializer {30 public sealed class ReverseLinearWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 31 31 [StorableConstructor] 32 32 private ReverseLinearWeightsInitializer(bool deserializing) : base(deserializing) { }
Note: See TracChangeset
for help on using the changeset viewer.