Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5681 was 5645, checked in by epitzer, 14 years ago

Set CurrentInertia inside operator graph and make sure all operators use it
Set default end value to epsilon instead of zero (#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
31  [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.")]
32  [StorableClass]
33  public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater {
34
35    public override bool CanChangeName {
36      get { return false; }
37    }
38
39    #region Parameter properties
40    public ILookupParameter<IRandom> RandomParameter {
41      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
42    }
43    public ILookupParameter<RealVector> VelocityParameter {
44      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
45    }
46    public ILookupParameter<RealVector> PersonalBestParameter {
47      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
48    }
49    public ILookupParameter<RealVector> NeighborBestParameter {
50      get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
51    }
52    public LookupParameter<RealVector> BestRealVectorParameter {
53      get { return (LookupParameter<RealVector>)Parameters["BestRealVector"]; }
54    }
55    public ILookupParameter<RealVector> RealVectorParameter {
56      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
57    }
58    public ILookupParameter<DoubleMatrix> BoundsParameter {
59      get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
60    }
61    public ILookupParameter<DoubleMatrix> VelocityBoundsParameter {
62      get { return (ILookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
63    }
64    public ILookupParameter<DoubleValue> InertiaParameter {
65      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
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 Parameter Values
76    protected IRandom Random {
77      get { return RandomParameter.ActualValue; }
78    }
79    protected RealVector Velocity {
80      get { return VelocityParameter.ActualValue; }
81      set { VelocityParameter.ActualValue = value; }
82    }
83    protected RealVector PersonalBest {
84      get { return PersonalBestParameter.ActualValue; }
85    }
86    protected RealVector BestPoint {
87      get { return BestRealVectorParameter.ActualValue; }
88    }
89    protected RealVector RealVector {
90      get { return RealVectorParameter.ActualValue; }
91      set { RealVectorParameter.ActualValue = value; }
92    }
93    protected RealVector NeighborBest {
94      get { return NeighborBestParameter.ActualValue; }
95    }
96    protected DoubleMatrix Bounds {
97      get { return BoundsParameter.ActualValue; }
98    }
99    protected DoubleMatrix VelocityBounds {
100      get { return VelocityBoundsParameter.ActualValue; }
101    }
102    protected DoubleValue Inertia {
103      get { return InertiaParameter.ActualValue; }
104    }
105    protected DoubleValue PersonalBestAttraction {
106      get { return PersonalBestAttractionParameter.ActualValue; }
107    }
108    protected DoubleValue NeighborBestAttraction {
109      get { return NeighborBestAttractionParameter.ActualValue; }
110    }
111    #endregion
112
113    #region Construction & Cloning
114    [StorableConstructor]
115    protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { }
116    protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { }
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>("BestRealVector", "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>("CurrentInertia", "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    #endregion
132  }
133}
Note: See TracBrowser for help on using the repository browser.