using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.MetaOptimization { /// /// An operator which creates a new random permutation of integer values. /// [Item("RandomParameterVectorCreator", "An operator which creates a new set of parameters TODO.")] [StorableClass] public sealed class RandomParameterConfigurationCreator : SingleSuccessorOperator, IStochasticOperator, IParameterConfigurationCreator { public override bool CanChangeName { get { return false; } } public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public ILookupParameter InitialParameterConfigurationParameter { get { return (ILookupParameter)Parameters[MetaOptimizationProblem.ParameterConfigurationTreeParameterName]; } } public IValueLookupParameter ParameterConfigurationParameter { get { return (IValueLookupParameter)Parameters["ParameterConfigurationTreeSolutionCandidate"]; } } [StorableConstructor] private RandomParameterConfigurationCreator(bool deserializing) : base(deserializing) { } private RandomParameterConfigurationCreator(RandomParameterConfigurationCreator original, Cloner cloner) : base(original, cloner) { } public RandomParameterConfigurationCreator() : base() { Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used to initialize the new random permutation.")); Parameters.Add(new LookupParameter(MetaOptimizationProblem.ParameterConfigurationTreeParameterName, "The parameter configuration tree on which the new solution will be based on.")); Parameters.Add(new ValueLookupParameter("ParameterConfigurationTreeSolutionCandidate", "The new random parameter set.")); } public override IDeepCloneable Clone(Cloner cloner) { return new RandomParameterConfigurationCreator(this, cloner); } public override IOperation Apply() { ParameterConfigurationParameter.ActualValue = (ParameterConfigurationTree)InitialParameterConfigurationParameter.ActualValue.Clone(); ParameterConfigurationParameter.ActualValue.Randomize(RandomParameter.ActualValue); return base.Apply(); } } }