Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Creators/RandomParameterConfigurationCreator.cs @ 16574

Last change on this file since 16574 was 16574, checked in by gkronber, 5 years ago

#2520: changed HeuristicLab.MetaOptimization addon to compile with new HL.Persistence

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