Changeset 3682 for trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs
- Timestamp:
- 05/06/10 19:06:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs
r3415 r3682 9 9 using HeuristicLab.Parameters; 10 10 using HeuristicLab.Data; 11 using HeuristicLab.Analysis; 12 using HeuristicLab.Optimization.Operators; 13 using HeuristicLab.Encodings.RealVectorEncoding; 11 14 12 15 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { … … 24 27 get { return (ValueLookupParameter<IOperator>)Parameters["Encoder"]; } 25 28 } 26 //public ValueLookupParameter<IOperator> EvaluatorParameter { 27 // get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; } 28 //} 29 public ValueLookupParameter<IOperator> DecoderParameter { 30 get { return (ValueLookupParameter<IOperator>)Parameters["Decoder"]; } 31 } 32 public ValueLookupParameter<BoolValue> MaximizationParameter { 33 get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 34 } 35 public ScopeTreeLookupParameter<DoubleValue> QualityParameter { 36 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 37 } 38 public ValueLookupParameter<IntValue> MaximumGenerationsParameter { 39 get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; } 40 } 41 public ValueLookupParameter<IOperator> EvaluatorParameter { 42 get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; } 43 } 44 public ValueLookupParameter<IOperator> AnalyzerParameter { 45 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 46 } 29 47 #endregion 30 48 … … 40 58 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 41 59 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.")); 60 Parameters.Add(new ValueLookupParameter<IOperator>("Decoder", "The decoding operator that maps a position vector to a solution.")); 61 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false.")); 62 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 63 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.")); 64 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions.")); 65 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 43 66 #endregion 44 67 45 68 #region Create operators 46 69 VariableCreator variableCreator = new VariableCreator(); 47 //variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); 70 ResultsCollector resultsCollector1 = new ResultsCollector(); 71 IntCounter intCounter = new IntCounter(); 72 ConditionalBranch conditionalBranch = new ConditionalBranch(); 73 ParticleUpdater velocityUpdater = new ParticleUpdater(); 48 74 UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor(); 49 Placeholder encoder = new Placeholder(); 75 UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor(); 76 Placeholder encPlaceholder = new Placeholder(); 77 Placeholder decPlaceholder = new Placeholder(); 50 78 Placeholder evaluator = new Placeholder(); 79 Comparator comparator = new Comparator(); 80 SwarmUpdater swarmUpdater = new SwarmUpdater(); 81 Placeholder analyzer1 = new Placeholder(); 51 82 52 encoder.Name = "Encoder (placeholder)";53 encoder.OperatorParameter.ActualName = EncoderParameter.Name;83 analyzer1.Name = "Analyzer (placeholder)"; 84 analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name; 54 85 55 //evaluator.Name = "Evaluator (placeholder)"; 56 //evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name; 86 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(1))); // Initial generation already built 87 88 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 89 resultsCollector1.ResultsParameter.ActualName = "Results"; 90 91 intCounter.Increment = new IntValue(1); 92 intCounter.ValueParameter.ActualName = "Generations"; 93 94 comparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 95 comparator.LeftSideParameter.ActualName = "Generations"; 96 comparator.ResultParameter.ActualName = "Terminate"; 97 comparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name; 98 99 conditionalBranch.ConditionParameter.ActualName = "Terminate"; 100 101 velocityUpdater.BestGlobalParameter.ActualName = "CurrentBestPosition"; 102 velocityUpdater.BestLocalParameter.ActualName = "BestPosition"; 103 velocityUpdater.CurrentPositionParameter.ActualName = "Position"; 104 velocityUpdater.VelocityParameter.ActualName = "Velocity"; 105 106 encPlaceholder.OperatorParameter.ActualName = EncoderParameter.ActualName; 107 decPlaceholder.OperatorParameter.ActualName = DecoderParameter.ActualName; 108 109 evaluator.Name = "Evaluator (placeholder)"; 110 evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name; 111 112 swarmUpdater.CurrentPositionParameter.ActualName = "Position"; 113 swarmUpdater.CurrentQualityParameter.ActualName = "Quality"; 114 swarmUpdater.BestGlobalParameter.ActualName = "CurrentBestPosition"; 115 swarmUpdater.BestLocalParameter.ActualName = "BestPosition"; 116 swarmUpdater.LocalBestQualityParameter.ActualName = "BestQuality"; 117 swarmUpdater.GlobalBestQualityParameter.ActualName = "CurrentBestBestQuality"; 118 57 119 #endregion 58 120 59 121 #region Create operator graph 60 122 OperatorGraph.InitialOperator = variableCreator; 61 variableCreator.Successor = uniformSubScopesProcessor; 62 uniformSubScopesProcessor.Operator = encoder; 63 //uniformSubScopesProcessor.Successor = evaluator; 123 variableCreator.Successor = comparator; 124 comparator.Successor = conditionalBranch; 125 conditionalBranch.FalseBranch = uniformSubScopesProcessor; 126 uniformSubScopesProcessor.Operator = velocityUpdater; 127 velocityUpdater.Successor = decPlaceholder; 128 uniformSubScopesProcessor.Successor = uniformSubScopesProcessor2; 129 uniformSubScopesProcessor2.Operator = evaluator; 130 evaluator.Successor = swarmUpdater; 131 swarmUpdater.Successor = intCounter; 132 intCounter.Successor = resultsCollector1; 133 resultsCollector1.Successor = comparator; //analyzer1; 134 //analyzer1.Successor = comparator; 64 135 #endregion 65 136 }
Note: See TracChangeset
for help on using the changeset viewer.