Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/17/12 13:38:17 (12 years ago)
Author:
abeham
Message:

#1775:

  • Renamed some crossovers
  • Ported some additional crossovers from the real-vector plugin
  • Introduced BoundedIntegerVector* base classes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/SelfAdaptiveRoundedNormalAllPositionsManipulator.cs

    r7715 r8017  
    3636  [Item("SelfAdaptiveRoundedNormalAllPositionsManipulator", "This manipulation operator adds a value sigma_i * N(0,1) to the current value in each position i. The resulting value is rounded to the next feasible value. The values for sigma_i are looked up dynamically. If there are less elements in the strategy vector than positions, then the strategy vector is cycled.")]
    3737  [StorableClass]
    38   public class SelfAdaptiveRoundedNormalAllPositionsManipulator : IntegerVectorManipulator, ISelfAdaptiveManipulator {
     38  public class SelfAdaptiveRoundedNormalAllPositionsManipulator : BoundedIntegerVectorManipulator, ISelfAdaptiveManipulator {
    3939    public Type StrategyParameterType {
    4040      get { return typeof(IIntegerVectorStdDevStrategyParameterOperator); }
     
    5151    }
    5252
    53     public IValueLookupParameter<IntMatrix> BoundsParameter {
    54       get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
    55     }
    56 
    5753    [StorableConstructor]
    5854    protected SelfAdaptiveRoundedNormalAllPositionsManipulator(bool deserializing) : base(deserializing) { }
     
    6460      : base() {
    6561      Parameters.Add(new LookupParameter<DoubleArray>("StrategyParameter", "The vector containing the endogenous strategy parameters."));
    66       Parameters.Add(new ValueLookupParameter<IntMatrix>("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."));
    6762    }
    6863
     
    8075    /// <param name="random">A random number generator.</param>
    8176    /// <param name="vector">The integer vector to manipulate.</param>
     77    /// <param name="bounds">The bounds and step size for each dimension (will be cycled in case there are less rows than elements in the parent vectors).</param>
    8278    public static void Apply(IRandom random, IntegerVector vector, IntMatrix bounds, DoubleArray strategyParameters) {
    83       if (strategyParameters == null || strategyParameters.Length == 0) throw new ArgumentException("ERROR: Vector containing the standard deviations is not defined.", "sigma");
    84       if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("RoundedNormalAllPositionsManipulator: Invalid bounds specified.", "bounds");
     79      if (strategyParameters == null || strategyParameters.Length == 0) throw new ArgumentException("SelfAdaptiveRoundedNormalAllPositionsManipulator: Vector containing the standard deviations is not defined.", "sigma");
     80      if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("SelfAdaptiveRoundedNormalAllPositionsManipulator: Invalid bounds specified.", "bounds");
    8581      var N = new NormalDistributedRandom(random, 0.0, 1.0);
    8682      if (strategyParameters != null) {
     
    9086
    9187          int value = (vector[i] + (int)Math.Round((N.NextDouble() * strategyParameters[i % strategyParameters.Length])) - min) / step;
    92           vector[i] = Math.Max(min, Math.Min(max, value * step + min));
     88          vector[i] = RoundFeasible(min, max, step, value);
    9389        }
    9490      }
     
    10096    /// <param name="random">The random number generator.</param>
    10197    /// <param name="vector">The vector of integer values that is manipulated.</param>
    102     protected override void Manipulate(IRandom random, IntegerVector vector) {
    103       Apply(random, vector, BoundsParameter.ActualValue, StrategyParameterParameter.ActualValue);
     98    /// <param name="bounds">The bounds and step size for each dimension (will be cycled in case there are less rows than elements in the parent vectors).</param>
     99    protected override void ManipulateBounded(IRandom random, IntegerVector vector, IntMatrix bounds) {
     100      Apply(random, vector, bounds, StrategyParameterParameter.ActualValue);
    104101    }
    105102  }
Note: See TracChangeset for help on using the changeset viewer.