Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs @ 15096

Last change on this file since 15096 was 15096, checked in by abeham, 7 years ago

#2797:

  • Added SPSO 2007 and SPSO 2011 particle updaters
  • Unhide particle updater parameter
  • Changed default parameters of sample
  • Changed max velocity to very high value by default (no speed limit)
  • Adapted unit test
File size: 4.7 KB
RevLine 
[5560]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5560]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
[15096]21 
[5560]22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
[15096]26using HeuristicLab.Optimization;
[5560]27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Encodings.RealVectorEncoding {
[5592]31
[5560]32  [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.")]
33  [StorableClass]
34  public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater {
[5592]35
[5560]36    public override bool CanChangeName {
37      get { return false; }
38    }
39
40    #region Parameter properties
41    public ILookupParameter<IRandom> RandomParameter {
42      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
43    }
44    public ILookupParameter<RealVector> VelocityParameter {
45      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
46    }
47    public ILookupParameter<RealVector> PersonalBestParameter {
[5566]48      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
[5560]49    }
[5568]50    public ILookupParameter<RealVector> NeighborBestParameter {
51      get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
[5560]52    }
53    public ILookupParameter<RealVector> RealVectorParameter {
54      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
55    }
56    public ILookupParameter<DoubleMatrix> BoundsParameter {
57      get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
58    }
[15091]59    public ILookupParameter<DoubleValue> CurrentMaxVelocityParameter {
60      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentMaxVelocity"]; }
[5560]61    }
[15096]62    public ILookupParameter<DoubleValue> CurrentInertiaParameter {
[5645]63      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
[5560]64    }
[15096]65    ILookupParameter<DoubleValue> IParticleUpdater.InertiaParameter { get { return CurrentInertiaParameter; } }
66
[5560]67    public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
68      get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
69    }
[5568]70    public ILookupParameter<DoubleValue> NeighborBestAttractionParameter {
71      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
[5560]72    }
73    #endregion
[15091]74   
[5560]75    #region Construction & Cloning
76    [StorableConstructor]
77    protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { }
78    protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { }
79    public RealVectorParticleUpdater()
80      : base() {
81      Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator."));
82      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
83      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
84      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
[5568]85      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
[5560]86      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
[15091]87      Parameters.Add(new LookupParameter<DoubleValue>("CurrentMaxVelocity", "Maximum for the particle's velocity vector."));
[5645]88      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
[5560]89      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
[5568]90      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
[5560]91    }
92    #endregion
93  }
94}
Note: See TracBrowser for help on using the repository browser.