Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs @ 5219

Last change on this file since 5219 was 5209, checked in by epitzer, 14 years ago

Configurable ParticleUpdater, and topologies, different topology initializers and support for dynamic topology changes (#852)

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