Changeset 5346 for trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm
- Timestamp:
- 01/21/11 10:54:30 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r5307 r5346 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Operators; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Optimization.Operators; … … 134 135 } 135 136 private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop { 136 get { return (GeneticAlgorithmMainLoop) SolutionsCreator.Successor; }137 get { return (GeneticAlgorithmMainLoop)((Assigner)SolutionsCreator.Successor).Successor; } 137 138 } 138 139 [Storable] … … 155 156 RandomCreator randomCreator = new RandomCreator(); 156 157 SolutionsCreator solutionsCreator = new SolutionsCreator(); 158 Assigner assigner = new Assigner(); 157 159 GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop(); 158 160 OperatorGraph.InitialOperator = randomCreator; … … 166 168 167 169 solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name; 168 solutionsCreator.Successor = geneticAlgorithmMainLoop; 170 solutionsCreator.Successor = assigner; 171 172 assigner.Name = "Initialize EvaluatedSolutions"; 173 assigner.LeftSideParameter.ActualName = "EvaluatedSolutions"; 174 assigner.RightSideParameter.ActualName = PopulationSizeParameter.Name; 175 assigner.Successor = geneticAlgorithmMainLoop; 169 176 170 177 geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name; … … 176 183 geneticAlgorithmMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName; 177 184 geneticAlgorithmMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 185 geneticAlgorithmMainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; 186 geneticAlgorithmMainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name; 178 187 geneticAlgorithmMainLoop.ResultsParameter.ActualName = "Results"; 179 188 -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithmMainLoop.cs
r5208 r5346 72 72 public ValueLookupParameter<IOperator> AnalyzerParameter { 73 73 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 74 } 75 public ValueLookupParameter<IntValue> EvaluatedSolutionsParameter { 76 get { return (ValueLookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 77 } 78 public ValueLookupParameter<IntValue> PopulationSizeParameter { 79 get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; } 74 80 } 75 81 private ScopeParameter CurrentScopeParameter { … … 109 115 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 110 116 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 117 Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 118 Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population.")); 111 119 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied.")); 112 120 #endregion … … 126 134 UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor(); 127 135 Placeholder evaluator = new Placeholder(); 136 IntCounter intCounter1 = new IntCounter(); 128 137 SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor(); 129 138 BestSelector bestSelector = new BestSelector(); 130 139 RightReducer rightReducer = new RightReducer(); 131 140 MergingReducer mergingReducer = new MergingReducer(); 132 IntCounter intCounter = new IntCounter();141 IntCounter intCounter2 = new IntCounter(); 133 142 Comparator comparator = new Comparator(); 134 143 ResultsCollector resultsCollector2 = new ResultsCollector(); … … 139 148 140 149 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 150 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(EvaluatedSolutionsParameter.Name)); 141 151 resultsCollector1.ResultsParameter.ActualName = "Results"; 142 152 … … 164 174 evaluator.Name = "Evaluator"; 165 175 evaluator.OperatorParameter.ActualName = "Evaluator"; 176 177 intCounter1.Name = "Increment EvaluatedSolutions"; 178 intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 179 intCounter1.Increment = null; 180 intCounter1.IncrementParameter.ActualName = PopulationSizeParameter.Name; 166 181 167 182 bestSelector.CopySelected = new BoolValue(false); … … 170 185 bestSelector.QualityParameter.ActualName = "Quality"; 171 186 172 intCounter .Increment = new IntValue(1);173 intCounter .ValueParameter.ActualName = "Generations";187 intCounter2.Increment = new IntValue(1); 188 intCounter2.ValueParameter.ActualName = "Generations"; 174 189 175 190 comparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); … … 179 194 180 195 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 196 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>(EvaluatedSolutionsParameter.Name)); 181 197 resultsCollector2.ResultsParameter.ActualName = "Results"; 182 198 … … 206 222 subScopesRemover.Successor = null; 207 223 uniformSubScopesProcessor2.Operator = evaluator; 208 uniformSubScopesProcessor2.Successor = null;224 uniformSubScopesProcessor2.Successor = intCounter1; 209 225 evaluator.Successor = null; 226 intCounter1.Successor = null; 210 227 subScopesProcessor2.Operators.Add(bestSelector); 211 228 subScopesProcessor2.Operators.Add(new EmptyOperator()); … … 213 230 bestSelector.Successor = rightReducer; 214 231 rightReducer.Successor = null; 215 mergingReducer.Successor = intCounter ;216 intCounter .Successor = comparator;232 mergingReducer.Successor = intCounter2; 233 intCounter2.Successor = comparator; 217 234 comparator.Successor = resultsCollector2; 218 235 resultsCollector2.Successor = analyzer2;
Note: See TracChangeset
for help on using the changeset viewer.