[4839] | 1 | using HeuristicLab.Common;
|
---|
[4830] | 2 | using HeuristicLab.Core;
|
---|
| 3 | using HeuristicLab.Operators;
|
---|
[4839] | 4 | using HeuristicLab.Optimization;
|
---|
[4830] | 5 | using HeuristicLab.Parameters;
|
---|
[4839] | 6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[4830] | 7 |
|
---|
| 8 | namespace 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 | }
|
---|
[5009] | 22 | public ILookupParameter<ParameterConfigurationTree> InitialParameterConfigurationParameter {
|
---|
[5184] | 23 | get { return (ILookupParameter<ParameterConfigurationTree>)Parameters[MetaOptimizationProblem.ParameterConfigurationTreeParameterName]; }
|
---|
[4830] | 24 | }
|
---|
| 25 |
|
---|
[5184] | 26 | public IValueLookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
|
---|
| 27 | get { return (IValueLookupParameter<ParameterConfigurationTree>)Parameters["ParameterConfigurationTreeSolutionCandidate"]; }
|
---|
[4830] | 28 | }
|
---|
| 29 |
|
---|
| 30 | [StorableConstructor]
|
---|
| 31 | private RandomParameterConfigurationCreator(bool deserializing) : base(deserializing) { }
|
---|
| 32 | private RandomParameterConfigurationCreator(RandomParameterConfigurationCreator original, Cloner cloner) : base(original, cloner) { }
|
---|
[4997] | 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."));
|
---|
[5184] | 35 | Parameters.Add(new LookupParameter<ParameterConfigurationTree>(MetaOptimizationProblem.ParameterConfigurationTreeParameterName, "The parameter configuration tree on which the new solution will be based on."));
|
---|
| 36 | Parameters.Add(new ValueLookupParameter<ParameterConfigurationTree>("ParameterConfigurationTreeSolutionCandidate", "The new random parameter set."));
|
---|
[4830] | 37 | }
|
---|
| 38 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 39 | return new RandomParameterConfigurationCreator(this, cloner);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public override IOperation Apply() {
|
---|
[5009] | 43 | ParameterConfigurationParameter.ActualValue = (ParameterConfigurationTree)InitialParameterConfigurationParameter.ActualValue.Clone();
|
---|
| 44 | ParameterConfigurationParameter.ActualValue.Randomize(RandomParameter.ActualValue);
|
---|
[4830] | 45 | return base.Apply();
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | }
|
---|