Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Creators/RandomParameterConfigurationCreator.cs @ 4997

Last change on this file since 4997 was 4997, checked in by cneumuel, 13 years ago

#1215 worked on metaoptimization

File size: 2.3 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Operators;
4using HeuristicLab.Optimization;
5using HeuristicLab.Parameters;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Problems.MetaOptimization {
9  /// <summary>
10  /// An operator which creates a new random permutation of integer values.
11  /// </summary>
12  [Item("RandomParameterVectorCreator", "An operator which creates a new set of parameters TODO.")]
13  [StorableClass]
14  public sealed class RandomParameterConfigurationCreator : SingleSuccessorOperator, IStochasticOperator, IParameterConfigurationCreator {
15    public override bool CanChangeName {
16      get { return false; }
17    }
18
19    public ILookupParameter<IRandom> RandomParameter {
20      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
21    }
22    public ILookupParameter<IValueConfiguration> ValueConfigurationParameter {
23      get { return (ILookupParameter<IValueConfiguration>)Parameters["ValueConfiguration"]; }
24    }
25
26    public ILookupParameter<IValueConfiguration> NewValueConfigurationParameter {
27      get { return (ILookupParameter<IValueConfiguration>)Parameters["NewValueConfiguration"]; }
28    }
29
30    [StorableConstructor]
31    private RandomParameterConfigurationCreator(bool deserializing) : base(deserializing) { }
32    private RandomParameterConfigurationCreator(RandomParameterConfigurationCreator original, Cloner cloner) : base(original, cloner) { }
33    public RandomParameterConfigurationCreator() : base() {
34      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
35      Parameters.Add(new LookupParameter<IValueConfiguration>("ValueConfiguration", "The new random parameter set."));
36    }
37    public override IDeepCloneable Clone(Cloner cloner) {
38      return new RandomParameterConfigurationCreator(this, cloner);
39    }
40
41    public override IOperation Apply() {
42      NewValueConfigurationParameter.ActualValue = (IValueConfiguration)ValueConfigurationParameter.ActualValue.Clone();
43      NewValueConfigurationParameter.ActualValue.Randomize();
44      NewValueConfigurationParameter.ActualValue.Parameterize();
45      return base.Apply();
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.