Changeset 3182
- Timestamp:
- 03/22/10 17:03:29 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/BoundsChecker.cs
r3123 r3182 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Operators; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Parameters;27 using System;28 28 29 29 namespace HeuristicLab.Encodings.RealVectorEncoding { … … 34 34 [Item("BoundsChecker", "Checks if all elements of a real vector are inside the bounds. If not, elements are corrected.")] 35 35 [StorableClass] 36 public class BoundsChecker : SingleSuccessorOperator {36 public class BoundsChecker : SingleSuccessorOperator, IRealVectorBoundsChecker { 37 37 public LookupParameter<RealVector> RealVectorParameter { 38 38 get { return (LookupParameter<RealVector>)Parameters["RealVector"]; } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj
r3054 r3182 103 103 <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" /> 104 104 <Compile Include="HeuristicLabEncodingsRealVectorEncodingPlugin.cs" /> 105 <Compile Include="Interfaces\IRealVectorBoundsChecker.cs" /> 105 106 <Compile Include="RealVector.cs" /> 106 107 <Compile Include="Manipulators\BreederGeneticAlgorithmManipulator.cs" /> -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorCrossover.cs
r3060 r3182 31 31 ILookupParameter<ItemArray<RealVector>> ParentsParameter { get; } 32 32 ILookupParameter<RealVector> ChildParameter { get; } 33 IValueLookupParameter<DoubleMatrix> BoundsParameter { get; } 33 34 } 34 35 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorManipulator.cs
r3060 r3182 30 30 public interface IRealVectorManipulator : IRealVectorOperator, IManipulator { 31 31 ILookupParameter<RealVector> RealVectorParameter { get; } 32 IValueLookupParameter<DoubleMatrix> BoundsParameter { get; } 32 33 } 33 34 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/BreederGeneticAlgorithmManipulator.cs
r3123 r3182 38 38 public class BreederGeneticAlgorithmManipulator : RealVectorManipulator { 39 39 private static readonly double[] powerOfTwo = new double[] { 1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625, 0.001953125, 0.0009765625, 0.00048828125, 0.000244140625, 0.0001220703125, 0.00006103515625, 0.000030517578125 }; 40 public ValueLookupParameter<DoubleMatrix> BoundsParameter {41 get { return (ValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }42 }43 40 public ValueLookupParameter<DoubleValue> SearchIntervalFactorParameter { 44 41 get { return (ValueLookupParameter<DoubleValue>)Parameters["SearchIntervalFactor"]; } … … 50 47 public BreederGeneticAlgorithmManipulator() 51 48 : base() { 52 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each element in the vector.")); 53 Parameters.Add(new ValueLookupParameter<DoubleValue>("SearchIntervalFactor", "The factor determining the size of the search interval, that will be added/removed to/from the allele selected for manipulation.", new DoubleValue(0.1))); 49 Parameters.Add(new ValueLookupParameter<DoubleValue>("SearchIntervalFactor", "The factor determining the size of the search interval, that will be added/removed to/from the allele selected for manipulation. E.g. a value of 0.1 means 10% of the range will be maximally added/removed.", new DoubleValue(0.1))); 54 50 } 55 51 -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/MichalewiczNonUniformAllPositionsManipulator.cs
r3172 r3182 38 38 public class MichalewiczNonUniformAllPositionsManipulator : RealVectorManipulator { 39 39 /// <summary> 40 /// The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.41 /// </summary>42 public ValueLookupParameter<DoubleMatrix> BoundsParameter {43 get { return (ValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }44 }45 /// <summary>46 40 /// The current generation. 47 41 /// </summary> … … 69 63 public MichalewiczNonUniformAllPositionsManipulator() 70 64 : base() { 71 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled."));72 65 Parameters.Add(new LookupParameter<IntValue>("Generation", "Current generation of the algorithm")); 73 66 Parameters.Add(new LookupParameter<IntValue>("MaximumGenerations", "Maximum number of generations")); -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/MichalewiczNonUniformOnePositionManipulator.cs
r3123 r3182 38 38 public class MichalewiczNonUniformOnePositionManipulator : RealVectorManipulator { 39 39 /// <summary> 40 /// The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.41 /// </summary>42 public ValueLookupParameter<DoubleMatrix> BoundsParameter {43 get { return (ValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }44 }45 /// <summary>46 40 /// The current generation. 47 41 /// </summary> … … 69 63 public MichalewiczNonUniformOnePositionManipulator() 70 64 : base() { 71 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled."));72 65 Parameters.Add(new LookupParameter<IntValue>("Generation", "Current generation of the algorithm")); 73 66 Parameters.Add(new LookupParameter<IntValue>("MaximumGenerations", "Maximum number of generations")); -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/UniformOnePositionManipulator.cs
r3123 r3182 37 37 public class UniformOnePositionManipulator : RealVectorManipulator { 38 38 /// <summary> 39 /// The bounds of the values in the real vector.40 /// </summary>41 public ValueLookupParameter<DoubleMatrix> BoundsParameter {42 get { return (ValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }43 }44 45 /// <summary>46 /// Initializes a new instance of <see cref="UniformOnePositionManipulator"/> with one parameter47 /// (<c>Bounds</c>).48 /// </summary>49 public UniformOnePositionManipulator() {50 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "Lower and upper bound of the positions in the vector."));51 }52 53 /// <summary>54 39 /// Changes randomly a single position in the given real <paramref name="vector"/>. 55 40 /// </summary> -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorCrossover.cs
r3060 r3182 47 47 get { return (ILookupParameter<RealVector>)Parameters["Child"]; } 48 48 } 49 public IValueLookupParameter<DoubleMatrix> BoundsParameter { 50 get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; } 51 } 49 52 50 53 protected RealVectorCrossover() … … 53 56 Parameters.Add(new SubScopesLookupParameter<RealVector>("Parents", "The parent vectors which should be crossed.")); 54 57 Parameters.Add(new LookupParameter<RealVector>("Child", "The child vector resulting from the crossover.")); 58 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds of the real vector.")); 55 59 } 56 60 57 61 public sealed override IOperation Apply() { 58 ChildParameter.ActualValue = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue); 62 RealVector result = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue); 63 DoubleMatrix bounds = BoundsParameter.ActualValue; 64 if (bounds != null) BoundsChecker.Apply(result, bounds); 65 ChildParameter.ActualValue = result; 59 66 return base.Apply(); 60 67 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorManipulator.cs
r3060 r3182 44 44 get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; } 45 45 } 46 public IValueLookupParameter<DoubleMatrix> BoundsParameter { 47 get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; } 48 } 46 49 47 50 protected RealVectorManipulator() … … 49 52 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 50 53 Parameters.Add(new LookupParameter<RealVector>("RealVector", "The vector which should be manipulated.")); 54 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds of the real vector.")); 51 55 } 52 56 53 57 public sealed override IOperation Apply() { 54 Manipulate(RandomParameter.ActualValue, RealVectorParameter.ActualValue); 58 RealVector vector = RealVectorParameter.ActualValue; 59 Manipulate(RandomParameter.ActualValue, vector); 60 DoubleMatrix bounds = BoundsParameter.ActualValue; 61 if (bounds != null) BoundsChecker.Apply(vector, bounds); 55 62 return base.Apply(); 56 63 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3170 r3182 226 226 Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1; 227 227 } 228 private void BoundsParameter_NameChanged(object sender, EventArgs e) { 229 ParameterizeOperators(); 230 } 228 231 #endregion 229 232 … … 234 237 ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged); 235 238 ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged); 239 BoundsParameter.NameChanged += new EventHandler(BoundsParameter_NameChanged); 236 240 BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged); 237 241 Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged); … … 243 247 VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged); 244 248 } 245 246 249 private void InitializeOperators() { 247 250 operators = new List<IRealVectorOperator>(); … … 280 283 op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 281 284 op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 285 op.BoundsParameter.ActualName = BoundsParameter.Name; 282 286 } 283 287 foreach (IRealVectorManipulator op in Operators.OfType<IRealVectorManipulator>()) { 284 288 op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 289 op.BoundsParameter.ActualName = BoundsParameter.Name; 285 290 } 286 291 /*foreach (IPermutationMoveOperator op in Operators.OfType<IPermutationMoveOperator>()) {
Note: See TracChangeset
for help on using the changeset viewer.