1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.Operators;
|
---|
4 | using HeuristicLab.Optimization;
|
---|
5 | using HeuristicLab.Parameters;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 | using HEAL.Attic;
|
---|
8 |
|
---|
9 | namespace 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 | }
|
---|