Changeset 8359 for branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3
- Timestamp:
- 07/30/12 14:13:17 (12 years ago)
- Location:
- branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs
r8349 r8359 189 189 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 190 190 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 191 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue( 300)));191 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100))); 192 192 Parameters.Add(new ValueParameter<IntValue>("MinimumPopulationSize", "The minimum size of the population of solutions.", new IntValue(2))); 193 Parameters.Add(new ValueParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions.", new IntValue( 499)));193 Parameters.Add(new ValueParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions.", new IntValue(299))); 194 194 Parameters.Add(new ValueParameter<DoubleValue>("ComparisonFactor", "The comparison factor.", new DoubleValue(0.0))); 195 Parameters.Add(new ValueParameter<IntValue>("Effort", "The maximum number of offspring created in each generation.", new IntValue( 1000)));195 Parameters.Add(new ValueParameter<IntValue>("Effort", "The maximum number of offspring created in each generation.", new IntValue(400))); 196 196 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 197 197 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); … … 302 302 base.Problem_OperatorsChanged(sender, e); 303 303 } 304 void EffortParameter_ValueChanged(object sender, EventArgs e) { 305 Effort.ValueChanged +=new EventHandler(Effort_ValueChanged); 306 ParameterizeSelectors(); 307 } 308 void Effort_ValueChanged(object sender, EventArgs e) { 309 ParameterizeSelectors(); 310 } 304 311 private void ElitesParameter_ValueChanged(object sender, EventArgs e) { 305 312 Elites.ValueChanged += new EventHandler(Elites_ValueChanged); … … 330 337 ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged); 331 338 Elites.ValueChanged += new EventHandler(Elites_ValueChanged); 339 EffortParameter.ValueChanged += new EventHandler(EffortParameter_ValueChanged); 340 Effort.ValueChanged += new EventHandler(Effort_ValueChanged); 332 341 if (Problem != null) { 333 342 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); … … 356 365 foreach (ISelector selector in SelectorParameter.ValidValues) { 357 366 selector.CopySelected = new BoolValue(true); 358 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value));367 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * EffortParameter.Value.Value); 359 368 selector.NumberOfSelectedSubScopesParameter.Hidden = true; 360 369 ParameterizeStochasticOperator(selector); -
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGAMainLoop.cs
r8349 r8359 136 136 #region Create operators 137 137 VariableCreator variableCreator = new VariableCreator(); 138 Assigner assigner1 = new Assigner();139 ResultsCollector resultsCollector 1= new ResultsCollector();138 IntCounter intCounter1 = new IntCounter(); 139 ResultsCollector resultsCollector = new ResultsCollector(); 140 140 Placeholder analyzer1 = new Placeholder(); 141 141 Placeholder selector = new Placeholder(); … … 149 149 Placeholder evaluator = new Placeholder(); 150 150 WeightedParentsQualityComparator comparator1 = new WeightedParentsQualityComparator(); 151 SubScopesCounter subScopesCounter1 = new SubScopesCounter(); 151 152 ConditionalSelector conditionalSelector = new ConditionalSelector(); 152 153 RightReducer rightReducer1 = new RightReducer(); … … 155 156 DuplicateSelector duplicateSelector = new DuplicateSelector(); 156 157 LeftReducer leftReducer = new LeftReducer(); 157 SubScopesCounter subScopesCounter1 = new SubScopesCounter(); 158 IntCounter intCounter1 = new IntCounter(); 158 SubScopesCounter subScopesCounter2 = new SubScopesCounter(); 159 159 Comparator comparator2 = new Comparator(); 160 160 ConditionalBranch conditionalBranch1 = new ConditionalBranch(); … … 170 170 Placeholder analyzer2 = new Placeholder(); 171 171 ConditionalBranch conditionalBranch2 = new ConditionalBranch(); 172 Assigner assigner2 = new Assigner(); 173 SubScopesCounter subScopesCounter2 = new SubScopesCounter(); 174 ResultsCollector resultsCollector2 = new ResultsCollector(); 172 SubScopesCounter subScopesCounter3 = new SubScopesCounter(); 175 173 Comparator comparator4 = new Comparator(); 176 174 ConditionalBranch conditionalBranch3 = new ConditionalBranch(); 177 175 178 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithmexpects this to be called Generations176 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations 179 177 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0))); 180 178 181 assigner1.Name = "Initialize CurrentPopulationSize"; 182 assigner1.LeftSideParameter.ActualName = "CurrentPopulationSize"; 183 assigner1.RightSideParameter.ActualName = EvaluatedSolutionsParameter.ActualName; 184 185 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 186 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize")); 187 resultsCollector1.ResultsParameter.ActualName = "Results"; 179 intCounter1.Name = "Initialize CurrentPopulationSize"; 180 intCounter1.IncrementParameter.ActualName = PopulationSizeParameter.Name; 181 intCounter1.IncrementParameter.Value = null; 182 intCounter1.ValueParameter.ActualName = "CurrentPopulationSize"; 183 184 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 185 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize")); 186 resultsCollector.ResultsParameter.ActualName = "Results"; 188 187 189 188 analyzer1.Name = "Analyzer"; … … 215 214 comparator1.ResultParameter.ActualName = "SuccessfulOffspring"; 216 215 216 subScopesCounter1.Name = "Increment EvaluatedSolutions"; 217 subScopesCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 218 217 219 conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring"; 218 220 conditionalSelector.ConditionParameter.Depth = 1; … … 225 227 subScopesRemover.RemoveAllSubScopes = true; 226 228 227 subScopesCounter1.Name = "Count Successful Offspring"; 228 subScopesCounter1.ValueParameter.ActualName = "NumberOfSuccessfulOffspring"; 229 230 intCounter1.IncrementParameter.ActualName = "NumberOfSuccessfulOffspring"; 231 intCounter1.IncrementParameter.Value = null; 232 intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 229 subScopesCounter2.Name = "Count Successful Offspring"; 230 subScopesCounter2.ValueParameter.ActualName = "NumberOfSuccessfulOffspring"; 233 231 234 232 comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual); … … 239 237 conditionalBranch1.ConditionParameter.ActualName = "SelectMaximum"; 240 238 241 bestSelector1.CopySelected = new BoolValue( true);239 bestSelector1.CopySelected = new BoolValue(false); 242 240 bestSelector1.MaximizationParameter.ActualName = MaximizationParameter.Name; 243 241 bestSelector1.NumberOfSelectedSubScopesParameter.ActualName = MaximumPopulationSizeParameter.Name; 244 242 bestSelector1.QualityParameter.ActualName = QualityParameter.Name; 245 243 246 bestSelector2.CopySelected = new BoolValue( true);244 bestSelector2.CopySelected = new BoolValue(false); 247 245 bestSelector2.MaximizationParameter.ActualName = MaximizationParameter.Name; 248 246 bestSelector2.NumberOfSelectedSubScopesParameter.ActualName = "NumberOfSuccessfulOffspring"; … … 267 265 conditionalBranch2.ConditionParameter.ActualName = "Terminate"; 268 266 269 assigner2.Name = "Reset CurrentPopulationSize"; 270 assigner2.LeftSideParameter.ActualName = "CurrentPopulationSize"; 271 assigner2.RightSideParameter.Value = new IntValue(0); 272 273 subScopesCounter2.Name = "Set CurrentPopulationSize"; 274 subScopesCounter2.ValueParameter.ActualName = "CurrentPopulationSize"; 275 276 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize")); 277 resultsCollector2.ResultsParameter.ActualName = "Results"; 267 subScopesCounter3.Name = "Set CurrentPopulationSize"; 268 subScopesCounter3.ValueParameter.ActualName = "CurrentPopulationSize"; 269 subScopesCounter3.AccumulateParameter.Value = new BoolValue(false); 278 270 279 271 comparator4.Comparison = new Comparison(ComparisonType.Less); … … 287 279 #region Create operator graph 288 280 OperatorGraph.InitialOperator = variableCreator; 289 variableCreator.Successor = assigner1;290 assigner1.Successor = resultsCollector1;291 resultsCollector 1.Successor = analyzer1;281 variableCreator.Successor = intCounter1; 282 intCounter1.Successor = resultsCollector; 283 resultsCollector.Successor = analyzer1; 292 284 analyzer1.Successor = selector; 293 285 selector.Successor = subScopesProcessor1; … … 305 297 subScopesRemover.Successor = null; 306 298 uniformSubScopesProcessor2.Operator = evaluator; 307 uniformSubScopesProcessor2.Successor = conditionalSelector;299 uniformSubScopesProcessor2.Successor = subScopesCounter1; 308 300 evaluator.Successor = comparator1; 301 subScopesCounter1.Successor = conditionalSelector; 309 302 conditionalSelector.Successor = rightReducer1; 310 303 rightReducer1.Successor = uniformSubScopesProcessor3; … … 312 305 uniformSubScopesProcessor3.Successor = duplicateSelector; 313 306 duplicateSelector.Successor = leftReducer; 314 leftReducer.Successor = subScopesCounter1; 315 subScopesCounter1.Successor = intCounter1; 316 intCounter1.Successor = comparator2; 307 leftReducer.Successor = subScopesCounter2; 308 subScopesCounter2.Successor = comparator2; 317 309 comparator2.Successor = conditionalBranch1; 318 310 conditionalBranch1.TrueBranch = bestSelector1; … … 329 321 comparator3.Successor = analyzer2; 330 322 analyzer2.Successor = conditionalBranch2; 331 conditionalBranch2.FalseBranch = assigner2;323 conditionalBranch2.FalseBranch = subScopesCounter3; 332 324 conditionalBranch2.TrueBranch = null; 333 325 conditionalBranch2.Successor = null; 334 assigner2.Successor = subScopesCounter2; 335 subScopesCounter2.Successor = resultsCollector2; 336 resultsCollector2.Successor = comparator4; 326 subScopesCounter3.Successor = comparator4; 337 327 comparator4.Successor = conditionalBranch3; 338 328 conditionalBranch3.FalseBranch = selector;
Note: See TracChangeset
for help on using the changeset viewer.