Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5568 was 5568, checked in by epitzer, 12 years ago

Continue working on SwarmUpdater (#852)

File size: 6.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Encodings.RealVectorEncoding {
30  [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.")]
31  [StorableClass]
32  public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater {
33    public override bool CanChangeName {
34      get { return false; }
35    }
36
37    #region Parameter properties
38    public ILookupParameter<IRandom> RandomParameter {
39      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
40    }
41    public ILookupParameter<RealVector> VelocityParameter {
42      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
43    }
44    public ILookupParameter<RealVector> PersonalBestParameter {
45      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
46    }
47    public ILookupParameter<RealVector> NeighborBestParameter {
48      get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
49    }
50    public LookupParameter<RealVector> BestPointParameter {
51      get { return (LookupParameter<RealVector>)Parameters["BestPoint"]; }
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<DoubleMatrix> VelocityBoundsParameter {
60      get { return (ILookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
61    }
62    public ILookupParameter<DoubleValue> InertiaParameter {
63      get { return (ILookupParameter<DoubleValue>)Parameters["Inertia"]; }
64    }
65    public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
66      get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
67    }
68    public ILookupParameter<DoubleValue> NeighborBestAttractionParameter {
69      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
70    }
71    #endregion
72
73    #region Parameter Values
74    protected IRandom Random {
75      get { return RandomParameter.ActualValue; }
76    }
77    protected RealVector Velocity {
78      get { return VelocityParameter.ActualValue; }
79      set { VelocityParameter.ActualValue = value; }
80    }
81    protected RealVector PersonalBest {
82      get { return PersonalBestParameter.ActualValue; }
83    }
84    protected RealVector BestPoint {
85      get { return BestPointParameter.ActualValue; }
86    }
87    protected RealVector RealVector {
88      get { return RealVectorParameter.ActualValue; }
89      set { RealVectorParameter.ActualValue = value; }
90    }
91    protected RealVector NeighborBest {
92      get { return NeighborBestParameter.ActualValue; }
93    }
94    protected DoubleMatrix Bounds {
95      get { return BoundsParameter.ActualValue; }
96    }
97    protected DoubleMatrix VelocityBounds {
98      get { return VelocityBoundsParameter.ActualValue; }
99    }
100    protected DoubleValue Inertia {
101      get { return InertiaParameter.ActualValue; }
102    }
103    protected DoubleValue PersonalBestAttraction {
104      get { return PersonalBestAttractionParameter.ActualValue; }
105    }
106    protected DoubleValue NeighborBestAttraction {
107      get { return NeighborBestAttractionParameter.ActualValue; }
108    }
109    #endregion
110
111    #region Construction & Cloning
112
113    [StorableConstructor]
114    protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { }
115    protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { }
116
117    public RealVectorParticleUpdater()
118      : base() {
119      Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator."));
120      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
121      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
122      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
123      Parameters.Add(new LookupParameter<RealVector>("BestPoint", "Global best position."));
124      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
125      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
126      Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
127      Parameters.Add(new LookupParameter<DoubleValue>("Inertia", "The weight for the particle's velocity vector."));
128      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
129      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
130    }
131
132    #endregion
133  }
134}
Note: See TracBrowser for help on using the repository browser.