Index: /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj
===================================================================
--- /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj (revision 7698)
+++ /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj (revision 7699)
@@ -173,4 +173,5 @@
+
Index: /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformSomePositionsManipulator.cs
===================================================================
--- /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformSomePositionsManipulator.cs (revision 7699)
+++ /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformSomePositionsManipulator.cs (revision 7699)
@@ -0,0 +1,108 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.IntegerVectorEncoding {
+ ///
+ /// Uniformly distributed change of several, but at least one, positions of an integer vector.
+ ///
+ ///
+ /// It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.
+ ///
+ [Item("UniformSomePositionsManipulator", " Uniformly distributed change of several, but at least one, positions of an integer vector. It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.")]
+ [StorableClass]
+ public class UniformSomePositionsManipulator : IntegerVectorManipulator, IBoundedIntegerVectorOperator {
+ ///
+ /// A matrix that specifies the bounds for each dimension in a separate row. The first column denotes the minimum, the second the maximum value, and the third column denotes the step size.
+ ///
+ public IValueLookupParameter BoundsParameter {
+ get { return (IValueLookupParameter)Parameters["Bounds"]; }
+ }
+
+ public IValueLookupParameter ProbabilityParameter {
+ get { return (IValueLookupParameter)Parameters["Probability"]; }
+ }
+
+ [StorableConstructor]
+ protected UniformSomePositionsManipulator(bool deserializing) : base(deserializing) { }
+ protected UniformSomePositionsManipulator(UniformSomePositionsManipulator original, Cloner cloner) : base(original, cloner) { }
+ ///
+ /// Initializes a new instance of with two parameters
+ /// (Minimum and Maximum).
+ ///
+ public UniformSomePositionsManipulator()
+ : base() {
+ Parameters.Add(new ValueLookupParameter("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled."));
+ Parameters.Add(new ValueLookupParameter("Probability", "The probability for each dimension to be manipulated.", new DoubleValue(0.5)));
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new UniformSomePositionsManipulator(this, cloner);
+ }
+
+ ///
+ /// Changes randomly several, but at least one, positions in the given integer , according to the given probabilities.
+ ///
+ /// A random number generator.
+ /// The integer vector to manipulate.
+ /// Contains the minimum value (inclusive), maximum value (exclusive), and step size of the sampling range for
+ /// the vector element to change.
+ /// The probability for each dimension to be manipulated..
+ public static void Apply(IRandom random, IntegerVector vector, IntMatrix bounds, double probability) {
+ if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("UniformSomePositionsManipulator: Invalid bounds specified", "bounds");
+ bool atLeastOneManipulated = false;
+ for (int index = 0; index < vector.Length; index++) {
+ if (random.NextDouble() < probability) {
+ atLeastOneManipulated = true;
+ Manipulate(random, vector, bounds, index);
+ }
+ }
+
+ if (!atLeastOneManipulated) {
+ Manipulate(random, vector, bounds, random.Next(vector.Length));
+ }
+ }
+
+ private static void Manipulate(IRandom random, IntegerVector vector, IntMatrix bounds, int index) {
+ int min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1], step = 1;
+ if (bounds.Columns > 2) step = bounds[index % bounds.Rows, 2];
+ int value = (max - min) / step;
+ vector[index] = random.Next(value) * step + min;
+ }
+
+ ///
+ /// Changes randomly several, but at least one, positions in the given integer .
+ ///
+ /// Calls .
+ /// A random number generator.
+ /// The integer vector to manipulate.
+ protected override void Manipulate(IRandom random, IntegerVector vector) {
+ if (BoundsParameter.ActualValue == null) throw new InvalidOperationException("UniformSomePositionsManipulator: Parameter " + BoundsParameter.ActualName + " could not be found.");
+ Apply(random, vector, BoundsParameter.ActualValue, ProbabilityParameter.ActualValue.Value);
+ }
+ }
+}
Index: /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/ShakingOperators/IntegerVectorShakingOperator.cs
===================================================================
--- /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/ShakingOperators/IntegerVectorShakingOperator.cs (revision 7698)
+++ /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/ShakingOperators/IntegerVectorShakingOperator.cs (revision 7699)
@@ -58,5 +58,5 @@
Parameters.Add(new LookupParameter("Random", "The random number generator that will be used for stochastic shaking operators."));
foreach (IIntegerVectorManipulator shaker in ApplicationManager.Manager.GetInstances().OrderBy(x => x.Name))
- Operators.Add(shaker);
+ if (!(shaker is ISelfAdaptiveManipulator)) Operators.Add(shaker);
}