Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12592 for branches


Ignore:
Timestamp:
07/06/15 10:07:15 (9 years ago)
Author:
ascheibe
Message:

#2306

  • hide weight and interaction initializer parameters
  • hide encoding parameter
  • removed setting of BestKnownQuality
  • added wiring code for interaction and weight initializers that have parameters
  • made all interaction/weight initializers ParameterizedNamedItem
Location:
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IInteractionInitializer.cs

    r12582 r12592  
    2424
    2525namespace HeuristicLab.Problems.NK {
    26   public interface IInteractionInitializer : IItem {
     26  public interface IInteractionInitializer : IParameterizedItem {
    2727    BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random);
    2828  }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IncreasingBlockSizeInteractionsInitializer.cs

    r12582 r12592  
    3131  [Item("IncreasingBlockSizeInteractionsInitializer", "Randomly assignes interactions across all bits but makes sure that different numbers of ineractions are applied to different bits.")]
    3232  [StorableClass]
    33   public sealed class IncreasingBlockSizeInteractionsInitializer : Item, IInteractionInitializer {
     33  public sealed class IncreasingBlockSizeInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    3434    [StorableConstructor]
    3535    private IncreasingBlockSizeInteractionsInitializer(bool serializing) : base(serializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/RandomInteractionsInitializer.cs

    r12582 r12592  
    2929  [Item("RandomInteractionsInitializer", "Randomly assignes interactions across all bits")]
    3030  [StorableClass]
    31   public sealed class RandomInteractionsInitializer : Item, IInteractionInitializer {
     31  public sealed class RandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    3232    [StorableConstructor]
    3333    private RandomInteractionsInitializer(bool serializing) : base(serializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs

    r12582 r12592  
    3434
    3535namespace HeuristicLab.Problems.NK {
    36 
    3736  [Item("NK Landscape", "Represents an NK landscape optimization problem.")]
    3837  [Creatable("Problems")]
     
    156155      Parameters.Add(new OptionalConstrainedValueParameter<IWeightsInitializer>("WeightsInitializer", "Operator to initialize weights distribution"));
    157156
     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
    158163      InitializeInteractionInitializerParameter();
    159164      InitializeWeightsInitializerParameter();
    160165
    161166      InitializeOperators();
     167      InitializeInteractions();
    162168      RegisterEventHandlers();
    163       InitializeInteractions();
    164169    }
    165170
     
    180185    }
    181186
    182     #region Events
    183     protected override void LengthParameter_ValueChanged(object sender, EventArgs e) {
    184       BestKnownQualityParameter.Value = new DoubleValue(Length);
    185       NrOfFitnessComponentsParameter.Value = new IntValue(Length);
    186     }
    187     #endregion
    188 
    189     #region Helpers
    190187    [StorableHook(HookType.AfterDeserialization)]
    191188    private void AfterDeserialization() {
     
    194191
    195192    private void RegisterEventHandlers() {
    196       NrOfInteractionsParameter.ValueChanged += InteractionParameterChanged;
    197       NrOfInteractionsParameter.Value.ValueChanged += InteractionParameterChanged;
    198       NrOfFitnessComponentsParameter.ValueChanged += InteractionParameterChanged;
    199       NrOfFitnessComponentsParameter.Value.ValueChanged += InteractionParameterChanged;
    200       InteractionInitializerParameter.ValueChanged += InteractionInitializerParameter_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;
    201198      WeightsInitializerParameter.ValueChanged += WeightsInitializerParameter_ValueChanged;
    202199      SeedParameter.ValueChanged += SeedParameter_ValueChanged;
    203200      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);
    204233    }
    205234
     
    214243    }
    215244
    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) {
    221246      InitializeInteractions();
    222247    }
     
    242267          .ToArray());
    243268    }
    244     #endregion
    245269
    246270    #region Evaluation function
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/EqualWeightsInitializer.cs

    r12582 r12592  
    2828  [Item("EqualWeightsInitializer", "Initializes all weights to 1.0.")]
    2929  [StorableClass]
    30   public sealed class EqualWeightsInitializer : Item, IWeightsInitializer {
     30  public sealed class EqualWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3131    [StorableConstructor]
    3232    private EqualWeightsInitializer(bool deserializing) : base(deserializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialWeightsInitializer.cs

    r12582 r12592  
    2929  [Item("ExponentialWeightsInitializer", "Assigns exponentially increasing weights.")]
    3030  [StorableClass]
    31   public sealed class ExponentialWeightsInitializer : Item, IWeightsInitializer {
     31  public sealed class ExponentialWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3232    [StorableConstructor]
    3333    private ExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/IWeightsInitializer.cs

    r12582 r12592  
    2424
    2525namespace HeuristicLab.Problems.NK {
    26   public interface IWeightsInitializer : IItem {
     26  public interface IWeightsInitializer : IParameterizedItem {
    2727    IEnumerable<double> GetWeights(int nComponents);
    2828  }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/LinearWeightsInitializer.cs

    r12582 r12592  
    2828  [Item("LinearWeightsInitializer", "Assigns linear increasing weights.")]
    2929  [StorableClass]
    30   public sealed class LinearWeightsInitializer : Item, IWeightsInitializer {
     30  public sealed class LinearWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3131    [StorableConstructor]
    3232    private LinearWeightsInitializer(bool deserializing) : base(deserializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseExponentialWeightsInitializer.cs

    r12582 r12592  
    2929  [Item("ReverseExponentialWeightsInitializer", "Assigns exponentially decreasing weights.")]
    3030  [StorableClass]
    31   public sealed class ReverseExponentialWeightsInitializer : Item, IWeightsInitializer {
     31  public sealed class ReverseExponentialWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3232    [StorableConstructor]
    3333    private ReverseExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseLinearWeightsInitializer.cs

    r12582 r12592  
    2828  [Item("ReverseLinearWeightsInitializer", "Assigns exponentially decreasing weights.")]
    2929  [StorableClass]
    30   public sealed class ReverseLinearWeightsInitializer : Item, IWeightsInitializer {
     30  public sealed class ReverseLinearWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3131    [StorableConstructor]
    3232    private ReverseLinearWeightsInitializer(bool deserializing) : base(deserializing) { }
Note: See TracChangeset for help on using the changeset viewer.