Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/27/10 17:38:55 (14 years ago)
Author:
cneumuel
Message:

implemented basic crossover operator for ParameterSets. MetaOptimization is now functional on a basic level (Configuration and Crossing only works for IntValue Parameters) (#1215)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/NumericParameterConfiguration.cs

    r4516 r4525  
    66using HeuristicLab.Core;
    77using HeuristicLab.Collections;
     8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    89
    910namespace HeuristicLab.Problems.MetaOptimization {
     11  [StorableClass]
    1012  public class NumericParameterConfiguration : ParameterConfiguration {
     13    [Storable]
    1114    private NumericRangeList ranges;
    1215    public NumericRangeList Ranges {
     
    1518
    1619    protected NumericParameterConfiguration() { }
     20   
     21    [StorableConstructor]
     22    protected NumericParameterConfiguration(bool deserializing) : base(deserializing) { }
     23
    1724    public NumericParameterConfiguration(IParameter parameter, string category)
    1825      : base(parameter, category) {
     
    2229      this.ranges.CollectionReset += new CollectionItemsChangedEventHandler<INumericRange>(ranges_CollectionReset);
    2330    }
     31
     32
    2433
    2534    void ranges_CollectionReset(object sender, CollectionItemsChangedEventArgs<INumericRange> e) {
     
    5564    }
    5665
     66    #region Cloning
    5767    public override Common.IDeepCloneable Clone(Common.Cloner cloner) {
    5868      NumericParameterConfiguration clone = (NumericParameterConfiguration)base.Clone(cloner);
     
    6373      return clone;
    6474    }
     75    #endregion
    6576
    6677    void range_ToStringChanged(object sender, EventArgs e) {
     
    7283    }
    7384
    74     public override IParameter GetParameterWithRandomValue(IRandom random) {
     85    public override void SetParameterWithRandomValue(IRandom random) {
    7586      int rangeIndex = random.Next(ranges.Count);
    7687      int value = random.Next(ranges.ElementAt(rangeIndex).LowerBound.Value, ranges.ElementAt(rangeIndex).UpperBound.Value); // TODO: respect StepSize parameter
    77       IParameter clone = (IParameter)this.Parameter.Clone();
    78       clone.ActualValue = new IntValue(value);
    79       return clone;
     88      this.Parameter.ActualValue = new IntValue(value);
    8089    }
    8190  }
Note: See TracChangeset for help on using the changeset viewer.