[5560] | 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.Operators;
|
---|
| 26 | using HeuristicLab.Parameters;
|
---|
| 27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Encodings.RealVectorEncoding {
|
---|
[5592] | 30 |
|
---|
[5560] | 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 {
|
---|
[5592] | 34 |
|
---|
[5560] | 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 {
|
---|
[5566] | 47 | get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
|
---|
[5560] | 48 | }
|
---|
[5568] | 49 | public ILookupParameter<RealVector> NeighborBestParameter {
|
---|
| 50 | get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
|
---|
[5560] | 51 | }
|
---|
[5643] | 52 | public LookupParameter<RealVector> BestRealVectorParameter {
|
---|
| 53 | get { return (LookupParameter<RealVector>)Parameters["BestRealVector"]; }
|
---|
[5568] | 54 | }
|
---|
[5560] | 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 | }
|
---|
[5866] | 61 | public ILookupParameter<DoubleMatrix> CurrentVelocityBoundsParameter {
|
---|
| 62 | get { return (ILookupParameter<DoubleMatrix>)Parameters["CurrentVelocityBounds"]; }
|
---|
[5560] | 63 | }
|
---|
| 64 | public ILookupParameter<DoubleValue> InertiaParameter {
|
---|
[5645] | 65 | get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
|
---|
[5560] | 66 | }
|
---|
| 67 | public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
|
---|
| 68 | get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
|
---|
| 69 | }
|
---|
[5568] | 70 | public ILookupParameter<DoubleValue> NeighborBestAttractionParameter {
|
---|
| 71 | get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
|
---|
[5560] | 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 | }
|
---|
[5568] | 86 | protected RealVector BestPoint {
|
---|
[5643] | 87 | get { return BestRealVectorParameter.ActualValue; }
|
---|
[5568] | 88 | }
|
---|
[5560] | 89 | protected RealVector RealVector {
|
---|
| 90 | get { return RealVectorParameter.ActualValue; }
|
---|
| 91 | set { RealVectorParameter.ActualValue = value; }
|
---|
| 92 | }
|
---|
[5568] | 93 | protected RealVector NeighborBest {
|
---|
| 94 | get { return NeighborBestParameter.ActualValue; }
|
---|
[5560] | 95 | }
|
---|
| 96 | protected DoubleMatrix Bounds {
|
---|
| 97 | get { return BoundsParameter.ActualValue; }
|
---|
| 98 | }
|
---|
[5866] | 99 | protected DoubleMatrix CurrentVelocityBounds {
|
---|
| 100 | get { return CurrentVelocityBoundsParameter.ActualValue; }
|
---|
[5560] | 101 | }
|
---|
| 102 | protected DoubleValue Inertia {
|
---|
| 103 | get { return InertiaParameter.ActualValue; }
|
---|
| 104 | }
|
---|
| 105 | protected DoubleValue PersonalBestAttraction {
|
---|
| 106 | get { return PersonalBestAttractionParameter.ActualValue; }
|
---|
| 107 | }
|
---|
[5568] | 108 | protected DoubleValue NeighborBestAttraction {
|
---|
| 109 | get { return NeighborBestAttractionParameter.ActualValue; }
|
---|
[5560] | 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."));
|
---|
[5643] | 123 | Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best position."));
|
---|
[5568] | 124 | Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
|
---|
[5560] | 125 | Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
|
---|
[5866] | 126 | Parameters.Add(new LookupParameter<DoubleMatrix>("CurrentVelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
|
---|
[5645] | 127 | Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
|
---|
[5560] | 128 | Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
|
---|
[5568] | 129 | Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
|
---|
[5560] | 130 | }
|
---|
| 131 | #endregion
|
---|
| 132 | }
|
---|
| 133 | }
|
---|