- Timestamp:
- 01/17/11 16:50:15 (14 years ago)
- Location:
- branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
- Files:
-
- 2 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.csproj
r5225 r5311 110 110 <ItemGroup> 111 111 <Compile Include="BestPointInitializer.cs" /> 112 <Compile Include=" WeightedValueModifierSelector.cs" />113 <Compile Include="V alueModifierSelector.cs" />112 <Compile Include="IDiscreteDoubleMatrixModifier.cs" /> 113 <Compile Include="VelocityBoundsModifier.cs" /> 114 114 <Compile Include="RandomTopologyInitializer.cs" /> 115 115 <Compile Include="VonNeumannTopologyInitializer.cs" /> -
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs
r5225 r5311 54 54 set { AnalyzerParameter.Value = value; } 55 55 } 56 public ValueModifierSelector OmegaUpdater {56 public IDiscreteDoubleValueModifier OmegaUpdater { 57 57 get { return OmegaUpdaterParameter.Value; } 58 58 set { OmegaUpdaterParameter.Value = value; } 59 59 } 60 public WeightedValueModifierSelector VelocityBoundsUpdater {60 public IDiscreteDoubleMatrixModifier VelocityBoundsUpdater { 61 61 get { return VelocityBoundsUpdaterParameter.Value; } 62 62 set { VelocityBoundsUpdaterParameter.Value = value; } … … 101 101 get { return (ConstrainedValueParameter<ITopologyUpdater>)Parameters["TopologyUpdater"]; } 102 102 } 103 public ValueParameter<WeightedValueModifierSelector> VelocityBoundsUpdaterParameter {104 get { return ( ValueParameter<WeightedValueModifierSelector>)Parameters["VelocityBoundsUpdater"]; }105 } 106 public ValueParameter<ValueModifierSelector> OmegaUpdaterParameter {107 get { return ( ValueParameter<ValueModifierSelector>)Parameters["OmegaUpdater"]; }103 public OptionalConstrainedValueParameter<IDiscreteDoubleMatrixModifier> VelocityBoundsUpdaterParameter { 104 get { return (OptionalConstrainedValueParameter<IDiscreteDoubleMatrixModifier>)Parameters["VelocityBoundsUpdater"]; } 105 } 106 public OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> OmegaUpdaterParameter { 107 get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["OmegaUpdater"]; } 108 108 } 109 109 #endregion … … 112 112 [Storable] 113 113 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 114 115 //[Storable]116 //private IDiscreteDoubleValueModifier omegaModifier;117 114 #endregion 118 115 … … 122 119 : base(original, cloner) { 123 120 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 124 //omegaModifier = cloner.Clone(original.omegaModifier);125 121 } 126 122 … … 144 140 //Parameters.Add(new ValueParameter<MultiParameterUpdater>("ParameterUpdater", "Updates the algorithm parameters according to some strategy", 145 141 // new MultiParameterUpdater())); 146 Parameters.Add(new ValueParameter<ValueModifierSelector>("OmegaUpdater", "Updates the omega parameter", new ValueModifierSelector())); 147 Parameters.Add(new ValueParameter<WeightedValueModifierSelector>("VelocityBoundsUpdater", "Adjusts the velocity bounds", new WeightedValueModifierSelector())); 142 Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("OmegaUpdater", "Updates the omega parameter")); 143 //Parameters.Add(new ValueParameter<MatrixValueModifierSelector>("VelocityBoundsUpdater", "Adjusts the velocity bounds", new MatrixValueModifierSelector())); 144 Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleMatrixModifier>("VelocityBoundsUpdater", "Adjusts the velocity bounds.")); 148 145 ParticleUpdaterParameter.ActualValue = ParticleUpdaterParameter.ValidValues.SingleOrDefault(v => v.GetType() == typeof(TotallyConnectedParticleUpdater)); 149 146 TopologyInitializerParameter.ActualValue = TopologyInitializerParameter.ValidValues.SingleOrDefault(v => v.GetType() == typeof(EmptyTopologyInitializer)); … … 254 251 255 252 InitializeAnalyzers(); 256 Init ializeUpdaters();253 InitVelocityBoundsUpdater(); 257 254 UpdateAnalyzers(); 255 UpdateOmegaUpdater(); 256 InitOmegaUpdater(); 258 257 } 259 258 … … 309 308 } 310 309 311 private void InitializeUpdaters() { 312 OmegaUpdater.ValueParameter.ActualName = OmegaParameter.Name; 313 foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>()) { 314 OmegaUpdater.ModifierParameter.ValidValues.Add(op); 315 op.EndIndexParameter.ActualName = MaxIterationsParameter.Name; 316 op.StartIndexParameter.Value = new IntValue(0); 317 op.IndexParameter.ActualName = "CurrentIteration"; 318 op.ValueParameter.ActualName = OmegaUpdater.ValueParameter.ActualName; 319 op.StartValueParameter.Value = new DoubleValue(OmegaParameter.Value.Value); 320 op.EndValueParameter.Value = new DoubleValue(-2); 321 } 322 VelocityBoundsUpdater.ValueParameter.ActualName = VelocityBoundsParameter.Name; 323 foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>()) { 324 VelocityBoundsUpdater.ModifierParameter.ValidValues.Add(op); 325 op.EndIndexParameter.ActualName = MaxIterationsParameter.Name; 326 op.StartIndexParameter.Value = new IntValue(0); 327 op.IndexParameter.ActualName = "CurrentIteration"; 328 op.ValueParameter.ActualName = VelocityBoundsUpdater.ScaleParameter.Name; 329 op.StartValueParameter.Value = new DoubleValue(VelocityBoundsUpdater.ScaleParameter.Value.Value); 330 op.EndValueParameter.Value = new DoubleValue(0); 310 private void InitVelocityBoundsUpdater() { 311 foreach (IDiscreteDoubleMatrixModifier matrixOp in ApplicationManager.Manager.GetInstances<IDiscreteDoubleMatrixModifier>()) { 312 VelocityBoundsUpdaterParameter.ValidValues.Add(matrixOp); 313 matrixOp.ValueParameter.ActualName = VelocityBoundsParameter.Name; 314 matrixOp.EndIndexParameter.ActualName = MaxIterationsParameter.Name; 315 matrixOp.StartIndexParameter.Value = new IntValue(0); 316 matrixOp.IndexParameter.ActualName = "CurrentIteration"; 317 matrixOp.EndValueParameter.Value = new DoubleValue(0); 318 } 319 VelocityBoundsUpdaterParameter.ValueChanged += new EventHandler(VelocityBoundsUpdaterParameter_ValueChanged); 320 } 321 322 void VelocityBoundsUpdaterParameter_ValueChanged(object sender, EventArgs e) { 323 if (VelocityBoundsParameter.Value != null) { 324 foreach (IDiscreteDoubleMatrixModifier matrixOp in VelocityBoundsUpdaterParameter.Value.ScalingOperatorParameter.ValidValues) { 325 matrixOp.ValueParameter.ActualName = VelocityBoundsUpdater.ScaleParameter.Name; 326 matrixOp.StartValueParameter.Value = new DoubleValue(VelocityBoundsUpdater.ScaleParameter.ActualValue.Value); 331 327 } 328 } 329 } 330 331 private void InitOmegaUpdater() { 332 foreach (IDiscreteDoubleValueModifier updater in OmegaUpdaterParameter.ValidValues) { 333 updater.EndIndexParameter.ActualName = MaxIterationsParameter.Name; 334 updater.StartIndexParameter.Value = new IntValue(0); 335 updater.IndexParameter.ActualName = "CurrentIteration"; 336 updater.ValueParameter.ActualName = OmegaParameter.Name; 337 updater.StartValueParameter.Value = new DoubleValue(1); 338 updater.EndValueParameter.Value = new DoubleValue(0); 339 } 340 } 341 342 private void UpdateOmegaUpdater() { 343 IDiscreteDoubleValueModifier oldOmegaUpdater = OmegaUpdater; 344 OmegaUpdaterParameter.ValidValues.Clear(); 345 foreach (IDiscreteDoubleValueModifier updater in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) { 346 OmegaUpdaterParameter.ValidValues.Add(updater); 347 } 348 if (oldOmegaUpdater != null) { 349 IDiscreteDoubleValueModifier updater = OmegaUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldOmegaUpdater.GetType()); 350 if (updater != null) OmegaUpdaterParameter.Value = updater; 351 } 332 352 } 333 353
Note: See TracChangeset
for help on using the changeset viewer.