1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Operators;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Data;
|
---|
8 | using HeuristicLab.Parameters;
|
---|
9 | using HeuristicLab.Common;
|
---|
10 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
11 | using HeuristicLab.PluginInfrastructure;
|
---|
12 | using HeuristicLab.Optimization;
|
---|
13 |
|
---|
14 | namespace 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 | }
|
---|