Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Creators/RandomParameterSetCreator.cs @ 4525

Last change on this file since 4525 was 4525, checked in by cneumuel, 14 years ago

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

File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using HeuristicLab.Operators;
8using HeuristicLab.Parameters;
9using HeuristicLab.Common;
10
11namespace HeuristicLab.Problems.MetaOptimization {
12  /// <summary>
13  /// An operator which creates a new random permutation of integer values.
14  /// </summary>
15  [Item("RandomParameterSetCreator", "An operator which creates a new set of parameters TODO.")]
16  [StorableClass]
17  public sealed class RandomParameterSetCreator : SingleSuccessorOperator, IParameterSetCreator {
18    public override bool CanChangeName {
19      get { return false; }
20    }
21
22    public ILookupParameter<IRandom> RandomParameter {
23      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
24    }
25    public ILookupParameter<IParameterSet> ParameterSetParameter {
26      get { return (ILookupParameter<IParameterSet>)Parameters["ParameterSet"]; }
27    }
28
29    [Storable]
30    private ParameterConfigurationList parametersToOptimize;
31    public ParameterConfigurationList ParametersToOptimize {
32      get { return parametersToOptimize; }
33      set { parametersToOptimize = value; }
34    }
35
36    public RandomParameterSetCreator()
37      : base() {
38        Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
39        Parameters.Add(new LookupParameter<IParameterSet>("ParameterSet", "The new random parameter set."));
40    }
41
42    public override IOperation Apply() {
43      ParameterSetParameter.ActualValue = new ParameterSet(ParametersToOptimize, RandomParameter.ActualValue);
44      return base.Apply();
45    }
46
47    #region Cloning
48    public override IDeepCloneable Clone(Cloner cloner) {
49      RandomParameterSetCreator clone = (RandomParameterSetCreator) base.Clone(cloner);
50      clone.parametersToOptimize = (ParameterConfigurationList)this.parametersToOptimize.Clone();
51      return clone;
52    }
53    #endregion
54  }
55}
Note: See TracBrowser for help on using the repository browser.