#region License Information /* HeuristicLab * Copyright (C) 2002-2011 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.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Encodings.RealVectorEncoding { [Item("RealVectorParticleUpdater", "Updates a certain particle taking the current position and velocity into account, as well as the best point and the best point in a local neighborhood.")] [StorableClass] public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater { public override bool CanChangeName { get { return false; } } #region Parameter properties public ILookupParameter RandomParameter { get { return (ILookupParameter)Parameters["Random"]; } } public ILookupParameter VelocityParameter { get { return (ILookupParameter)Parameters["Velocity"]; } } public ILookupParameter PersonalBestParameter { get { return (ILookupParameter)Parameters["PersonalBestParameter"]; } } public ILookupParameter NeighborsBestParameter { get { return (ILookupParameter)Parameters["NeighborsBest"]; } } public ILookupParameter RealVectorParameter { get { return (ILookupParameter)Parameters["RealVector"]; } } public ILookupParameter BoundsParameter { get { return (ILookupParameter)Parameters["Bounds"]; } } public ILookupParameter VelocityBoundsParameter { get { return (ILookupParameter)Parameters["VelocityBounds"]; } } public ILookupParameter InertiaParameter { get { return (ILookupParameter)Parameters["Inertia"]; } } public ILookupParameter PersonalBestAttractionParameter { get { return (ILookupParameter)Parameters["PersonalBestAttraction"]; } } public ILookupParameter NeighborsBestAttractionParameter { get { return (ILookupParameter)Parameters["NeighborsBestAttraction"]; } } #endregion #region Parameter Values protected IRandom Random { get { return RandomParameter.ActualValue; } } protected RealVector Velocity { get { return VelocityParameter.ActualValue; } set { VelocityParameter.ActualValue = value; } } protected RealVector PersonalBest { get { return PersonalBestParameter.ActualValue; } } protected RealVector RealVector { get { return RealVectorParameter.ActualValue; } set { RealVectorParameter.ActualValue = value; } } protected RealVector NeighborsBest { get { return NeighborsBestParameter.ActualValue; } } protected DoubleMatrix Bounds { get { return BoundsParameter.ActualValue; } } protected DoubleMatrix VelocityBounds { get { return VelocityBoundsParameter.ActualValue; } } protected DoubleValue Inertia { get { return InertiaParameter.ActualValue; } } protected DoubleValue PersonalBestAttraction { get { return PersonalBestAttractionParameter.ActualValue; } } protected DoubleValue NeighborsBestAttraction { get { return NeighborsBestAttractionParameter.ActualValue; } } #endregion #region Construction & Cloning [StorableConstructor] protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { } protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { } public RealVectorParticleUpdater() : base() { Parameters.Add(new LookupParameter("Random", "Random number generator.")); Parameters.Add(new LookupParameter("RealVector", "Particle's current solution")); Parameters.Add(new LookupParameter("Velocity", "Particle's current velocity.")); Parameters.Add(new LookupParameter("PersonalBest", "Particle's personal best solution.")); Parameters.Add(new LookupParameter("BestPoint", "Global best position.")); Parameters.Add(new LookupParameter("NeighborsBest", "Best neighboring solution.")); Parameters.Add(new LookupParameter("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem.")); Parameters.Add(new LookupParameter("VelocityBounds", "Upper and lower bounds for the particle's velocity vector.")); Parameters.Add(new LookupParameter("Inertia", "The weight for the particle's velocity vector.")); Parameters.Add(new LookupParameter("PersonalBestAttraction", "The weight for the particle's personal best position.")); Parameters.Add(new LookupParameter("NeighborsBestAttraction", "The weight for the global best position.")); } #endregion } }