- Timestamp:
- 07/16/13 15:32:29 (11 years ago)
- Location:
- branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALinearweightedRecombinator.cs
r9297 r9709 25 25 26 26 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { 27 [Item("CMA Linear-weighted Recombinator", "Calculates weighted mean using linear increasing weights.")]27 [Item("CMA Linear-weighted Recombinator", "Calculates weighted mean using linear decreasing weights.")] 28 28 [StorableClass] 29 29 public class CMALinearweightedRecombinator : CMARecombinator { -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALogweightedRecombinator.cs
r9297 r9709 20 20 #endregion 21 21 22 using System; 23 using System.Linq; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using System;26 using System.Linq;27 27 28 28 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { 29 [Item("CMA Log-weighted Recombinator", "Calculates weighted mean based on a logarithmic increasing weights.")]29 [Item("CMA Log-weighted Recombinator", "Calculates weighted mean based on a logarithmic decreasing weights.")] 30 30 [StorableClass] 31 31 public class CMALogweightedRecombinator : CMARecombinator { -
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.