Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/29/17 15:26:16 (7 years ago)
Author:
abeham
Message:

#2797:

  • Updated PSO to make it more compatible with SPSO 2011
  • Removed truncation of velocity vector and instead rescaled it given the maximum velocity
  • Added non-zero initial velocity according to SPSO 2011
  • Removed complicated bouncing code due to box constraints and instead implemented as described in SPSO 2011
  • Calculating neighbor best has been changed to use personal best
  • Avoiding local and global particle update and instead relying on neighborbest
  • More randomization during velocity update by using a separate random numbers per dimension
  • Reusing problem specific solution creator in RealVectorParticleCreator instead of always using UniformRandomRealVectorCreator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleCreator.cs

    r14185 r15091  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Operators;
     26using HeuristicLab.Optimization;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3031  [Item("RealVectorParticleCreator", "Creates a particle with position, zero velocity vector and personal best.")]
    3132  [StorableClass]
    32   public class RealVectorParticleCreator : AlgorithmOperator, IRealVectorParticleCreator {
     33  public class RealVectorParticleCreator : AlgorithmOperator, IRealVectorParticleCreator, IStochasticOperator {
    3334
    3435    #region Parameters
    35     public ILookupParameter<IntValue> ProblemSizeParameter {
    36       get { return (ILookupParameter<IntValue>)Parameters["ProblemSize"]; }
     36    public ILookupParameter<IRandom> RandomParameter {
     37      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    3738    }
    3839    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     
    4849      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
    4950    }
    50     #endregion
    51 
    52     #region Parameter Values
    53     protected int ProblemSize {
    54       get { return ProblemSizeParameter.ActualValue.Value; }
    55     }
    56     protected RealVector Velocity {
    57       set { VelocityParameter.ActualValue = value; }
     51    public ILookupParameter<ISolutionCreator> SolutionCreatorParameter {
     52      get { return (ILookupParameter<ISolutionCreator>)Parameters["SolutionCreator"]; }
    5853    }
    5954    #endregion
    60 
     55   
    6156    #region Construction & Cloning
    6257    [StorableConstructor]
     
    6560    public RealVectorParticleCreator()
    6661      : base() {
    67       Parameters.Add(new LookupParameter<IntValue>("ProblemSize", "The dimension of the problem."));
     62      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    6863      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension."));
    6964      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
    7065      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
    7166      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
     67      Parameters.Add(new LookupParameter<ISolutionCreator>("SolutionCreator", "The operator that creates the initial position."));
    7268
    73       UniformRandomRealVectorCreator realVectorCreater = new UniformRandomRealVectorCreator();
     69      Placeholder realVectorCreater = new Placeholder();
    7470      Assigner personalBestPositionAssigner = new Assigner();
     71      RealVectorVelocityInitializer velocityInitializer = new RealVectorVelocityInitializer();
    7572
    7673      OperatorGraph.InitialOperator = realVectorCreater;
    7774
    78       realVectorCreater.RealVectorParameter.ActualName = RealVectorParameter.Name;
    79       realVectorCreater.LengthParameter.ActualName = ProblemSizeParameter.Name;
    80       realVectorCreater.BoundsParameter.ActualName = BoundsParameter.Name;
     75      realVectorCreater.OperatorParameter.ActualName = SolutionCreatorParameter.Name;
    8176      realVectorCreater.Successor = personalBestPositionAssigner;
    8277
    8378      personalBestPositionAssigner.LeftSideParameter.ActualName = PersonalBestParameter.Name;
    8479      personalBestPositionAssigner.RightSideParameter.ActualName = RealVectorParameter.Name;
    85       personalBestPositionAssigner.Successor = null;
     80      personalBestPositionAssigner.Successor = velocityInitializer;
     81
     82      velocityInitializer.BoundsParameter.ActualName = BoundsParameter.Name;
     83      velocityInitializer.RandomParameter.ActualName = RandomParameter.Name;
     84      velocityInitializer.RealVectorParameter.ActualName = RealVectorParameter.Name;
     85      velocityInitializer.VelocityParameter.ActualName = VelocityParameter.Name;
     86      velocityInitializer.Successor = null;
    8687    }
    8788    public override IDeepCloneable Clone(Cloner cloner) {
     
    8990    }
    9091    #endregion
    91 
    92     public override IOperation Apply() {
    93       Velocity = new RealVector(ProblemSize);
    94       return base.Apply();
    95     }
    96 
    97 
    9892  }
    9993}
Note: See TracChangeset for help on using the changeset viewer.