Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5435


Ignore:
Timestamp:
02/04/11 21:34:45 (14 years ago)
Author:
abeham
Message:

#852

  • Made public properties that redirect to ActualValue.Value private or protected
  • Sealed all of the specific operators
  • Removed files that are present in the repository, but are not included in the project
  • Removed .sln file (is this still needed?)
  • Added license headers to some files
  • Unified the pattern for writing the constructors similar to other files in the trunk
  • Corrected assembly and plugin version from 3.3.0.x to 3.3.2.x
  • Fixed the wiring in the VelocityBoundsModifier
Location:
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
Files:
4 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/BestPointInitializer.cs

    r5410 r5435  
    3030
    3131namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    32 
    3332  [Item("Best Point Initializer", "Determines the best quality and point of the current particle population.")]
    3433  [StorableClass]
    35   public class BestPointInitializer : SingleSuccessorOperator {
     34  public sealed class BestPointInitializer : SingleSuccessorOperator {
     35    public override bool CanChangeName {
     36      get { return false; }
     37    }
    3638
    3739    #region Parameter properties
     
    5456
    5557    #region Parameter values
    56     public ItemArray<DoubleValue> Quality {
     58    private ItemArray<DoubleValue> Quality {
    5759      get { return QualityParameter.ActualValue; }
    5860    }
    59     public double BestQuality {
     61    private double BestQuality {
    6062      get { return BestQualityParameter.ActualValue.Value; }
    6163      set { BestQualityParameter.ActualValue = new DoubleValue(value); }
    6264    }
    63     public ItemArray<RealVector> Point {
     65    private ItemArray<RealVector> Point {
    6466      get { return PointParameter.ActualValue; }
    6567    }
    66     public RealVector BestPoint {
     68    private RealVector BestPoint {
    6769      get { return BestPointParameter.ActualValue; }
    6870      set { BestPointParameter.ActualValue = value; }
    6971    }
    70     public bool Maximization {
     72    private bool Maximization {
    7173      get { return MaximizationParameter.ActualValue.Value; }
    7274    }
     
    7678
    7779    [StorableConstructor]
    78     protected BestPointInitializer(bool deserializing) : base(deserializing) { }
    79     protected BestPointInitializer(BestPointInitializer original, Cloner cloner)
    80       : base(original, cloner) {
    81     }
    82 
     80    private BestPointInitializer(bool deserializing) : base(deserializing) { }
     81    private BestPointInitializer(BestPointInitializer original, Cloner cloner) : base(original, cloner) { }
    8382    public BestPointInitializer()
    8483      : base() {
     
    102101      return base.Apply();
    103102    }
    104 
    105     public override bool CanChangeName {
    106       get { return false; }
    107     }
    108103  }
    109104}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLabAlgorithmsParticleSwarmOptimizationPlugin.cs.frame

    r5426 r5435  
    2626  /// Plugin class for HeuristicLab.Algorithms.ParticleSwarmOptimization plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.0.$WCREV$")]
     28  [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.2.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IDiscreteDoubleMatrixModifier.cs

    r5316 r5435  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     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
    522using HeuristicLab.Core;
    623using HeuristicLab.Data;
     
    926
    1027namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    11 
    1228  public interface IDiscreteDoubleMatrixModifier : IItem {
    1329    ILookupParameter<DoubleMatrix> ValueParameter { get; }
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IGlobalParticleUpdater.cs

    r5342 r5435  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     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
    521
    622namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ILocalParticleUpdater.cs

    r5342 r5435  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     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
    521
    622namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IParticleUpdater.cs

    r5410 r5435  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.Encodings.RealVectorEncoding;
    25 using HeuristicLab.Parameters;
    2625
    2726namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    28 
    2927  public interface IParticleUpdater : IOperator {
    3028
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyInitializer.cs

    r5410 r5435  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.Encodings.IntegerVectorEncoding;
    25 using HeuristicLab.Parameters;
     25
    2626namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    27 
    2827  public interface ITopologyInitializer : IOperator {
    2928    IScopeTreeLookupParameter<IntegerVector> NeighborsParameter { get; }
    3029    ILookupParameter<IntValue> SwarmSizeParameter { get; }
    3130  }
    32 
    3331}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyUpdater.cs

    r5410 r5435  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.IntegerVectorEncoding;
    24 using HeuristicLab.Parameters;
     24
    2525namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    26 
    27   public interface ITopologyUpdater : IItem {
     26  public interface ITopologyUpdater : IOperator {
    2827    IScopeTreeLookupParameter<IntegerVector> NeighborsParameter { get; }
    2928  }
    30 
    3129}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/MultiPSOTopologyUpdater.cs

    r5410 r5435  
    1 using System;
     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
    222using System.Collections.Generic;
    323using System.Linq;
    4 using System.Text;
     24using HeuristicLab.Common;
    525using HeuristicLab.Core;
     26using HeuristicLab.Data;
     27using HeuristicLab.Encodings.IntegerVectorEncoding;
     28using HeuristicLab.Operators;
     29using HeuristicLab.Parameters;
    630using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    7 using HeuristicLab.Operators;
    8 using HeuristicLab.Common;
    9 using HeuristicLab.Parameters;
    10 using HeuristicLab.Encodings.IntegerVectorEncoding;
    11 using HeuristicLab.Data;
    1231
    1332namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    14   [Item("Multi PSO Topology Initializer/Updater", "Splits swarm into swarmsize / (nrOfConnections + 1) non-overlapping sub-swarms. Swarms are re-grouped every regroupingPeriod iteration. The operator is implemented as described in Liang, J.J. and Suganthan, P.N 2005. Dynamic multi-swarm particle swarm optimizer. IEEE Swarm Intelligence Symposium, pp. 124-129")]
     33  [Item("Multi PSO Topology Initializer/Updater", "Splits swarm into swarmsize / (nrOfConnections + 1) non-overlapping sub-swarms. Swarms are re-grouped every regroupingPeriod iteration. The operator is implemented as described in Liang, J.J. and Suganthan, P.N 2005. Dynamic multi-swarm particle swarm optimizer. IEEE Swarm Intelligence Symposium, pp. 124-129.")]
    1534  [StorableClass]
    16   public class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, ITopologyInitializer {
     35  public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, ITopologyInitializer {
     36    public override bool CanChangeName {
     37      get { return false; }
     38    }
     39
    1740    #region Parameters
    1841    public ILookupParameter<IRandom> RandomParameter {
     
    3760
    3861    #region Parameter Values
    39     public IRandom Random {
     62    private IRandom Random {
    4063      get { return RandomParameter.ActualValue; }
    4164    }
    42     public int NrOfConnections {
     65    private int NrOfConnections {
    4366      get { return NrOfConnectionsParameter.ActualValue.Value; }
    4467    }
    45     public int SwarmSize {
     68    private int SwarmSize {
    4669      get { return SwarmSizeParameter.ActualValue.Value; }
    4770    }
    48     public ItemArray<IntegerVector> Neighbors {
     71    private ItemArray<IntegerVector> Neighbors {
    4972      get { return NeighborsParameter.ActualValue; }
    5073      set { NeighborsParameter.ActualValue = value; }
    5174    }
    52     public int CurrentIteration {
     75    private int CurrentIteration {
    5376      get { return CurrentIterationParameter.ActualValue.Value; }
    5477    }
    55     public int RegroupingPeriod {
     78    private int RegroupingPeriod {
    5679      get { return RegroupingPeriodParameter.ActualValue.Value; }
    5780    }
    5881    #endregion
    5982
     83    [StorableConstructor]
     84    private MultiPSOTopologyUpdater(bool deserializing) : base(deserializing) { }
     85    private MultiPSOTopologyUpdater(MultiPSOTopologyUpdater original, Cloner cloner) : base(original, cloner) { }
    6086    public MultiPSOTopologyUpdater()
    6187      : base() {
     
    6692      Parameters.Add(new LookupParameter<IntValue>("CurrentIteration", "The current iteration of the algorithm."));
    6793      Parameters.Add(new ValueLookupParameter<IntValue>("RegroupingPeriod", "Update interval (=iterations) for regrouping of neighborhoods.", new IntValue(5)));
     94    }
     95
     96    public override IDeepCloneable Clone(Cloner cloner) {
     97      return new MultiPSOTopologyUpdater(this, cloner);
    6898    }
    6999
     
    84114          int nextParticle = numbers[Random.Next(0, numbers.Count)];
    85115          if (!groups.ContainsKey(groupId)) {
    86             groups.Add(groupId, new List<int>()); 
     116            groups.Add(groupId, new List<int>());
    87117          }
    88118          groups[groupId].Add(nextParticle);
     
    90120            groupId++;
    91121          }
    92           numbers.Remove(nextParticle); 
     122          numbers.Remove(nextParticle);
    93123        }
    94124
     
    111141      return base.Apply();
    112142    }
    113 
    114     [StorableConstructor]
    115     protected MultiPSOTopologyUpdater(bool deserializing) : base(deserializing) { }
    116 
    117     #region Cloning
    118     public override IDeepCloneable Clone(Cloner cloner) {
    119       return new MultiPSOTopologyUpdater(this, cloner);
    120     }
    121 
    122     protected MultiPSOTopologyUpdater(MultiPSOTopologyUpdater original, Cloner cloner)
    123       : base(original, cloner) {
    124     }
    125     #endregion
    126143  }
    127144}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborUpdater.cs

    r5410 r5435  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31
    3132namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    32 
    3333  [Item("Neighbor Updater", "Determines the best quality and point among the defined list of neigbors for every particle and its individual neighborhood.")]
    3434  [StorableClass]
    35   public class NeighborUpdater : SingleSuccessorOperator {
     35  public sealed class NeighborUpdater : SingleSuccessorOperator {
     36    public override bool CanChangeName {
     37      get { return false; }
     38    }
    3639
    3740    #region Parameters
     
    5457
    5558    #region Parameter Values
    56     public ItemArray<RealVector> Points {
     59    private ItemArray<RealVector> Points {
    5760      get { return PointsParameter.ActualValue; }
    5861    }
    59     public ItemArray<IntegerVector> Neighbors {
     62    private ItemArray<IntegerVector> Neighbors {
    6063      get { return NeighborsParameter.ActualValue; }
    6164    }
    62     public ItemArray<RealVector> BestNeighborPoints {
     65    private ItemArray<RealVector> BestNeighborPoints {
    6366      get { return BestNeighborPointParameter.ActualValue; }
    6467      set { BestNeighborPointParameter.ActualValue = value; }
    6568    }
    66     public ItemArray<DoubleValue> Qualities {
     69    private ItemArray<DoubleValue> Qualities {
    6770      get { return QualityParameter.ActualValue; }
    6871    }
    69     public bool Maximization {
     72    private bool Maximization {
    7073      get { return MaximizationParameter.ActualValue.Value; }
    7174    }
     
    7376
    7477    #region Construction & Cloning
     78    [StorableConstructor]
     79    private NeighborUpdater(bool deserializing) : base(deserializing) { }
     80    private NeighborUpdater(NeighborUpdater original, Cloner cloner) : base(original, cloner) { }
    7581    public NeighborUpdater() {
    7682      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Point", "The position of the particle."));
     
    8086      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "Whether the problem is a maximization problem."));
    8187    }
    82     [StorableConstructor]
    83     protected NeighborUpdater(bool deserializing) : base(deserializing) { }
    84     protected NeighborUpdater(NeighborUpdater original, Cloner cloner)
    85       : base(original, cloner) {
    86     }
     88
    8789    public override IDeepCloneable Clone(Cloner cloner) {
    8890      return new NeighborUpdater(this, cloner);
     
    9496        if (BestNeighborPoints == null || BestNeighborPoints.Length != Neighbors.Length)
    9597          BestNeighborPoints = new ItemArray<RealVector>(Neighbors.Length);
    96         for (int n = 0; n<Neighbors.Length; n++) {
     98        for (int n = 0; n < Neighbors.Length; n++) {
    9799          var pairs = Qualities.Zip(Points, (q, p) => new { Quality = q, Point = p })
    98100            .Where((p, i) => i == n || Neighbors[n].Contains(i));
    99           BestNeighborPoints[n] = Maximization ? 
     101          BestNeighborPoints[n] = Maximization ?
    100102          pairs.OrderByDescending(p => p.Quality.Value).First().Point :
    101103          pairs.OrderBy(p => p.Quality.Value).First().Point;
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs

    r5427 r5435  
    2626
    2727namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    28 
    29   [Item("Neighborhood Particle Updater", "Updates the particle's position using (among other things) the best neighbor's position. Point = Point + Velocity*Omega + (PersonalBestPoint-Point)*Phi_P*r_p + (BestNeighborPoint-Point)*Phi_G*r_g")]
     28  [Item("Neighborhood Particle Updater", "Updates the particle's position using (among other things) the best neighbor's position. Point = Point + Velocity*Omega + (PersonalBestPoint-Point)*Phi_P*r_p + (BestNeighborPoint-Point)*Phi_G*r_g.")]
    3029  [StorableClass]
    31   public class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater {
    32 
    33     #region Construction & Cloning
     30  public sealed class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater {
    3431
    3532    [StorableConstructor]
    36     protected NeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
    37     protected NeighborhoodParticleUpdater(NeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
     33    private NeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
     34    private NeighborhoodParticleUpdater(NeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3835    public NeighborhoodParticleUpdater() : base() { }
    3936
     
    4138      return new NeighborhoodParticleUpdater(this, cloner);
    4239    }
    43 
    44     #endregion
    4540
    4641    public override IOperation Apply() {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r5418 r5435  
    3434using HeuristicLab.PluginInfrastructure;
    3535using HeuristicLab.Random;
    36 using System.Collections.Generic;
    3736
    3837namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    39 
    4038  [Item("Particle Swarm Optimization", "A particle swarm optimization algorithm based on the description in Pedersen, M.E.H. (2010). PhD thesis. University of Southampton.")]
    4139  [Creatable("Algorithms")]
    4240  [StorableClass]
    43   public class ParticleSwarmOptimization : EngineAlgorithm, IStorableContent {
     41  public sealed class ParticleSwarmOptimization : EngineAlgorithm, IStorableContent {
    4442
    4543    #region Problem Properties
     
    135133
    136134    [StorableConstructor]
    137     protected ParticleSwarmOptimization(bool deserializing)
    138       : base(deserializing) {
    139     }
    140     protected ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner)
     135    private ParticleSwarmOptimization(bool deserializing) : base(deserializing) { }
     136    private ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner)
    141137      : base(original, cloner) {
    142138      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    143139      Initialize();
    144140    }
    145 
    146     [StorableHook(HookType.AfterDeserialization)]
    147     private void AfterDeserialization() {
    148       Initialize();
    149     }
    150 
    151141    public ParticleSwarmOptimization()
    152142      : base() {
     
    288278    }
    289279
     280    [StorableHook(HookType.AfterDeserialization)]
     281    private void AfterDeserialization() {
     282      Initialize();
     283    }
     284
    290285    public override void Prepare() {
    291286      if (Problem != null) {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs

    r5410 r5435  
    2929
    3030namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    31 
     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.")]
    3232  [StorableClass]
    3333  public abstract class ParticleUpdater : SingleSuccessorOperator, IParticleUpdater {
     34    public override bool CanChangeName {
     35      get { return false; }
     36    }
    3437
    3538    #region Parameter properties
     
    7073
    7174    #region Parameter Values
    72     public IRandom Random {
     75    protected IRandom Random {
    7376      get { return RandomParameter.ActualValue; }
    7477    }
    75     public RealVector Point {
     78    protected RealVector Point {
    7679      get { return PointParameter.ActualValue; }
    7780      set { PointParameter.ActualValue = value; }
    7881    }
    79     public RealVector Velocity {
     82    protected RealVector Velocity {
    8083      get { return VelocityParameter.ActualValue; }
    8184      set { VelocityParameter.ActualValue = value; }
    8285    }
    83     public RealVector PersonalBestPoint {
     86    protected RealVector PersonalBestPoint {
    8487      get { return PersonalBestPointParameter.ActualValue; }
    8588    }
    86     public RealVector BestPoint {
     89    protected RealVector BestPoint {
    8790      get { return BestPointParameter.ActualValue; }
    8891    }
    89     public RealVector BestNeighborPoint {
     92    protected RealVector BestNeighborPoint {
    9093      get { return BestNeighborPointParameter.ActualValue; }
    9194    }
    92     public DoubleMatrix Bounds {
     95    protected DoubleMatrix Bounds {
    9396      get { return BoundsParameter.ActualValue; }
    9497    }
    95     public DoubleMatrix VelocityBounds {
     98    protected DoubleMatrix VelocityBounds {
    9699      get { return VelocityBoundsParameter.ActualValue; }
    97100    }
    98 
    99     public DoubleValue Omega {
     101    protected DoubleValue Omega {
    100102      get { return OmegaParameter.ActualValue; }
    101103    }
    102     public DoubleValue Phi_P {
     104    protected DoubleValue Phi_P {
    103105      get { return Phi_PParameter.ActualValue; }
    104106    }
    105     public DoubleValue Phi_G {
     107    protected DoubleValue Phi_G {
    106108      get { return Phi_GParameter.ActualValue; }
    107109    }
    108110    #endregion
    109 
    110     public override bool CanChangeName {
    111       get { return false; }
    112     }
    113111
    114112    #region Construction & Cloning
     
    116114    [StorableConstructor]
    117115    protected ParticleUpdater(bool deserializing) : base(deserializing) { }
    118     protected ParticleUpdater(ParticleUpdater original, Cloner cloner)
    119       : base(original, cloner) {
    120     }
    121 
     116    protected ParticleUpdater(ParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    122117    public ParticleUpdater()
    123118      : base() {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Properties/AssemblyInfo.frame

    r3348 r5435  
    2727// associated with an assembly.
    2828[assembly: AssemblyTitle("HeuristicLab.Algorithms.ParticleSwarmOptimization")]
    29 [assembly: AssemblyDescription("HeuristicLab ParticleSwarmOptimization (PSO)")]
     29[assembly: AssemblyDescription("Plugin that provides an implementation of the particle swarm optimization (PSO) metaheuristic.")]
    3030[assembly: AssemblyConfiguration("")]
    3131[assembly: AssemblyCompany("")]
     
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.0.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.2.$WCREV$")]
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RandomTopologyInitializer.cs

    r5410 r5435  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30
    3031namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    31 
    3232  [Item("Random Topology Initializer", "Randomly connectes every particle with k other particles.")]
    3333  [StorableClass]
    34   public class RandomTopologyInitializer : TopologyInitializer {
    35 
     34  public sealed class RandomTopologyInitializer : TopologyInitializer {
    3635    #region Parameters
    3736    public ILookupParameter<IRandom> RandomParameter {
     
    4443
    4544    #region Parameter Values
    46     public IRandom Random {
     45    private IRandom Random {
    4746      get { return RandomParameter.ActualValue; }
    4847    }
    49     public int NrOfConnections {
     48    private int NrOfConnections {
    5049      get { return NrOfConnectionsParameter.ActualValue.Value; }
    5150    }
     
    5352
    5453    #region Construction & Cloning
     54    [StorableConstructor]
     55    private RandomTopologyInitializer(bool deserializing) : base(deserializing) { }
     56    private RandomTopologyInitializer(RandomTopologyInitializer original, Cloner cloner) : base(original, cloner) { }
    5557    public RandomTopologyInitializer() {
    5658      Parameters.Add(new LookupParameter<IRandom>("Random", "A random number generation."));
    5759      Parameters.Add(new ValueLookupParameter<IntValue>("NrOfConnections", "Nr of connected neighbors.", new IntValue(3)));
    5860    }
    59     [StorableConstructor]
    60     protected RandomTopologyInitializer(bool deserializing) : base(deserializing) { }
    61     protected RandomTopologyInitializer(RandomTopologyInitializer original, Cloner cloner)
    62       : base(original, cloner) {
    63     }
     61
    6462    public override IDeepCloneable Clone(Cloner cloner) {
    6563      return new RandomTopologyInitializer(this, cloner);
     
    6967    public override IOperation Apply() {
    7068      ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize);
    71       for (int i = 0; i<SwarmSize; i++) {
     69      for (int i = 0; i < SwarmSize; i++) {
    7270        var numbers = Enumerable.Range(0, SwarmSize).ToList();
    7371        numbers.RemoveAt(i);
    7472        var selectedNumbers = new List<int>(NrOfConnections);
    75         for (int j = 0; j<NrOfConnections && numbers.Count > 0; j++) {
     73        for (int j = 0; j < NrOfConnections && numbers.Count > 0; j++) {
    7674          int index = Random.Next(numbers.Count);
    7775          selectedNumbers.Add(numbers[index]);
     
    8381      return base.Apply();
    8482    }
    85 
    8683  }
    8784}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs

    r5316 r5435  
    2424using HeuristicLab.Encodings.IntegerVectorEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26
    2627namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    27 
    2828  [Item("Ring Topology Initializer", "Connected every particle with its preceeding and its following particle.")]
    2929  [StorableClass]
    30   public class RingTopologyInitializer : TopologyInitializer {
     30  public sealed class RingTopologyInitializer : TopologyInitializer {
     31    #region Construction & Cloning
    3132
    32     #region Construction & Cloning
    33     public RingTopologyInitializer() { }
    3433    [StorableConstructor]
    35     protected RingTopologyInitializer(bool deserializing) : base(deserializing) { }
    36     protected RingTopologyInitializer(RingTopologyInitializer original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     34    private RingTopologyInitializer(bool deserializing) : base(deserializing) { }
     35    private RingTopologyInitializer(RingTopologyInitializer original, Cloner cloner) : base(original, cloner) { }
     36    public RingTopologyInitializer() : base() { }
     37
    3938    public override IDeepCloneable Clone(Cloner cloner) {
    4039      return new RingTopologyInitializer(this, cloner);
    4140    }
     41
    4242    #endregion
    4343
    4444    public override IOperation Apply() {
    4545      ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize);
    46       for (int i = 0; i<SwarmSize; i++) {
    47         neighbors[i] = new IntegerVector(new[] { (SwarmSize + i-1) % SwarmSize, (i+1) % SwarmSize });
     46      for (int i = 0; i < SwarmSize; i++) {
     47        neighbors[i] = new IntegerVector(new[] { (SwarmSize + i - 1) % SwarmSize, (i + 1) % SwarmSize });
    4848      }
    4949      Neighbors = neighbors;
    5050      return base.Apply();
    5151    }
    52 
    5352  }
    5453}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/SwarmUpdater.cs

    r5410 r5435  
    2929
    3030namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    31 
    3231  [Item("Swarm Updater", "Updates personal best point and quality as well as global best point and quality.")]
    3332  [StorableClass]
    34   public class SwarmUpdater : SingleSuccessorOperator {
     33  public sealed class SwarmUpdater : SingleSuccessorOperator {
     34    public override bool CanChangeName {
     35      get { return false; }
     36    }
    3537
    3638    #region Parameter properties
     
    5961
    6062    #region Parameter values
    61     public double Quality {
     63    private double Quality {
    6264      get { return QualityParameter.ActualValue.Value; }
    6365    }
    64     public double PersonalBestQuality {
     66    private double PersonalBestQuality {
    6567      get { return PersonalBestQualityParameter.ActualValue.Value; }
    6668      set { PersonalBestQualityParameter.ActualValue = new DoubleValue(value); }
    6769    }
    68     public double BestQuality {
     70    private double BestQuality {
    6971      get { return BestQualityParameter.ActualValue.Value; }
    7072      set { BestQualityParameter.ActualValue = new DoubleValue(value); }
    7173    }
    72     public RealVector Point {
     74    private RealVector Point {
    7375      get { return PointParameter.ActualValue; }
    7476    }
    75     public RealVector PersonalBestPoint {
     77    private RealVector PersonalBestPoint {
    7678      get { return PersonalBestPointParameter.ActualValue; }
    7779      set { PersonalBestPointParameter.ActualValue = value; }
    7880    }
    79     public RealVector BestPoint {
     81    private RealVector BestPoint {
    8082      get { return BestPointParameter.ActualValue; }
    8183      set { BestPointParameter.ActualValue = value; }
    8284    }
    83     public bool Maximization {
     85    private bool Maximization {
    8486      get { return MaximizationParameter.ActualValue.Value; }
    8587    }
     
    8991
    9092    [StorableConstructor]
    91     protected SwarmUpdater(bool deserializing) : base(deserializing) { }
    92     protected SwarmUpdater(SwarmUpdater original, Cloner cloner)
    93       : base(original, cloner) {
    94     }
    95 
     93    private SwarmUpdater(bool deserializing) : base(deserializing) { }
     94    private SwarmUpdater(SwarmUpdater original, Cloner cloner) : base(original, cloner) { }
    9695    public SwarmUpdater()
    9796      : base() {
     
    112111
    113112    public override IOperation Apply() {
    114 
    115113      if (Maximization && Quality > PersonalBestQuality ||
    116114         !Maximization && Quality < PersonalBestQuality) {
     
    125123      return base.Apply();
    126124    }
    127 
    128     public override bool CanChangeName {
    129       get { return false; }
    130     }
    131125  }
    132126}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TopologyInitializer.cs

    r5410 r5435  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29
    2930namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    30 
     31  [Item("TopologyInitializer", "Groups the particles into neighborhoods according to a certain strategy.")]
    3132  [StorableClass]
    3233  public abstract class TopologyInitializer : SingleSuccessorOperator, ITopologyInitializer {
     34    public override bool CanChangeName {
     35      get { return false; }
     36    }
    3337
    3438    #region Parameters
     
    4347
    4448    #region Parameter Values
    45     public ItemArray<IntegerVector> Neighbors {
     49    protected ItemArray<IntegerVector> Neighbors {
    4650      get { return NeighborsParameter.ActualValue; }
    4751      set { NeighborsParameter.ActualValue = value; }
    4852    }
    49     public int SwarmSize {
     53    protected int SwarmSize {
    5054      get { return SwarmSizeParameter.ActualValue.Value; }
    5155    }
     
    5357
    5458    #region Construction & Cloning
    55     protected TopologyInitializer() {
     59    [StorableConstructor]
     60    protected TopologyInitializer(bool deserializing) : base(deserializing) { }
     61    protected TopologyInitializer(TopologyInitializer original, Cloner cloner) : base(original, cloner) { }
     62    public TopologyInitializer() {
    5663      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Neighbors", "The list of neighbors for each particle."));
    5764      Parameters.Add(new LookupParameter<IntValue>("SwarmSize", "Number of particles in the swarm."));
    58     }
    59     [StorableConstructor]
    60     protected TopologyInitializer(bool deserializing) : base(deserializing) { }
    61     protected TopologyInitializer(TopologyInitializer original, Cloner cloner)
    62       : base(original, cloner) {
    6365    }
    6466    #endregion
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TotallyConnectedParticleUpdater.cs

    r5427 r5435  
    2626
    2727namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    28 
    2928  [Item("Totally Connected Particle Updater", "Updates the particle's position using (among other things) the global best position. Use together with the empty topology initialzer. Point = Point + Velocity*Omega + (PersonalBestPoint-Point)*Phi_P*r_p + (BestPoint-Point)*Phi_G*r_g")]
    3029  [StorableClass]
    31   public class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater {
     30  public sealed class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater {
    3231
    3332    #region Construction & Cloning
    3433
    3534    [StorableConstructor]
    36     protected TotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
    37     protected TotallyConnectedParticleUpdater(TotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
     35    private TotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
     36    private TotallyConnectedParticleUpdater(TotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3837    public TotallyConnectedParticleUpdater() : base() { }
    3938
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VelocityBoundsModifier.cs

    r5316 r5435  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using HeuristicLab.Operators;
    6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     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
    722using HeuristicLab.Common;
    823using HeuristicLab.Core;
    924using HeuristicLab.Data;
     25using HeuristicLab.Operators;
    1026using HeuristicLab.Optimization;
    1127using HeuristicLab.Parameters;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1229using HeuristicLab.PluginInfrastructure;
    1330
    1431namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    15 
     32  [Item("VelocityBoundsModifier", "Modifies the velocity bounds.")]
    1633  [StorableClass]
    17   public class VelocityBoundsModifier : SingleSuccessorOperator, IDiscreteDoubleMatrixModifier {
    18 
     34  public sealed class VelocityBoundsModifier : SingleSuccessorOperator, IDiscreteDoubleMatrixModifier {
    1935    #region Parameters
    2036    public ILookupParameter<DoubleMatrix> ValueParameter {
     
    4763
    4864    [StorableConstructor]
    49     protected VelocityBoundsModifier(bool deserializing) : base(deserializing) { }
    50     protected VelocityBoundsModifier(VelocityBoundsModifier original, Cloner cloner) : base(original, cloner) {
    51       Initialize();
     65    private VelocityBoundsModifier(bool deserializing) : base(deserializing) { }
     66    private VelocityBoundsModifier(VelocityBoundsModifier original, Cloner cloner)
     67      : base(original, cloner) {
     68      ParameterizeModifiers();
    5269    }
    5370    public VelocityBoundsModifier() {
     
    6077      Parameters.Add(new ValueLookupParameter<IntValue>("StartIndex", "The start index at which to start modifying 'Value'."));
    6178      Parameters.Add(new ValueLookupParameter<IntValue>("EndIndex", "The end index by which 'Value' should have reached 'EndValue'."));
     79
    6280      Initialize();
     81      ParameterizeModifiers();
    6382    }
     83
    6484    public override IDeepCloneable Clone(Cloner cloner) {
    6585      return new VelocityBoundsModifier(this, cloner);
     86    }
     87    #endregion
     88
     89    [StorableHook(HookType.AfterDeserialization)]
     90    private void AfterDeserialization() {
     91      ParameterizeModifiers();
    6692    }
    6793
     
    6995      foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>()) {
    7096        ScalingOperatorParameter.ValidValues.Add(op);
    71         op.ValueParameter.ActualName = ScaleParameter.ActualName;
    72       }
    73       ScaleParameter.ActualNameChanged += new EventHandler(ScaleParameter_ActualNameChanged);
    74       StartValueParameter.ActualNameChanged += new EventHandler(StartValueParameter_ActualNameChanged);
    75       EndValueParameter.ActualNameChanged += new EventHandler(EndValueParameter_ActualNameChanged);
    76       IndexParameter.ActualNameChanged += new EventHandler(IndexParameter_ActualNameChanged);
    77       EndIndexParameter.ActualNameChanged += new EventHandler(EndIndexParameter_ActualNameChanged);
    78       StartIndexParameter.ActualNameChanged += new EventHandler(StartIndexParameter_ActualNameChanged);
    79     }
    80     #endregion
    81 
    82     #region Events
    83     private void ScaleParameter_ActualNameChanged(object sender, EventArgs e) {
    84       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    85         modifier.ValueParameter.ActualName = ScaleParameter.ActualName;
    8697      }
    8798    }
    8899
    89     private void StartValueParameter_ActualNameChanged(object sender, EventArgs e) {
    90       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    91         modifier.StartValueParameter.ActualName = StartValueParameter.ActualName;
     100    private void ParameterizeModifiers() {
     101      foreach (IDiscreteDoubleValueModifier op in ScalingOperatorParameter.ValidValues) {
     102        op.ValueParameter.ActualName = ScaleParameter.Name;
     103        op.StartValueParameter.ActualName = StartValueParameter.Name;
     104        op.EndValueParameter.ActualName = EndValueParameter.Name;
     105        op.IndexParameter.ActualName = IndexParameter.Name;
     106        op.StartIndexParameter.ActualName = StartIndexParameter.Name;
     107        op.EndIndexParameter.ActualName = EndIndexParameter.Name;
    92108      }
    93109    }
    94 
    95     private void EndValueParameter_ActualNameChanged(object sender, EventArgs e) {
    96       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    97         modifier.EndValueParameter.ActualName = EndValueParameter.ActualName;
    98       }
    99     }
    100 
    101     private void IndexParameter_ActualNameChanged(object sender, EventArgs e) {
    102       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    103         modifier.IndexParameter.ActualName = IndexParameter.ActualName;
    104       }
    105     }
    106 
    107     private void StartIndexParameter_ActualNameChanged(object sender, EventArgs e) {
    108       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    109         modifier.StartIndexParameter.ActualName = StartIndexParameter.ActualName;
    110       }
    111     }
    112 
    113     private void EndIndexParameter_ActualNameChanged(object sender, EventArgs e) {
    114       foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {
    115         modifier.EndIndexParameter.ActualName = EndIndexParameter.ActualName;
    116       }
    117     }
    118     #endregion
    119110
    120111    public override IOperation Apply() {
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs

    r5316 r5435  
    2424using HeuristicLab.Encodings.IntegerVectorEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26
    2627namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    27 
    2828  [Item("Von Neumann Topology Initializer", "Every particle is connected with the two following and the two previous particles wrapping around at the beginning and the end of the population.")]
    2929  [StorableClass]
    30   public class VonNeumannTopologyInitializer : TopologyInitializer {
     30  public sealed class VonNeumannTopologyInitializer : TopologyInitializer {
    3131
    3232    #region Construction & Cloning
    33     public VonNeumannTopologyInitializer() { }
     33
    3434    [StorableConstructor]
    35     protected VonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { }
    36     protected VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35    private VonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { }
     36    private VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner) : base(original, cloner) { }
     37    public VonNeumannTopologyInitializer() : base() { }
     38
    3939    public override IDeepCloneable Clone(Cloner cloner) {
    4040      return new VonNeumannTopologyInitializer(this, cloner);
    4141    }
     42
    4243    #endregion
    4344
    4445    public override IOperation Apply() {
    4546      ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize);
    46       for (int i = 0; i<SwarmSize; i++) {
     47      for (int i = 0; i < SwarmSize; i++) {
    4748        neighbors[i] = new IntegerVector(new[] {
    4849          (SwarmSize + i-2) % SwarmSize,
     
    5556      return base.Apply();
    5657    }
    57 
    5858  }
    5959}
Note: See TracChangeset for help on using the changeset viewer.