Changeset 9709 for branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs
- Timestamp:
- 07/16/13 15:32:29 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs
r9303 r9709 73 73 } 74 74 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"]; } 77 81 } 78 82 #endregion … … 91 95 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The bounds for the dimensions.")); 92 96 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))); 94 99 } 95 100 … … 100 105 public override IOperation Apply() { 101 106 var maxTries = MaxTriesParameter.Value.Value; 107 var truncateAtBounds = TruncateAtBoundsParameter.Value.Value; 102 108 var random = RandomParameter.ActualValue; 103 109 var lambda = PopulationSizeParameter.ActualValue.Value; … … 128 134 if (!inRange) tries++; 129 135 } while (!inRange && tries < maxTries); 130 if (!inRange && maxTries > 1) {136 if (!inRange && truncateAtBounds) { 131 137 if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0]; 132 138 else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1]; … … 152 158 } 153 159 } while (!inRange && tries < maxTries); 154 if (!inRange && maxTries > 1) {160 if (!inRange && truncateAtBounds) { 155 161 for (int k = 0; k < length; k++) { 156 162 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.