- Timestamp:
- 06/24/11 17:51:06 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs
r5941 r6476 39 39 [StorableClass] 40 40 public sealed class ParticleSwarmOptimization : HeuristicOptimizationEngineAlgorithm, IStorableContent { 41 42 #region Problem Properties 41 #region Parameter Properties 42 public IValueParameter<IntValue> SeedParameter { 43 get { return (IValueParameter<IntValue>)Parameters["Seed"]; } 44 } 45 public IValueParameter<BoolValue> SetSeedRandomlyParameter { 46 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 47 } 48 public IValueParameter<IntValue> SwarmSizeParameter { 49 get { return (IValueParameter<IntValue>)Parameters["SwarmSize"]; } 50 } 51 public IValueParameter<IntValue> MaxIterationsParameter { 52 get { return (IValueParameter<IntValue>)Parameters["MaxIterations"]; } 53 } 54 public IValueParameter<DoubleValue> InertiaParameter { 55 get { return (IValueParameter<DoubleValue>)Parameters["Inertia"]; } 56 } 57 public IValueParameter<DoubleValue> PersonalBestAttractionParameter { 58 get { return (IValueParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; } 59 } 60 public IValueParameter<DoubleValue> NeighborBestAttractionParameter { 61 get { return (IValueParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; } 62 } 63 public IValueParameter<MultiAnalyzer> AnalyzerParameter { 64 get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 65 } 66 public ConstrainedValueParameter<IParticleCreator> ParticleCreatorParameter { 67 get { return (ConstrainedValueParameter<IParticleCreator>)Parameters["ParticleCreator"]; } 68 } 69 public ConstrainedValueParameter<IParticleUpdater> ParticleUpdaterParameter { 70 get { return (ConstrainedValueParameter<IParticleUpdater>)Parameters["ParticleUpdater"]; } 71 } 72 public OptionalConstrainedValueParameter<ITopologyInitializer> TopologyInitializerParameter { 73 get { return (OptionalConstrainedValueParameter<ITopologyInitializer>)Parameters["TopologyInitializer"]; } 74 } 75 public OptionalConstrainedValueParameter<ITopologyUpdater> TopologyUpdaterParameter { 76 get { return (OptionalConstrainedValueParameter<ITopologyUpdater>)Parameters["TopologyUpdater"]; } 77 } 78 public OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> InertiaUpdaterParameter { 79 get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["InertiaUpdater"]; } 80 } 81 public ConstrainedValueParameter<ISwarmUpdater> SwarmUpdaterParameter { 82 get { return (ConstrainedValueParameter<ISwarmUpdater>)Parameters["SwarmUpdater"]; } 83 84 } 85 #endregion 86 87 #region Properties 88 89 public string Filename { get; set; } 90 91 [Storable] 92 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 93 94 [Storable] 95 private SolutionsCreator solutionsCreator; 96 97 [Storable] 98 private ParticleSwarmOptimizationMainLoop mainLoop; 99 43 100 public override Type ProblemType { 44 101 get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } … … 48 105 set { base.Problem = value; } 49 106 } 107 public IntValue Seed { 108 get { return SeedParameter.Value; } 109 set { SeedParameter.Value = value; } 110 } 111 public BoolValue SetSeedRandomly { 112 get { return SetSeedRandomlyParameter.Value; } 113 set { SetSeedRandomlyParameter.Value = value; } 114 } 115 public IntValue SwarmSize { 116 get { return SwarmSizeParameter.Value; } 117 set { SwarmSizeParameter.Value = value; } 118 } 119 public IntValue MaxIterations { 120 get { return MaxIterationsParameter.Value; } 121 set { MaxIterationsParameter.Value = value; } 122 } 123 public DoubleValue Inertia { 124 get { return InertiaParameter.Value; } 125 set { InertiaParameter.Value = value; } 126 } 127 public DoubleValue PersonalBestAttraction { 128 get { return PersonalBestAttractionParameter.Value; } 129 set { PersonalBestAttractionParameter.Value = value; } 130 } 131 public DoubleValue NeighborBestAttraction { 132 get { return NeighborBestAttractionParameter.Value; } 133 set { NeighborBestAttractionParameter.Value = value; } 134 } 50 135 public MultiAnalyzer Analyzer { 51 136 get { return AnalyzerParameter.Value; } 52 137 set { AnalyzerParameter.Value = value; } 53 138 } 139 public IParticleCreator ParticleCreator { 140 get { return ParticleCreatorParameter.Value; } 141 set { ParticleCreatorParameter.Value = value; } 142 } 143 public IParticleUpdater ParticleUpdater { 144 get { return ParticleUpdaterParameter.Value; } 145 set { ParticleUpdaterParameter.Value = value; } 146 } 147 public ITopologyInitializer TopologyInitializer { 148 get { return TopologyInitializerParameter.Value; } 149 set { TopologyInitializerParameter.Value = value; } 150 } 151 public ITopologyUpdater TopologyUpdater { 152 get { return TopologyUpdaterParameter.Value; } 153 set { TopologyUpdaterParameter.Value = value; } 154 } 54 155 public IDiscreteDoubleValueModifier InertiaUpdater { 55 156 get { return InertiaUpdaterParameter.Value; } 56 157 set { InertiaUpdaterParameter.Value = value; } 57 158 } 58 #endregion 59 60 #region Parameter Properties 61 public IValueParameter<IntValue> SeedParameter { 62 get { return (IValueParameter<IntValue>)Parameters["Seed"]; } 63 } 64 public IValueParameter<BoolValue> SetSeedRandomlyParameter { 65 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 66 } 67 public IValueParameter<IntValue> SwarmSizeParameter { 68 get { return (IValueParameter<IntValue>)Parameters["SwarmSize"]; } 69 } 70 public IValueParameter<IntValue> MaxIterationsParameter { 71 get { return (IValueParameter<IntValue>)Parameters["MaxIterations"]; } 72 } 73 public IValueParameter<DoubleValue> InertiaParameter { 74 get { return (IValueParameter<DoubleValue>)Parameters["Inertia"]; } 75 } 76 public IValueParameter<DoubleValue> PersonalBestAttractionParameter { 77 get { return (IValueParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; } 78 } 79 public IValueParameter<DoubleValue> NeighborBestAttractionParameter { 80 get { return (IValueParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; } 81 } 82 public IValueParameter<MultiAnalyzer> AnalyzerParameter { 83 get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 84 } 85 public ConstrainedValueParameter<IParticleCreator> ParticleCreatorParameter { 86 get { return (ConstrainedValueParameter<IParticleCreator>)Parameters["ParticleCreator"]; } 87 } 88 public ConstrainedValueParameter<IParticleUpdater> ParticleUpdaterParameter { 89 get { return (ConstrainedValueParameter<IParticleUpdater>)Parameters["ParticleUpdater"]; } 90 } 91 public OptionalConstrainedValueParameter<ITopologyInitializer> TopologyInitializerParameter { 92 get { return (OptionalConstrainedValueParameter<ITopologyInitializer>)Parameters["TopologyInitializer"]; } 93 } 94 public OptionalConstrainedValueParameter<ITopologyUpdater> TopologyUpdaterParameter { 95 get { return (OptionalConstrainedValueParameter<ITopologyUpdater>)Parameters["TopologyUpdater"]; } 96 } 97 public OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> InertiaUpdaterParameter { 98 get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["InertiaUpdater"]; } 99 } 100 public ConstrainedValueParameter<ISwarmUpdater> SwarmUpdaterParameter { 101 get { return (ConstrainedValueParameter<ISwarmUpdater>)Parameters["SwarmUpdater"]; } 102 103 } 104 #endregion 105 106 #region Properties 107 108 public string Filename { get; set; } 109 110 [Storable] 111 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 112 113 [Storable] 114 private SolutionsCreator solutionsCreator; 115 116 [Storable] 117 private ParticleSwarmOptimizationMainLoop mainLoop; 118 119 public ITopologyInitializer TopologyInitializer { 120 get { return TopologyInitializerParameter.Value; } 121 set { TopologyInitializerParameter.Value = value; } 122 } 123 124 public ITopologyUpdater TopologyUpdater { 125 get { return TopologyUpdaterParameter.Value; } 126 set { TopologyUpdaterParameter.Value = value; } 127 } 128 129 public IParticleCreator ParticleCreator { 130 get { return ParticleCreatorParameter.Value; } 131 set { ParticleCreatorParameter.Value = value; } 132 } 133 134 public IParticleUpdater ParticleUpdater { 135 get { return ParticleUpdaterParameter.Value; } 136 set { ParticleUpdaterParameter.Value = value; } 159 public ISwarmUpdater SwarmUpdater { 160 get { return SwarmUpdaterParameter.Value; } 161 set { SwarmUpdaterParameter.Value = value; } 137 162 } 138 163 #endregion … … 333 358 } 334 359 360 private void ParameterizeTopologyUpdaters() { 361 foreach (var updater in TopologyUpdaterParameter.ValidValues) { 362 var multiPsoUpdater = updater as MultiPSOTopologyUpdater; 363 if (multiPsoUpdater != null) { 364 multiPsoUpdater.CurrentIterationParameter.ActualName = "Iterations"; 365 } 366 } 367 } 368 335 369 private void UpdateTopologyParameters() { 336 370 ITopologyUpdater oldTopologyUpdater = TopologyUpdater; … … 355 389 if (newParticleUpdater != null) ParticleUpdater = newParticleUpdater; 356 390 } 391 392 ParameterizeTopologyUpdaters(); 357 393 } 358 394 }
Note: See TracChangeset
for help on using the changeset viewer.