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 |
|
---|
22 | using HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
26 | using HeuristicLab.Operators;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
|
---|
31 | [Item("ParticleUpdater", "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 ParticleUpdater : SingleSuccessorOperator, IParticleUpdater {
|
---|
34 | public override bool CanChangeName {
|
---|
35 | get { return false; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | #region Parameter properties
|
---|
39 | public ILookupParameter<IRandom> RandomParameter {
|
---|
40 | get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
|
---|
41 | }
|
---|
42 | public ILookupParameter<RealVector> PointParameter {
|
---|
43 | get { return (ILookupParameter<RealVector>)Parameters["Point"]; }
|
---|
44 | }
|
---|
45 | public ILookupParameter<RealVector> VelocityParameter {
|
---|
46 | get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
|
---|
47 | }
|
---|
48 | public ILookupParameter<RealVector> PersonalBestPointParameter {
|
---|
49 | get { return (ILookupParameter<RealVector>)Parameters["PersonalBestPoint"]; }
|
---|
50 | }
|
---|
51 | public ILookupParameter<RealVector> BestNeighborPointParameter {
|
---|
52 | get { return (ILookupParameter<RealVector>)Parameters["BestNeighborPoint"]; }
|
---|
53 | }
|
---|
54 | public ILookupParameter<RealVector> BestPointParameter {
|
---|
55 | get { return (ILookupParameter<RealVector>)Parameters["BestPoint"]; }
|
---|
56 | }
|
---|
57 | public ILookupParameter<DoubleMatrix> BoundsParameter {
|
---|
58 | get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
|
---|
59 | }
|
---|
60 | public ILookupParameter<DoubleMatrix> VelocityBoundsParameter {
|
---|
61 | get { return (ILookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
|
---|
62 | }
|
---|
63 | public ILookupParameter<DoubleValue> OmegaParameter {
|
---|
64 | get { return (ILookupParameter<DoubleValue>)Parameters["Omega"]; }
|
---|
65 | }
|
---|
66 | public ILookupParameter<DoubleValue> Phi_PParameter {
|
---|
67 | get { return (ILookupParameter<DoubleValue>)Parameters["Phi_P"]; }
|
---|
68 | }
|
---|
69 | public ILookupParameter<DoubleValue> Phi_GParameter {
|
---|
70 | get { return (ILookupParameter<DoubleValue>)Parameters["Phi_G"]; }
|
---|
71 | }
|
---|
72 | #endregion
|
---|
73 |
|
---|
74 | #region Parameter Values
|
---|
75 | protected IRandom Random {
|
---|
76 | get { return RandomParameter.ActualValue; }
|
---|
77 | }
|
---|
78 | protected RealVector Point {
|
---|
79 | get { return PointParameter.ActualValue; }
|
---|
80 | set { PointParameter.ActualValue = value; }
|
---|
81 | }
|
---|
82 | protected RealVector Velocity {
|
---|
83 | get { return VelocityParameter.ActualValue; }
|
---|
84 | set { VelocityParameter.ActualValue = value; }
|
---|
85 | }
|
---|
86 | protected RealVector PersonalBestPoint {
|
---|
87 | get { return PersonalBestPointParameter.ActualValue; }
|
---|
88 | }
|
---|
89 | protected RealVector BestPoint {
|
---|
90 | get { return BestPointParameter.ActualValue; }
|
---|
91 | }
|
---|
92 | protected RealVector BestNeighborPoint {
|
---|
93 | get { return BestNeighborPointParameter.ActualValue; }
|
---|
94 | }
|
---|
95 | protected DoubleMatrix Bounds {
|
---|
96 | get { return BoundsParameter.ActualValue; }
|
---|
97 | }
|
---|
98 | protected DoubleMatrix VelocityBounds {
|
---|
99 | get { return VelocityBoundsParameter.ActualValue; }
|
---|
100 | }
|
---|
101 | protected DoubleValue Omega {
|
---|
102 | get { return OmegaParameter.ActualValue; }
|
---|
103 | }
|
---|
104 | protected DoubleValue Phi_P {
|
---|
105 | get { return Phi_PParameter.ActualValue; }
|
---|
106 | }
|
---|
107 | protected DoubleValue Phi_G {
|
---|
108 | get { return Phi_GParameter.ActualValue; }
|
---|
109 | }
|
---|
110 | #endregion
|
---|
111 |
|
---|
112 | #region Construction & Cloning
|
---|
113 |
|
---|
114 | [StorableConstructor]
|
---|
115 | protected ParticleUpdater(bool deserializing) : base(deserializing) { }
|
---|
116 | protected ParticleUpdater(ParticleUpdater original, Cloner cloner) : base(original, cloner) { }
|
---|
117 | public ParticleUpdater()
|
---|
118 | : base() {
|
---|
119 | Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator."));
|
---|
120 | Parameters.Add(new LookupParameter<RealVector>("Point", "Particle's current position"));
|
---|
121 | Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
|
---|
122 | Parameters.Add(new LookupParameter<RealVector>("PersonalBestPoint", "Particle's personal best position"));
|
---|
123 | Parameters.Add(new LookupParameter<RealVector>("BestPoint", "Global best position"));
|
---|
124 | Parameters.Add(new LookupParameter<RealVector>("BestNeighborPoint", "Best neighboring position"));
|
---|
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>("Omega", "The weight for the particle's velocity vector."));
|
---|
128 | Parameters.Add(new LookupParameter<DoubleValue>("Phi_P", "The weight for the particle's personal best position."));
|
---|
129 | Parameters.Add(new LookupParameter<DoubleValue>("Phi_G", "The weight for the global best position."));
|
---|
130 | }
|
---|
131 |
|
---|
132 | #endregion
|
---|
133 | }
|
---|
134 | }
|
---|