1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Operators;
|
---|
6 | using HeuristicLab.Common;
|
---|
7 | using HeuristicLab.Core;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 | using HeuristicLab.Parameters;
|
---|
10 | using HeuristicLab.Data;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
|
---|
13 | /// <summary>
|
---|
14 | /// An operator which represents the main loop of a PSO.
|
---|
15 | /// </summary>
|
---|
16 | [Item("ParticleSwarmOptimizationMainLoop", "An operator which represents the main loop of a PSO.")]
|
---|
17 | [StorableClass]
|
---|
18 | public class ParticleSwarmOptimizationMainLoop : AlgorithmOperator {
|
---|
19 | #region Parameter properties
|
---|
20 | public ValueLookupParameter<VariableCollection> ResultsParameter {
|
---|
21 | get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
22 | }
|
---|
23 | public ValueLookupParameter<IOperator> EncoderParameter {
|
---|
24 | get { return (ValueLookupParameter<IOperator>)Parameters["Encoder"]; }
|
---|
25 | }
|
---|
26 | //public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
27 | // get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
28 | //}
|
---|
29 | #endregion
|
---|
30 |
|
---|
31 | [StorableConstructor]
|
---|
32 | private ParticleSwarmOptimizationMainLoop(bool deserializing) : base() { }
|
---|
33 | public ParticleSwarmOptimizationMainLoop()
|
---|
34 | : base() {
|
---|
35 | Initialize();
|
---|
36 | }
|
---|
37 |
|
---|
38 | private void Initialize() {
|
---|
39 | #region Create parameters
|
---|
40 | Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
|
---|
41 | Parameters.Add(new ValueLookupParameter<IOperator>("Encoder", "The encoding operator that maps a solution to a position vector."));
|
---|
42 | //Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
|
---|
43 | #endregion
|
---|
44 |
|
---|
45 | #region Create operators
|
---|
46 | VariableCreator variableCreator = new VariableCreator();
|
---|
47 | //variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
|
---|
48 | UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
|
---|
49 | Placeholder encoder = new Placeholder();
|
---|
50 | Placeholder evaluator = new Placeholder();
|
---|
51 |
|
---|
52 | encoder.Name = "Encoder (placeholder)";
|
---|
53 | encoder.OperatorParameter.ActualName = EncoderParameter.Name;
|
---|
54 |
|
---|
55 | //evaluator.Name = "Evaluator (placeholder)";
|
---|
56 | //evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
57 | #endregion
|
---|
58 |
|
---|
59 | #region Create operator graph
|
---|
60 | OperatorGraph.InitialOperator = variableCreator;
|
---|
61 | variableCreator.Successor = uniformSubScopesProcessor;
|
---|
62 | uniformSubScopesProcessor.Operator = encoder;
|
---|
63 | //uniformSubScopesProcessor.Successor = evaluator;
|
---|
64 | #endregion
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|