Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/11 16:34:11 (14 years ago)
Author:
epitzer
Message:

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

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs

    r5208 r5209  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Encodings.RealVectorEncoding;
    26 using HeuristicLab.Operators;
    27 using HeuristicLab.Parameters;
    2825using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2926
     
    3128
    3229  [StorableClass]
    33   public class ParticleUpdater : SingleSuccessorOperator {
    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> BestPointParameter {
    49       get { return (LookupParameter<RealVector>)Parameters["BestPoint"]; }
    50     }
    51     public LookupParameter<DoubleMatrix> BoundsParameter {
    52       get { return (LookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    53     }
    54     public LookupParameter<DoubleMatrix> VelocityBoundsParameter {
    55       get { return (LookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
    56     }
    57     public LookupParameter<DoubleValue> OmegaParameter {
    58       get { return (LookupParameter<DoubleValue>)Parameters["Omega"]; }
    59     }
    60     public LookupParameter<DoubleValue> Phi_PParameter {
    61       get { return (LookupParameter<DoubleValue>)Parameters["Phi_P"]; }
    62     }
    63     public LookupParameter<DoubleValue> Phi_GParameter {
    64       get { return (LookupParameter<DoubleValue>)Parameters["Phi_G"]; }
    65     }
    66     #endregion
    67 
    68     #region Parameter Values
    69     public IRandom Random {
    70       get { return RandomParameter.ActualValue; }
    71     }
    72     public RealVector Point {
    73       get { return PointParameter.ActualValue; }
    74       set { PointParameter.ActualValue = value; }
    75     }
    76     public RealVector Velocity {
    77       get { return VelocityParameter.ActualValue; }
    78       set { VelocityParameter.ActualValue = value; }
    79     }
    80     public RealVector PersonalBestPoint {
    81       get { return PersonalBestPointParameter.ActualValue; }
    82     }
    83     public RealVector BestPoint {
    84       get { return BestPointParameter.ActualValue; }
    85     }
    86     public DoubleMatrix Bounds {
    87       get { return BoundsParameter.ActualValue; }
    88     }
    89     public DoubleMatrix VelocityBounds {
    90       get { return VelocityBoundsParameter.ActualValue; }
    91     }
    92     public double Omega {
    93       get { return OmegaParameter.ActualValue.Value; }
    94     }
    95     public double Phi_P {
    96       get { return Phi_PParameter.ActualValue.Value; }
    97     }
    98     public double Phi_G {
    99       get { return Phi_GParameter.ActualValue.Value; }
    100     }
    101     #endregion
     30  public class NeighborhoodParticleUpdater : ParticleUpdater {
    10231
    10332    #region Construction & Cloning
    10433
    10534    [StorableConstructor]
    106     protected ParticleUpdater(bool deserializing) : base(deserializing) { }
    107     protected ParticleUpdater(ParticleUpdater original, Cloner cloner)
    108       : base(original, cloner) {
    109     }
    110 
    111     public ParticleUpdater()
    112       : base() {
    113       Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator."));
    114       Parameters.Add(new LookupParameter<RealVector>("Point", "Particle's current position"));
    115       Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
    116       Parameters.Add(new LookupParameter<RealVector>("PersonalBestPoint", "Particle's personal best position"));
    117       Parameters.Add(new LookupParameter<RealVector>("BestPoint", "Global best position"));
    118       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
    119       Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
    120       Parameters.Add(new LookupParameter<DoubleValue>("Omega", "The weight for the particle's velocity vector."));
    121       Parameters.Add(new LookupParameter<DoubleValue>("Phi_P", "The weight for the particle's personal best position."));
    122       Parameters.Add(new LookupParameter<DoubleValue>("Phi_G", "The weight for the global best position."));
    123     }
     35    protected NeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
     36    protected NeighborhoodParticleUpdater(ParticleUpdater original, Cloner cloner) : base(original, cloner) { }
     37    public NeighborhoodParticleUpdater() : base() { }
    12438
    12539    public override IDeepCloneable Clone(Cloner cloner) {
    126       return new ParticleUpdater(this, cloner);
     40      return new NeighborhoodParticleUpdater(this, cloner);
    12741    }
    12842
     
    13852          Velocity[i] * Omega +
    13953          (PersonalBestPoint[i] - Point[i]) * Phi_P * r_p +
    140           (BestPoint[i] - Point[i]) * Phi_G * r_g;
     54          (BestNeighborPoint[i] - Point[i]) * Phi_G * r_g;
    14155      }
    14256      BoundsChecker.Apply(velocity, VelocityBounds);
     
    15064      return base.Apply();
    15165    }
    152 
    153     public override bool CanChangeName {
    154       get { return false; }
    155     }
    15666  }
    15767}
Note: See TracChangeset for help on using the changeset viewer.