Changeset 12569


Ignore:
Timestamp:
07/02/15 11:02:16 (4 years ago)
Author:
ascheibe
Message:

#2306 fixed typos and some cosmetic changes

Location:
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/BinaryVectorComparer.cs

    r12566 r12569  
    2727
    2828namespace HeuristicLab.Problems.NK {
    29 
    30   public interface IBinaryVectorComparer : INamedItem, IComparer<BinaryVector> { }
    31 
    3229  [StorableClass]
    3330  public abstract class BinaryVectorComparer : NamedItem, IBinaryVectorComparer {
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/HeuristicLab.Problems.NK.csproj

    r12566 r12569  
    158158  <ItemGroup>
    159159    <Compile Include="BinaryVectorComparers\BinaryVectorComparer.cs" />
     160    <Compile Include="BinaryVectorComparers\IBinaryVectorComparer.cs" />
    160161    <Compile Include="BinaryVectorComparers\LexicographicBinaryVectorComparer.cs" />
    161162    <Compile Include="BinaryVectorComparers\AverageBitBinaryVectorComparer.cs" />
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/LimitedRandomInteractionsInitializer.cs

    r12566 r12569  
    4141        Max = Math.Max(min, max);
    4242      }
    43       public int bounded(int n) {
     43      public int Bounded(int n) {
    4444        return Math.Max(Min, Math.Min(Max, n));
    4545      }
    4646    }
    4747
    48     public ValueParameter<IntValue> MaximumDistanceParameter {
    49       get { return (ValueParameter<IntValue>)Parameters["MaximumDistance"]; }
     48    public IValueParameter<IntValue> MaximumDistanceParameter {
     49      get { return (IValueParameter<IntValue>)Parameters["MaximumDistance"]; }
    5050    }
    51     public ValueParameter<DoubleValue> MaximumDistanceRatioParameter {
    52       get { return (ValueParameter<DoubleValue>)Parameters["MaximumDistanceRatio"]; }
     51    public IValueParameter<DoubleValue> MaximumDistanceRatioParameter {
     52      get { return (IValueParameter<DoubleValue>)Parameters["MaximumDistanceRatio"]; }
    5353    }
    5454
     
    5858      maxBitDist = Math.Min(
    5959        maxBitDist == 0 ? length : maxBitDist,
    60         maxDistRatio == 0 ? length : (int)Math.Round(maxDistRatio * length));
     60        maxDistRatio.IsAlmost(0.0) ? length : (int)Math.Round(maxDistRatio * length));
    6161      if (maxBitDist * 2 < nInteractions)
    6262        maxBitDist = (int)Math.Ceiling(0.5 * nInteractions);
     
    8383      var maxBounds = new Bounds(nInteractions, length - 1);
    8484      for (int c = 0; c < m.Columns; c++) {
    85         int min = minBounds.bounded(c - maxBitDistance);
    86         int max = maxBounds.bounded(c + maxBitDistance);
     85        int min = minBounds.Bounded(c - maxBitDistance);
     86        int max = maxBounds.Bounded(c + maxBitDistance);
    8787        var indices = Enumerable.Range(min, max - min).ToList();
    8888        indices.Remove(c);
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/SortedRandomInteractionsInitializer.cs

    r12566 r12569  
    3131namespace HeuristicLab.Problems.NK {
    3232
    33   [Item("SortedRandomInteractionsInitializer", "Randomly assigned interactions across all bits and sorts components according to bit affinity.")]
     33  [Item("SortedRandomInteractionsInitializer", "Randomly assigns interactions across all bits and sorts components according to bit affinity.")]
    3434  [StorableClass]
    3535  public class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    36 
    3736    public IConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter {
    3837      get { return (IConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; }
    3938    }
    40 
    4139    public IBinaryVectorComparer Comparer {
    4240      get { return ComparerParameter.Value; }
     
    4745    protected SortedRandomInteractionsInitializer(SortedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
    4846    public SortedRandomInteractionsInitializer() {
    49       AddComparerParameter();
     47      Parameters.Add(new ConstrainedValueParameter<IBinaryVectorComparer>("Comparer", "Comparison for sorting of component functions."));
     48      InitializeComparers();
    5049    }
    5150
    52     private void AddComparerParameter() {
    53       Parameters.Add(new ConstrainedValueParameter<IBinaryVectorComparer>("Comparer", "Comparison for sorting of component functions"));
     51    private void InitializeComparers() {
    5452      foreach (var comparer in ApplicationManager.Manager.GetInstances<IBinaryVectorComparer>())
    5553        ComparerParameter.ValidValues.Add(comparer);
     
    5957    public override IDeepCloneable Clone(Cloner cloner) {
    6058      return new SortedRandomInteractionsInitializer(this, cloner);
    61     }
    62 
    63     [StorableHook(HookType.AfterDeserialization)]
    64     private void AfterDeserialization() {
    65       try {
    66         IBinaryVectorComparer comparer = Comparer;
    67       }
    68       catch {
    69         Parameters.Remove("Comparer");
    70         AddComparerParameter();
    71       }
    7259    }
    7360
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKBitFlipMoveEvaluator.cs

    r12566 r12569  
    3333  [StorableClass]
    3434  public class NKBitFlipMoveEvaluator : NKMoveEvaluator, IOneBitflipMoveOperator {
    35 
    3635    public ILookupParameter<OneBitflipMove> OneBitflipMoveParameter {
    3736      get { return (ILookupParameter<OneBitflipMove>)Parameters["OneBitflipMove"]; }
    3837    }
    39     public LookupParameter<BinaryVector> MovedBinaryVectorParameter {
    40       get { return (LookupParameter<BinaryVector>)Parameters["MovedBinaryVector"]; }
     38    public ILookupParameter<BinaryVector> MovedBinaryVectorParameter {
     39      get { return (ILookupParameter<BinaryVector>)Parameters["MovedBinaryVector"]; }
    4140    }
    4241
    4342    [StorableConstructor]
    4443    protected NKBitFlipMoveEvaluator(bool deserializing) : base(deserializing) { }
    45 
    4644    protected NKBitFlipMoveEvaluator(NKBitFlipMoveEvaluator original, Cloner cloner)
    4745      : base(original, cloner) { }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs

    r12566 r12569  
    4545
    4646    #region Parameters
    47     public ValueParameter<BoolMatrix> GeneInteractionsParameter {
    48       get { return (ValueParameter<BoolMatrix>)Parameters["GeneInteractions"]; }
    49     }
    50     public ValueParameter<IntValue> InteractionSeedParameter {
    51       get { return (ValueParameter<IntValue>)Parameters["InteractionSeed"]; }
    52     }
    53     public ValueParameter<IntValue> NrOfInteractionsParameter {
    54       get { return (ValueParameter<IntValue>)Parameters["NrOfInteractions"]; }
    55     }
    56     public ValueParameter<IntValue> NrOfFitnessComponentsParameter {
    57       get { return (ValueParameter<IntValue>)Parameters["NrOfFitnessComponents"]; }
    58     }
    59     public ValueParameter<DoubleArray> WeightsParameter {
    60       get { return (ValueParameter<DoubleArray>)Parameters["Weights"]; }
     47    public IValueParameter<BoolMatrix> GeneInteractionsParameter {
     48      get { return (IValueParameter<BoolMatrix>)Parameters["GeneInteractions"]; }
     49    }
     50    public IValueParameter<IntValue> InteractionSeedParameter {
     51      get { return (IValueParameter<IntValue>)Parameters["InteractionSeed"]; }
     52    }
     53    public IValueParameter<IntValue> NrOfInteractionsParameter {
     54      get { return (IValueParameter<IntValue>)Parameters["NrOfInteractions"]; }
     55    }
     56    public IValueParameter<IntValue> NrOfFitnessComponentsParameter {
     57      get { return (IValueParameter<IntValue>)Parameters["NrOfFitnessComponents"]; }
     58    }
     59    public IValueParameter<DoubleArray> WeightsParameter {
     60      get { return (IValueParameter<DoubleArray>)Parameters["Weights"]; }
    6161    }
    6262    public IConstrainedValueParameter<IInteractionInitializer> InteractionInitializerParameter {
     
    8080    public IntValue InteractionSeed {
    8181      get { return InteractionSeedParameter.Value; }
     82    }
     83    public IntValue NrOfFitnessComponents {
     84      get { return NrOfFitnessComponentsParameter.Value; }
     85    }
     86    public IntValue NrOfInteractions {
     87      get { return NrOfInteractionsParameter.Value; }
     88    }
     89    public IWeightsInitializer WeightsInitializer {
     90      get { return WeightsInitializerParameter.Value; }
    8291    }
    8392    #endregion
     
    168177    }
    169178
    170     void WeightsInitializerParameter_ValueChanged(object sender, EventArgs e) {
     179    private void WeightsInitializerParameter_ValueChanged(object sender, EventArgs e) {
    171180      InitializeWeights();
    172181    }
    173182
    174     void InteractionInitializerParameter_ValueChanged(object sender, EventArgs e) {
     183    private void InteractionInitializerParameter_ValueChanged(object sender, EventArgs e) {
    175184      InitializeInteractions();
    176185    }
     
    190199        GeneInteractionsParameter.Value = InteractionInitializer.InitializeInterations(
    191200          Length,
    192           NrOfFitnessComponentsParameter.Value.Value,
    193           NrOfInteractionsParameter.Value.Value, Random);
     201          NrOfFitnessComponents.Value,
     202          NrOfInteractions.Value, Random);
    194203    }
    195204
     
    197206      if (WeightsInitializerParameter.Value != null)
    198207        WeightsParameter.Value = new DoubleArray(
    199           WeightsInitializerParameter.Value.GetWeights(NrOfFitnessComponentsParameter.Value.Value)
     208          WeightsInitializer.GetWeights(NrOfFitnessComponents.Value)
    200209          .ToArray());
    201210    }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKMoveEvaluator.cs

    r12566 r12569  
    2525using HeuristicLab.Encodings.BinaryVectorEncoding;
    2626using HeuristicLab.Operators;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Parameters;
    2928using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3130namespace HeuristicLab.Problems.NK {
    3231
    33   [Item("NKMoveEvaluator", "A base class for operators which evaluate moves on the NK Lanscape.")]
     32  [Item("NKMoveEvaluator", "A base class for operators which evaluate moves on the NK Landscape.")]
    3433  [StorableClass]
    35   public abstract class NKMoveEvaluator : SingleSuccessorOperator, INKMoveEvaluator, IMoveOperator, IBinaryVectorMoveOperator {
     34  public abstract class NKMoveEvaluator : SingleSuccessorOperator, INKMoveEvaluator, IBinaryVectorMoveOperator {
    3635
    3736    public ILookupParameter<DoubleValue> QualityParameter {
     
    4443      get { return (ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; }
    4544    }
    46     public LookupParameter<BoolMatrix> GeneInteractionsParameter {
    47       get { return (LookupParameter<BoolMatrix>)Parameters["GeneInteractions"]; }
     45    public ILookupParameter<BoolMatrix> GeneInteractionsParameter {
     46      get { return (ILookupParameter<BoolMatrix>)Parameters["GeneInteractions"]; }
    4847    }
    49     public LookupParameter<IntValue> InteractionSeedParameter {
    50       get { return (LookupParameter<IntValue>)Parameters["InteractionSeed"]; }
     48    public ILookupParameter<IntValue> InteractionSeedParameter {
     49      get { return (ILookupParameter<IntValue>)Parameters["InteractionSeed"]; }
    5150    }
    52     public LookupParameter<DoubleArray> WeightsParameter {
    53       get { return (LookupParameter<DoubleArray>)Parameters["Weights"]; }
     51    public ILookupParameter<DoubleArray> WeightsParameter {
     52      get { return (ILookupParameter<DoubleArray>)Parameters["Weights"]; }
    5453    }
    5554
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/Properties/AssemblyInfo.cs.frame

    r12566 r12569  
    2727// associated with an assembly.
    2828[assembly: AssemblyTitle("HeuristicLab.Problems.NK")]
    29 [assembly: AssemblyDescription("NK Fitness Lanscape Analysis Test Problem")]
     29[assembly: AssemblyDescription("NK Fitness Landscape Analysis Test Problem")]
    3030[assembly: AssemblyConfiguration("")]
    3131[assembly: AssemblyCompany("")]
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/EqualWeightsInitializer.cs

    r12566 r12569  
    2727namespace HeuristicLab.Problems.NK.WeightInitializers {
    2828
    29   [Item("EqualWeightsInitializer", "Initializes all weights to 1.0")]
     29  [Item("EqualWeightsInitializer", "Initializes all weights to 1.0.")]
     30  [StorableClass]
    3031  public class EqualWeightsInitializer : NamedItem, IWeightsInitializer {
    3132
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialDistributionWeightsInitializer.cs

    r12566 r12569  
    3030namespace HeuristicLab.Problems.NK.WeightInitializers {
    3131
    32   [Item("ExponentialDistributionWeightsInitializer", "Assigned exponentially decreasing weights using the rate parameter lambad.")]
     32  [Item("ExponentialDistributionWeightsInitializer", "Assigns exponentially decreasing weights using the rate parameter lambda.")]
     33  [StorableClass]
    3334  public class ExponentialDistributionWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3435
    3536    public override bool CanChangeName { get { return false; } }
    3637    public override bool CanChangeDescription { get { return false; } }
    37     public ValueParameter<DoubleValue> LambdaParameter {
    38       get { return (ValueParameter<DoubleValue>)Parameters["Lambda"]; }
     38    public IValueParameter<DoubleValue> LambdaParameter {
     39      get { return (IValueParameter<DoubleValue>)Parameters["Lambda"]; }
    3940    }
    4041
     
    4546    }
    4647    public ExponentialDistributionWeightsInitializer() {
    47       Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The rate paramter of the exponential distribution.", new DoubleValue(1.0)));
     48      Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The rate parameter of the exponential distribution.", new DoubleValue(1.0)));
    4849    }
    4950    public override IDeepCloneable Clone(Cloner cloner) {
     
    5253
    5354    public static double f(double x, double lambda) {
    54       if (x < 0)
    55         return 0;
     55      if (x < 0.0)
     56        return 0.0;
    5657      return lambda * Math.Exp(-lambda * x);
    5758    }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialWeightsInitializer.cs

    r12566 r12569  
    2828namespace HeuristicLab.Problems.NK.WeightInitializers {
    2929
    30   [Item("ExponentialWeightsInitializer", "Assigned exponentially increasing weights.")]
     30  [Item("ExponentialWeightsInitializer", "Assigns exponentially increasing weights.")]
     31  [StorableClass]
    3132  public class ExponentialWeightsInitializer : NamedItem, IWeightsInitializer {
    3233
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/IWeightsInitializer.cs

    r12566 r12569  
    2424
    2525namespace HeuristicLab.Problems.NK {
    26 
    2726  public interface IWeightsInitializer : INamedItem {
    2827    IEnumerable<double> GetWeights(int nComponents);
    2928  }
    30 
    3129}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/LinearWeightsInitializer.cs

    r12566 r12569  
    2727namespace HeuristicLab.Problems.NK.WeightInitializers {
    2828
    29   [Item("LinearWeightsInitializer", "Assigned linear increasing weights.")]
     29  [Item("LinearWeightsInitializer", "Assigns linear increasing weights.")]
     30  [StorableClass]
    3031  public class LinearWeightsInitializer : NamedItem, IWeightsInitializer {
    3132
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseExponentialWeightsInitializer.cs

    r12566 r12569  
    2828namespace HeuristicLab.Problems.NK.WeightInitializers {
    2929
    30   [Item("ReverseExponentialWeightsInitializer", "Assigned exponentially decreasing weights.")]
     30  [Item("ReverseExponentialWeightsInitializer", "Assigns exponentially decreasing weights.")]
     31  [StorableClass]
    3132  public class ReverseExponentialWeightsInitializer : NamedItem, IWeightsInitializer {
    3233
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseLinearWeightsInitializer.cs

    r12566 r12569  
    2727namespace HeuristicLab.Problems.NK.WeightInitializers {
    2828
    29   [Item("ReverseLienarWeightsInitializer", "Assigned exponentially decreasing weights.")]
     29  [Item("ReverseLinearWeightsInitializer", "Assigns exponentially decreasing weights.")]
     30  [StorableClass]
    3031  public class ReverseLinearWeightsInitializer : NamedItem, IWeightsInitializer {
    3132
Note: See TracChangeset for help on using the changeset viewer.