- Timestamp:
- 09/06/12 14:45:59 (12 years ago)
- Location:
- branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Crossovers/ParameterConfigurationCrossover.cs
r8574 r8590 108 108 109 109 Cross(RandomParameter.ActualValue, child1, child2, IntValueCrossoverParameter.ActualValue, DoubleValueCrossoverParameter.ActualValue); 110 this.ChildParameter.ActualValue = child1;110 ChildParameter.ActualValue = child1; 111 111 112 112 return base.Apply(); -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/HeuristicLab.Encodings.ParameterConfigurationEncoding-3.3.csproj
r8574 r8590 119 119 <Compile Include="Operators\Crossovers\DoubleValue\AverageDoubleValueCrossover.cs" /> 120 120 <Compile Include="Operators\Crossovers\DoubleValue\DiscreteDoubleValueCrossover.cs" /> 121 <Compile Include="Operators\Crossovers\DoubleValue\MultiDoubleValueCrossover.cs" /> 121 122 <Compile Include="Operators\Crossovers\DoubleValue\NormalDoubleValueCrossover.cs" /> 122 123 <Compile Include="Operators\Crossovers\IntValue\AverageIntValueCrossover.cs" /> -
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); -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/ParameterConfiguration.cs
r8574 r8590 96 96 protected Type parameterDataType; 97 97 public Type ParameterDataType { 98 get { return this.parameterDataType; }98 get { return parameterDataType; } 99 99 } 100 100 … … 103 103 get { return validTypes; } 104 104 protected set { 105 if ( this.validTypes != value) {106 this.validTypes = value;105 if (validTypes != value) { 106 validTypes = value; 107 107 } 108 108 } … … 113 113 public Type ValueDataType { 114 114 get { return valueDataType; } 115 protected set { this.valueDataType = value; }115 protected set { valueDataType = value; } 116 116 } 117 117 … … 119 119 protected ICheckedValueConfigurationList valueConfigurations; 120 120 public ICheckedValueConfigurationList ValueConfigurations { 121 get { return this.valueConfigurations; }121 get { return valueConfigurations; } 122 122 protected set { 123 if ( this.valueConfigurations != value) {124 if ( this.valueConfigurations != null) DeregisterValueConfigurationEvents();125 this.valueConfigurations = value;123 if (valueConfigurations != value) { 124 if (valueConfigurations != null) DeregisterValueConfigurationEvents(); 125 valueConfigurations = value; 126 126 KeepActualValueConfigurationIndexConsistent(); 127 if ( this.valueConfigurations != null) RegisterValueConfigurationEvents();128 } 129 } 130 } 131 132 [Storable] 133 private int actualValueConfigurationIndex = 0;127 if (valueConfigurations != null) RegisterValueConfigurationEvents(); 128 } 129 } 130 } 131 132 [Storable] 133 private int actualValueConfigurationIndex; 134 134 public int ActualValueConfigurationIndex { 135 135 get { return actualValueConfigurationIndex; } … … 155 155 get { return isNullable; } 156 156 protected set { 157 if ( this.isNullable != value) {158 this.isNullable = value;157 if (isNullable != value) { 158 isNullable = value; 159 159 } 160 160 } … … 182 182 get { return valuesReadOnly; } 183 183 set { 184 if (value != this.valuesReadOnly) {185 this.valuesReadOnly = value;186 foreach (var vc in this.valueConfigurations) {184 if (valuesReadOnly != value) { 185 valuesReadOnly = value; 186 foreach (var vc in valueConfigurations) { 187 187 vc.ValuesReadOnly = value; 188 188 }
Note: See TracChangeset
for help on using the changeset viewer.