Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/13 15:32:29 (11 years ago)
Author:
abeham
Message:

#1961: implemented reviewer comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs

    r9303 r9709  
    7373    }
    7474
    75     public IValueParameter<IntValue> MaxTriesParameter {
    76       get { return (IValueParameter<IntValue>)Parameters["MaxTries"]; }
     75    public IFixedValueParameter<IntValue> MaxTriesParameter {
     76      get { return (IFixedValueParameter<IntValue>)Parameters["MaxTries"]; }
     77    }
     78
     79    public IFixedValueParameter<BoolValue> TruncateAtBoundsParameter {
     80      get { return (IFixedValueParameter<BoolValue>)Parameters["TruncateAtBounds"]; }
    7781    }
    7882    #endregion
     
    9195      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The bounds for the dimensions."));
    9296      Parameters.Add(new LookupParameter<CMAParameters>("StrategyParameters", "The CMA-ES strategy parameters used for mutation."));
    93       Parameters.Add(new ValueParameter<IntValue>("MaxTries", "The maximum number of tries a mutation should be performed if it was outside the bounds.", new IntValue(1000)));
     97      Parameters.Add(new FixedValueParameter<IntValue>("MaxTries", "The maximum number of tries a mutation should be performed if it was outside the bounds.", new IntValue(100)));
     98      Parameters.Add(new FixedValueParameter<BoolValue>("TruncateAtBounds", "Whether the point should be truncated at the bounds if none of the tries resulted in a point within the bounds.", new BoolValue(true)));
    9499    }
    95100
     
    100105    public override IOperation Apply() {
    101106      var maxTries = MaxTriesParameter.Value.Value;
     107      var truncateAtBounds = TruncateAtBoundsParameter.Value.Value;
    102108      var random = RandomParameter.ActualValue;
    103109      var lambda = PopulationSizeParameter.ActualValue.Value;
     
    128134              if (!inRange) tries++;
    129135            } while (!inRange && tries < maxTries);
    130             if (!inRange && maxTries > 1) {
     136            if (!inRange && truncateAtBounds) {
    131137              if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0];
    132138              else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1];
     
    152158            }
    153159          } while (!inRange && tries < maxTries);
    154           if (!inRange && maxTries > 1) {
     160          if (!inRange && truncateAtBounds) {
    155161            for (int k = 0; k < length; k++) {
    156162              if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0];
Note: See TracChangeset for help on using the changeset viewer.