#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Operators;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
///
/// A base class for operators creating combined int-valued vectors.
///
[Item("CombinedIntegerVectorCreator", "A base class for operators creating combined int-valued vectors.")]
[StorableClass]
public abstract class CombinedIntegerVectorCreator : SingleSuccessorOperator, IStochasticOperator, ICombinedIntegerVectorCreator {
public override bool CanChangeName {
get { return false; }
}
public ILookupParameter RandomParameter {
get { return (LookupParameter)Parameters["Random"]; }
}
public IValueLookupParameter ProblemDataParameter {
get { return (IValueLookupParameter)Parameters["ProblemData"]; }
}
public ILookupParameter CombinedIntegerVectorParameter {
get { return (ILookupParameter)Parameters["CombinedIntegerVector"]; }
}
protected ICombinedIntegerVectorClassificationProblemData ProblemData {
get { return ProblemDataParameter.ActualValue; }
}
[StorableConstructor]
protected CombinedIntegerVectorCreator(bool deserializing) : base(deserializing) { }
protected CombinedIntegerVectorCreator(CombinedIntegerVectorCreator original, Cloner cloner) : base(original, cloner) { }
protected CombinedIntegerVectorCreator()
: base() {
Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
Parameters.Add(new ValueLookupParameter("ProblemData", ""));
Parameters.Add(new LookupParameter("CombinedIntegerVector", "The vector which should be manipulated."));
}
public sealed override IOperation Apply() {
CombinedIntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, ProblemData.LengthParameter.Value, ProblemData.BoundsParameter.Value, ProblemData.ActionLengthParameter.Value);
return base.Apply();
}
protected abstract CombinedIntegerVector Create(IRandom random, IntValue length, IntMatrix bounds, IntValue actionPartLength);
}
}