#region License Information
/* HeuristicLab
* Copyright (C) 2002-2010 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.Encodings.RealVectorEncoding;
using HeuristicLab.Operators;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Problems.TestFunctions {
public class RealVectorToRealVectorEncoder : SingleSuccessorOperator, IRealVectorPSOEncoder, IRealVectorOperator {
#region Parameters
public IParameter OriginalRealVectorParameter {
get { return (IParameter)Parameters["OriginalRealVector"]; }
}
public IParameter RealVectorParameter {
get { return (IParameter)Parameters["RealVector"]; }
}
public ILookupParameter LengthParameter {
get { return (ILookupParameter)Parameters["Length"]; }
}
public IValueLookupParameter BoundsParameter {
get { return (IValueLookupParameter)Parameters["Bounds"]; }
}
protected ScopeParameter CurrentScopeParameter {
get { return (ScopeParameter)Parameters["CurrentScope"]; }
}
#endregion
public IScope CurrentScope {
get { return CurrentScopeParameter.ActualValue; }
}
[StorableConstructor]
protected RealVectorToRealVectorEncoder(bool deserializing) : base(deserializing) { }
protected RealVectorToRealVectorEncoder(RealVectorToRealVectorEncoder original, Cloner cloner) : base(original, cloner) { }
public RealVectorToRealVectorEncoder()
: base() {
Parameters.Add(new LookupParameter("OriginalRealVector", "The original real vector."));
Parameters.Add(new LookupParameter("RealVector", "The resulting reference to the original real vector."));
Parameters.Add(new LookupParameter("Length", "Vector length."));
Parameters.Add(new ScopeParameter("CurrentScope", "The current scope bounds matrix should be cloned."));
Parameters.Add(new ValueLookupParameter("Bounds", "The lower and upper bounds in each dimension."));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new RealVectorToRealVectorEncoder(this, cloner);
}
public override IOperation Apply() {
RealVectorParameter.ActualValue = OriginalRealVectorParameter.ActualValue;
IItem value = (IItem)BoundsParameter.ActualValue.Clone();
CurrentScope.Variables.Add(new Variable("ParticleBounds", BoundsParameter.Description, value == null ? null : (IItem)value.Clone()));
return base.Apply();
}
public override bool CanChangeName {
get { return false; }
}
}
}