Free cookie consent management tool by TermsFeed Policy Generator

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.