Changeset 12569 for branches/FitnessLandscapeAnalysis
- Timestamp:
- 07/02/15 11:02:16 (9 years ago)
- 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 27 27 28 28 namespace HeuristicLab.Problems.NK { 29 30 public interface IBinaryVectorComparer : INamedItem, IComparer<BinaryVector> { }31 32 29 [StorableClass] 33 30 public abstract class BinaryVectorComparer : NamedItem, IBinaryVectorComparer { -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/HeuristicLab.Problems.NK.csproj
r12566 r12569 158 158 <ItemGroup> 159 159 <Compile Include="BinaryVectorComparers\BinaryVectorComparer.cs" /> 160 <Compile Include="BinaryVectorComparers\IBinaryVectorComparer.cs" /> 160 161 <Compile Include="BinaryVectorComparers\LexicographicBinaryVectorComparer.cs" /> 161 162 <Compile Include="BinaryVectorComparers\AverageBitBinaryVectorComparer.cs" /> -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/LimitedRandomInteractionsInitializer.cs
r12566 r12569 41 41 Max = Math.Max(min, max); 42 42 } 43 public int bounded(int n) {43 public int Bounded(int n) { 44 44 return Math.Max(Min, Math.Min(Max, n)); 45 45 } 46 46 } 47 47 48 public ValueParameter<IntValue> MaximumDistanceParameter {49 get { return ( ValueParameter<IntValue>)Parameters["MaximumDistance"]; }48 public IValueParameter<IntValue> MaximumDistanceParameter { 49 get { return (IValueParameter<IntValue>)Parameters["MaximumDistance"]; } 50 50 } 51 public ValueParameter<DoubleValue> MaximumDistanceRatioParameter {52 get { return ( ValueParameter<DoubleValue>)Parameters["MaximumDistanceRatio"]; }51 public IValueParameter<DoubleValue> MaximumDistanceRatioParameter { 52 get { return (IValueParameter<DoubleValue>)Parameters["MaximumDistanceRatio"]; } 53 53 } 54 54 … … 58 58 maxBitDist = Math.Min( 59 59 maxBitDist == 0 ? length : maxBitDist, 60 maxDistRatio == 0? length : (int)Math.Round(maxDistRatio * length));60 maxDistRatio.IsAlmost(0.0) ? length : (int)Math.Round(maxDistRatio * length)); 61 61 if (maxBitDist * 2 < nInteractions) 62 62 maxBitDist = (int)Math.Ceiling(0.5 * nInteractions); … … 83 83 var maxBounds = new Bounds(nInteractions, length - 1); 84 84 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); 87 87 var indices = Enumerable.Range(min, max - min).ToList(); 88 88 indices.Remove(c); -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/SortedRandomInteractionsInitializer.cs
r12566 r12569 31 31 namespace HeuristicLab.Problems.NK { 32 32 33 [Item("SortedRandomInteractionsInitializer", "Randomly assign edinteractions 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.")] 34 34 [StorableClass] 35 35 public class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer { 36 37 36 public IConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter { 38 37 get { return (IConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; } 39 38 } 40 41 39 public IBinaryVectorComparer Comparer { 42 40 get { return ComparerParameter.Value; } … … 47 45 protected SortedRandomInteractionsInitializer(SortedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { } 48 46 public SortedRandomInteractionsInitializer() { 49 AddComparerParameter(); 47 Parameters.Add(new ConstrainedValueParameter<IBinaryVectorComparer>("Comparer", "Comparison for sorting of component functions.")); 48 InitializeComparers(); 50 49 } 51 50 52 private void AddComparerParameter() { 53 Parameters.Add(new ConstrainedValueParameter<IBinaryVectorComparer>("Comparer", "Comparison for sorting of component functions")); 51 private void InitializeComparers() { 54 52 foreach (var comparer in ApplicationManager.Manager.GetInstances<IBinaryVectorComparer>()) 55 53 ComparerParameter.ValidValues.Add(comparer); … … 59 57 public override IDeepCloneable Clone(Cloner cloner) { 60 58 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 }72 59 } 73 60 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKBitFlipMoveEvaluator.cs
r12566 r12569 33 33 [StorableClass] 34 34 public class NKBitFlipMoveEvaluator : NKMoveEvaluator, IOneBitflipMoveOperator { 35 36 35 public ILookupParameter<OneBitflipMove> OneBitflipMoveParameter { 37 36 get { return (ILookupParameter<OneBitflipMove>)Parameters["OneBitflipMove"]; } 38 37 } 39 public LookupParameter<BinaryVector> MovedBinaryVectorParameter {40 get { return ( LookupParameter<BinaryVector>)Parameters["MovedBinaryVector"]; }38 public ILookupParameter<BinaryVector> MovedBinaryVectorParameter { 39 get { return (ILookupParameter<BinaryVector>)Parameters["MovedBinaryVector"]; } 41 40 } 42 41 43 42 [StorableConstructor] 44 43 protected NKBitFlipMoveEvaluator(bool deserializing) : base(deserializing) { } 45 46 44 protected NKBitFlipMoveEvaluator(NKBitFlipMoveEvaluator original, Cloner cloner) 47 45 : base(original, cloner) { } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs
r12566 r12569 45 45 46 46 #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"]; } 61 61 } 62 62 public IConstrainedValueParameter<IInteractionInitializer> InteractionInitializerParameter { … … 80 80 public IntValue InteractionSeed { 81 81 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; } 82 91 } 83 92 #endregion … … 168 177 } 169 178 170 void WeightsInitializerParameter_ValueChanged(object sender, EventArgs e) {179 private void WeightsInitializerParameter_ValueChanged(object sender, EventArgs e) { 171 180 InitializeWeights(); 172 181 } 173 182 174 void InteractionInitializerParameter_ValueChanged(object sender, EventArgs e) {183 private void InteractionInitializerParameter_ValueChanged(object sender, EventArgs e) { 175 184 InitializeInteractions(); 176 185 } … … 190 199 GeneInteractionsParameter.Value = InteractionInitializer.InitializeInterations( 191 200 Length, 192 NrOfFitnessComponents Parameter.Value.Value,193 NrOfInteractions Parameter.Value.Value, Random);201 NrOfFitnessComponents.Value, 202 NrOfInteractions.Value, Random); 194 203 } 195 204 … … 197 206 if (WeightsInitializerParameter.Value != null) 198 207 WeightsParameter.Value = new DoubleArray( 199 WeightsInitializer Parameter.Value.GetWeights(NrOfFitnessComponentsParameter.Value.Value)208 WeightsInitializer.GetWeights(NrOfFitnessComponents.Value) 200 209 .ToArray()); 201 210 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKMoveEvaluator.cs
r12566 r12569 25 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 26 using HeuristicLab.Operators; 27 using HeuristicLab.Optimization;28 27 using HeuristicLab.Parameters; 29 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 30 namespace HeuristicLab.Problems.NK { 32 31 33 [Item("NKMoveEvaluator", "A base class for operators which evaluate moves on the NK Lan scape.")]32 [Item("NKMoveEvaluator", "A base class for operators which evaluate moves on the NK Landscape.")] 34 33 [StorableClass] 35 public abstract class NKMoveEvaluator : SingleSuccessorOperator, INKMoveEvaluator, I MoveOperator, IBinaryVectorMoveOperator {34 public abstract class NKMoveEvaluator : SingleSuccessorOperator, INKMoveEvaluator, IBinaryVectorMoveOperator { 36 35 37 36 public ILookupParameter<DoubleValue> QualityParameter { … … 44 43 get { return (ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; } 45 44 } 46 public LookupParameter<BoolMatrix> GeneInteractionsParameter {47 get { return ( LookupParameter<BoolMatrix>)Parameters["GeneInteractions"]; }45 public ILookupParameter<BoolMatrix> GeneInteractionsParameter { 46 get { return (ILookupParameter<BoolMatrix>)Parameters["GeneInteractions"]; } 48 47 } 49 public LookupParameter<IntValue> InteractionSeedParameter {50 get { return ( LookupParameter<IntValue>)Parameters["InteractionSeed"]; }48 public ILookupParameter<IntValue> InteractionSeedParameter { 49 get { return (ILookupParameter<IntValue>)Parameters["InteractionSeed"]; } 51 50 } 52 public LookupParameter<DoubleArray> WeightsParameter {53 get { return ( LookupParameter<DoubleArray>)Parameters["Weights"]; }51 public ILookupParameter<DoubleArray> WeightsParameter { 52 get { return (ILookupParameter<DoubleArray>)Parameters["Weights"]; } 54 53 } 55 54 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/Properties/AssemblyInfo.cs.frame
r12566 r12569 27 27 // associated with an assembly. 28 28 [assembly: AssemblyTitle("HeuristicLab.Problems.NK")] 29 [assembly: AssemblyDescription("NK Fitness Lan scape Analysis Test Problem")]29 [assembly: AssemblyDescription("NK Fitness Landscape Analysis Test Problem")] 30 30 [assembly: AssemblyConfiguration("")] 31 31 [assembly: AssemblyCompany("")] -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/EqualWeightsInitializer.cs
r12566 r12569 27 27 namespace HeuristicLab.Problems.NK.WeightInitializers { 28 28 29 [Item("EqualWeightsInitializer", "Initializes all weights to 1.0")] 29 [Item("EqualWeightsInitializer", "Initializes all weights to 1.0.")] 30 [StorableClass] 30 31 public class EqualWeightsInitializer : NamedItem, IWeightsInitializer { 31 32 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialDistributionWeightsInitializer.cs
r12566 r12569 30 30 namespace HeuristicLab.Problems.NK.WeightInitializers { 31 31 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] 33 34 public class ExponentialDistributionWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer { 34 35 35 36 public override bool CanChangeName { get { return false; } } 36 37 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"]; } 39 40 } 40 41 … … 45 46 } 46 47 public ExponentialDistributionWeightsInitializer() { 47 Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The rate param ter 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))); 48 49 } 49 50 public override IDeepCloneable Clone(Cloner cloner) { … … 52 53 53 54 public static double f(double x, double lambda) { 54 if (x < 0 )55 return 0 ;55 if (x < 0.0) 56 return 0.0; 56 57 return lambda * Math.Exp(-lambda * x); 57 58 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialWeightsInitializer.cs
r12566 r12569 28 28 namespace HeuristicLab.Problems.NK.WeightInitializers { 29 29 30 [Item("ExponentialWeightsInitializer", "Assigned exponentially increasing weights.")] 30 [Item("ExponentialWeightsInitializer", "Assigns exponentially increasing weights.")] 31 [StorableClass] 31 32 public class ExponentialWeightsInitializer : NamedItem, IWeightsInitializer { 32 33 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/IWeightsInitializer.cs
r12566 r12569 24 24 25 25 namespace HeuristicLab.Problems.NK { 26 27 26 public interface IWeightsInitializer : INamedItem { 28 27 IEnumerable<double> GetWeights(int nComponents); 29 28 } 30 31 29 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/LinearWeightsInitializer.cs
r12566 r12569 27 27 namespace HeuristicLab.Problems.NK.WeightInitializers { 28 28 29 [Item("LinearWeightsInitializer", "Assigned linear increasing weights.")] 29 [Item("LinearWeightsInitializer", "Assigns linear increasing weights.")] 30 [StorableClass] 30 31 public class LinearWeightsInitializer : NamedItem, IWeightsInitializer { 31 32 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseExponentialWeightsInitializer.cs
r12566 r12569 28 28 namespace HeuristicLab.Problems.NK.WeightInitializers { 29 29 30 [Item("ReverseExponentialWeightsInitializer", "Assigned exponentially decreasing weights.")] 30 [Item("ReverseExponentialWeightsInitializer", "Assigns exponentially decreasing weights.")] 31 [StorableClass] 31 32 public class ReverseExponentialWeightsInitializer : NamedItem, IWeightsInitializer { 32 33 -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseLinearWeightsInitializer.cs
r12566 r12569 27 27 namespace HeuristicLab.Problems.NK.WeightInitializers { 28 28 29 [Item("ReverseLienarWeightsInitializer", "Assigned exponentially decreasing weights.")] 29 [Item("ReverseLinearWeightsInitializer", "Assigns exponentially decreasing weights.")] 30 [StorableClass] 30 31 public class ReverseLinearWeightsInitializer : NamedItem, IWeightsInitializer { 31 32
Note: See TracChangeset
for help on using the changeset viewer.