Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ValueModifierSelector.cs @ 5258

Last change on this file since 5258 was 5225, checked in by mkofler, 14 years ago

#852: Added two parameter updaters (for omega and the velocity bounds)

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Operators;
6using HeuristicLab.Core;
7using HeuristicLab.Data;
8using HeuristicLab.Parameters;
9using HeuristicLab.Common;
10using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
11using HeuristicLab.PluginInfrastructure;
12using HeuristicLab.Optimization;
13
14namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
15  public class ValueModifierSelector : SingleSuccessorOperator {
16    public ILookupParameter<Item> ValueParameter {
17      get { return (ILookupParameter<Item>)Parameters["Value"]; }
18    }
19
20    public ConstrainedValueParameter<IOperator> ModifierParameter {
21      get { return (ConstrainedValueParameter<IOperator>)Parameters["Modifier"]; }
22    }
23
24    public ValueModifierSelector() : base() {
25      Parameters.Add(new LookupParameter<Item>("Value", "The double value to modify."));
26      Parameters.Add(new ConstrainedValueParameter<IOperator>("Modifier", "Modifies the value", new ItemSet<IOperator>()));
27    }
28
29    public override IDeepCloneable Clone(Cloner cloner) {
30      return new ValueModifierSelector(this, cloner);
31    }
32
33    protected ValueModifierSelector(ValueModifierSelector original, Cloner cloner)
34      : base(original, cloner) {
35    }
36
37    [StorableConstructor]
38    protected ValueModifierSelector(bool deserializing) : base(deserializing) { }
39
40    public override IOperation Apply() {
41      OperationCollection next = new OperationCollection();
42      next.Add(ExecutionContext.CreateOperation(this.ModifierParameter.Value));
43      next.Add(base.Apply());
44      return next;
45    }
46  }
47}
Note: See TracBrowser for help on using the repository browser.