Changeset 8590 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators
- Timestamp:
- 09/06/12 14:45:59 (12 years ago)
- Location:
- branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/AverageDoubleValueCrossover.cs
r8574 r8590 56 56 public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { 57 57 value.Value = (value.Value + other.Value) / 2; 58 value.Value = range.ApplyStepSize(value.Value);59 58 } 60 59 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/DiscreteDoubleValueCrossover.cs
r8574 r8590 55 55 56 56 public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { 57 if (random.NextDouble() > 0.5) {57 if (random.NextDouble() > 0.5) 58 58 value.Value = other.Value; 59 }60 59 } 61 60 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/NormalDoubleValueCrossover.cs
r8574 r8590 53 53 54 54 public void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { 55 value.Value = ApplyStatic(random, value, other, range).Value;55 ApplyStatic(random, value, other, range); 56 56 } 57 57 58 public static DoubleValue ApplyStatic(IRandom random, DoubleValue better, DoubleValue worse, DoubleValueRange range) { 59 NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value) / 3); 60 var offspring = new DoubleValue(); 58 public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { 59 var N = new NormalDistributedRandom(random, value.Value, Math.Abs(value.Value - other.Value) / 3); 60 61 double offspring; 61 62 do { 62 offspring .Value= N.NextDouble();63 offspring .Value = range.ApplyStepSize(offspring.Value);64 } while (!range.IsInRange(offspring .Value));63 offspring = N.NextDouble(); 64 offspring = range.ApplyStepSize(offspring); 65 } while (!range.IsInRange(offspring)); 65 66 66 returnoffspring;67 value.Value = offspring; 67 68 } 68 69 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/DiscreteIntValueCrossover.cs
r8574 r8590 55 55 56 56 public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) { 57 if (random.NextDouble() > 0.5) {57 if (random.NextDouble() > 0.5) 58 58 value.Value = other.Value; 59 }60 59 } 61 60 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/MultiIntValueCrossover.cs
r8574 r8590 67 67 68 68 public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) { 69 // TODO69 Operators[random.Next(Operators.Count)].Apply(random, value, other, range); 70 70 } 71 71 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/NormalIntValueCrossover.cs
r8574 r8590 53 53 54 54 public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) { 55 value.Value = ApplyStatic(random, value, other, range).Value;55 ApplyStatic(random, value, other, range); 56 56 } 57 57 58 public static IntValue ApplyStatic(IRandom random, IntValue better, IntValue worse, IntValueRange range) { 59 NormalDistributedRandom N = new NormalDistributedRandom(random, better.Value, Math.Abs(better.Value - worse.Value) / 3); 60 var offspring = new IntValue(); 58 public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) { 59 var N = new NormalDistributedRandom(random, value.Value, Math.Abs(value.Value - other.Value) / 3); 60 61 int offspring; 61 62 do { 62 offspring.Value = (int)N.NextDouble(); 63 offspring.Value = range.ApplyStepSize(offspring.Value); 64 } while (!range.IsInRange(offspring.Value)); 65 return offspring; 63 offspring = (int)N.NextDouble(); 64 offspring = range.ApplyStepSize(offspring); 65 } while (!range.IsInRange(offspring)); 66 67 value.Value = offspring; 66 68 } 67 69 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Manipulators/IntValue/NormalIntValueManipulator.cs
r8574 r8590 36 36 [StorableClass] 37 37 public class NormalIntValueManipulator : SingleSuccessorOperator, IIntValueManipulator, IStochasticOperator { 38 39 38 public ILookupParameter<IRandom> RandomParameter { 40 39 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 59 58 public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) { 60 59 var strategy = new RealVector(new double[] { (range.UpperBound.Value - range.LowerBound.Value) / 10 }); 61 var vector = new RealVector( new double[] { value.Value });60 var vector = new RealVector(1); 62 61 int val = value.Value; 63 62 -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Manipulators/IntValue/UniformIntValueManipulator.cs
r8574 r8590 36 36 [StorableClass] 37 37 public class UniformIntValueManipulator : SingleSuccessorOperator, IIntValueManipulator, IStochasticOperator { 38 39 38 public ILookupParameter<IRandom> RandomParameter { 40 39 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 58 57 59 58 public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) { 60 var vector = new IntegerVector(new int[] { value.Value }); 59 var vector = new IntegerVector(1); 60 var bounds = new IntMatrix(1, 2); 61 bounds[0, 0] = range.LowerBound.Value; 62 bounds[0, 1] = range.UpperBound.Value; 61 63 int val = value.Value; 62 64 63 65 do { 64 66 vector[0] = val; 65 UniformOnePositionManipulator.Apply(random, vector, new IntMatrix(new int[,] { { range.LowerBound.Value, range.UpperBound.Value } }));67 UniformOnePositionManipulator.Apply(random, vector, bounds); 66 68 value.Value = vector[0]; 67 69 value.Value = range.ApplyStepSize(value.Value);
Note: See TracChangeset
for help on using the changeset viewer.