Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/06/12 14:45:59 (12 years ago)
Author:
jkarder
Message:

#1853:

  • added MultiDoubleValueCrossover
  • fixed bug in AverageDoubleValueCrossover
  • minor code improvements
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  
    108108
    109109      Cross(RandomParameter.ActualValue, child1, child2, IntValueCrossoverParameter.ActualValue, DoubleValueCrossoverParameter.ActualValue);
    110       this.ChildParameter.ActualValue = child1;
     110      ChildParameter.ActualValue = child1;
    111111
    112112      return base.Apply();
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/HeuristicLab.Encodings.ParameterConfigurationEncoding-3.3.csproj

    r8574 r8590  
    119119    <Compile Include="Operators\Crossovers\DoubleValue\AverageDoubleValueCrossover.cs" />
    120120    <Compile Include="Operators\Crossovers\DoubleValue\DiscreteDoubleValueCrossover.cs" />
     121    <Compile Include="Operators\Crossovers\DoubleValue\MultiDoubleValueCrossover.cs" />
    121122    <Compile Include="Operators\Crossovers\DoubleValue\NormalDoubleValueCrossover.cs" />
    122123    <Compile Include="Operators\Crossovers\IntValue\AverageIntValueCrossover.cs" />
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/AverageDoubleValueCrossover.cs

    r8574 r8590  
    5656    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
    5757      value.Value = (value.Value + other.Value) / 2;
    58       value.Value = range.ApplyStepSize(value.Value);
    5958    }
    6059  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/DiscreteDoubleValueCrossover.cs

    r8574 r8590  
    5555
    5656    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
    57       if (random.NextDouble() > 0.5) {
     57      if (random.NextDouble() > 0.5)
    5858        value.Value = other.Value;
    59       }
    6059    }
    6160  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/DoubleValue/NormalDoubleValueCrossover.cs

    r8574 r8590  
    5353
    5454    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);
    5656    }
    5757
    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;
    6162      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));
    6566
    66       return offspring;
     67      value.Value = offspring;
    6768    }
    6869  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/DiscreteIntValueCrossover.cs

    r8574 r8590  
    5555
    5656    public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) {
    57       if (random.NextDouble() > 0.5) {
     57      if (random.NextDouble() > 0.5)
    5858        value.Value = other.Value;
    59       }
    6059    }
    6160  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/MultiIntValueCrossover.cs

    r8574 r8590  
    6767
    6868    public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) {
    69       // TODO
     69      Operators[random.Next(Operators.Count)].Apply(random, value, other, range);
    7070    }
    7171  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/IntValue/NormalIntValueCrossover.cs

    r8574 r8590  
    5353
    5454    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);
    5656    }
    5757
    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;
    6162      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;
    6668    }
    6769  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Manipulators/IntValue/NormalIntValueManipulator.cs

    r8574 r8590  
    3636  [StorableClass]
    3737  public class NormalIntValueManipulator : SingleSuccessorOperator, IIntValueManipulator, IStochasticOperator {
    38 
    3938    public ILookupParameter<IRandom> RandomParameter {
    4039      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    5958    public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) {
    6059      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);
    6261      int val = value.Value;
    6362
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Manipulators/IntValue/UniformIntValueManipulator.cs

    r8574 r8590  
    3636  [StorableClass]
    3737  public class UniformIntValueManipulator : SingleSuccessorOperator, IIntValueManipulator, IStochasticOperator {
    38 
    3938    public ILookupParameter<IRandom> RandomParameter {
    4039      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    5857
    5958    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;
    6163      int val = value.Value;
    6264
    6365      do {
    6466        vector[0] = val;
    65         UniformOnePositionManipulator.Apply(random, vector, new IntMatrix(new int[,] { { range.LowerBound.Value, range.UpperBound.Value } }));
     67        UniformOnePositionManipulator.Apply(random, vector, bounds);
    6668        value.Value = vector[0];
    6769        value.Value = range.ApplyStepSize(value.Value);
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/ParameterConfiguration.cs

    r8574 r8590  
    9696    protected Type parameterDataType;
    9797    public Type ParameterDataType {
    98       get { return this.parameterDataType; }
     98      get { return parameterDataType; }
    9999    }
    100100
     
    103103      get { return validTypes; }
    104104      protected set {
    105         if (this.validTypes != value) {
    106           this.validTypes = value;
     105        if (validTypes != value) {
     106          validTypes = value;
    107107        }
    108108      }
     
    113113    public Type ValueDataType {
    114114      get { return valueDataType; }
    115       protected set { this.valueDataType = value; }
     115      protected set { valueDataType = value; }
    116116    }
    117117
     
    119119    protected ICheckedValueConfigurationList valueConfigurations;
    120120    public ICheckedValueConfigurationList ValueConfigurations {
    121       get { return this.valueConfigurations; }
     121      get { return valueConfigurations; }
    122122      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;
    126126          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;
    134134    public int ActualValueConfigurationIndex {
    135135      get { return actualValueConfigurationIndex; }
     
    155155      get { return isNullable; }
    156156      protected set {
    157         if (this.isNullable != value) {
    158           this.isNullable = value;
     157        if (isNullable != value) {
     158          isNullable = value;
    159159        }
    160160      }
     
    182182      get { return valuesReadOnly; }
    183183      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) {
    187187            vc.ValuesReadOnly = value;
    188188          }
Note: See TracChangeset for help on using the changeset viewer.