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, 2 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
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
21 
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Encodings.RealVectorEncoding {
31
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 {
35
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 {
48      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
49    }
50    public ILookupParameter<RealVector> NeighborBestParameter {
51      get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
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    }
59    public ILookupParameter<DoubleValue> CurrentMaxVelocityParameter {
60      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentMaxVelocity"]; }
61    }
62    public ILookupParameter<DoubleValue> CurrentInertiaParameter {
63      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
64    }
65    ILookupParameter<DoubleValue> IParticleUpdater.InertiaParameter { get { return CurrentInertiaParameter; } }
66
67    public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
68      get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
69    }
70    public ILookupParameter<DoubleValue> NeighborBestAttractionParameter {
71      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
72    }
73    #endregion
74   
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."));
85      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
86      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
87      Parameters.Add(new LookupParameter<DoubleValue>("CurrentMaxVelocity", "Maximum for the particle's velocity vector."));
88      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
89      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
90      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
91    }
92    #endregion
93  }
94}
Note: See TracBrowser for help on using the repository browser.