Changeset 3650
- Timestamp:
- 05/05/10 18:54:00 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
r3616 r3650 34 34 using HeuristicLab.Random; 35 35 using HeuristicLab.Selection; 36 using HeuristicLab.Analysis; 36 37 37 38 namespace HeuristicLab.Algorithms.GeneticAlgorithm { … … 103 104 get { return (ValueParameter<BoolValue>)Parameters["Parallel"]; } 104 105 } 106 private ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>> AnalyzerParameter { 107 get { return (ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>>)Parameters["Analyzer"]; } 108 } 109 private ValueParameter<MultiAnalyzer<IPopulationAnalyzer>> IslandAnalyzerParameter { 110 get { return (ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>)Parameters["IslandAnalyzer"]; } 111 } 105 112 #endregion 106 113 … … 169 176 get { return ParallelParameter.Value; } 170 177 set { ParallelParameter.Value = value; } 178 } 179 public MultiAnalyzer<IMultiPopulationAnalyzer> Analyzer { 180 get { return AnalyzerParameter.Value; } 181 set { AnalyzerParameter.Value = value; } 182 } 183 public MultiAnalyzer<IPopulationAnalyzer> IslandAnalyzer { 184 get { return IslandAnalyzerParameter.Value; } 185 set { IslandAnalyzerParameter.Value = value; } 171 186 } 172 187 private List<ISelector> selectors; … … 189 204 get { return (IslandGeneticAlgorithmMainLoop)IslandProcessor.Successor; } 190 205 } 206 private PopulationBestAverageWorstQualityAnalyzer islandQualityAnalyzer; 207 //private MultipopulationBestAverageWorstQualityAnalyzer qualityAnalyzer; 191 208 #endregion 192 209 … … 211 228 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 212 229 Parameters.Add(new ValueParameter<BoolValue>("Parallel", "True if the islands should be run in parallel (also requires a parallel engine)", new BoolValue(false))); 213 230 Parameters.Add(new ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer<IMultiPopulationAnalyzer>())); 231 Parameters.Add(new ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer<IPopulationAnalyzer>())); 232 214 233 RandomCreator randomCreator = new RandomCreator(); 215 234 SubScopesCreator populationCreator = new SubScopesCreator(); … … 251 270 mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; 252 271 mainLoop.ResultsParameter.ActualName = "Results"; 272 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 273 mainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name; 253 274 254 275 mainLoop.Successor = null; … … 275 296 ParameterizeMainLoop(); 276 297 ParameterizeSelectors(); 298 ParameterizeAnalyzers(); 277 299 UpdateCrossovers(); 278 300 UpdateMutators(); 301 UpdateAnalyzers(); 279 302 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 280 303 base.OnProblemChanged(); … … 291 314 ParameterizeMainLoop(); 292 315 ParameterizeSelectors(); 316 ParameterizeAnalyzers(); 293 317 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 294 318 base.Problem_EvaluatorChanged(sender, e); … … 298 322 UpdateCrossovers(); 299 323 UpdateMutators(); 324 UpdateAnalyzers(); 300 325 base.Problem_OperatorsChanged(sender, e); 301 326 } … … 317 342 ParameterizeMainLoop(); 318 343 ParameterizeSelectors(); 344 ParameterizeAnalyzers(); 319 345 } 320 346 private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) { … … 331 357 private void Initialize() { 332 358 InitializeSelectors(); 359 InitializeAnalyzers(); 333 360 UpdateSelectors(); 361 UpdateAnalyzers(); 334 362 InitializeMigrators(); 335 363 UpdateMigrators(); … … 368 396 immigrationReplacers.AddRange(ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)); 369 397 ParameterizeSelectors(); 398 } 399 private void InitializeAnalyzers() { 400 islandQualityAnalyzer = new PopulationBestAverageWorstQualityAnalyzer(); 401 //qualityAnalyzer = new MultipopulationBestAverageWorstQualityAnalyzer(); 402 ParameterizeAnalyzers(); 370 403 } 371 404 private void InitializeMigrators() { … … 403 436 } 404 437 } 438 private void ParameterizeAnalyzers() { 439 islandQualityAnalyzer.ResultsParameter.ActualName = "Results"; 440 //qualityAnalyzer.ResultsParameter.ActualName = "Results"; 441 if (Problem != null) { 442 islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 443 islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 444 islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 445 } 446 } 405 447 private void UpdateSelectors() { 406 448 ISelector oldSelector = SelectorParameter.Value; … … 465 507 } 466 508 } 509 private void UpdateAnalyzers() { 510 IslandAnalyzer.Operators.Clear(); 511 Analyzer.Operators.Clear(); 512 IslandAnalyzer.Operators.Add(islandQualityAnalyzer); 513 //Analyzer.Operators.Add(qualityAnalyzer); 514 if (Problem != null) { 515 foreach (IPopulationAnalyzer analyzer in Problem.Operators.OfType<IPopulationAnalyzer>().OrderBy(x => x.Name)) { 516 IslandAnalyzer.Operators.Add(analyzer); 517 } 518 foreach (IMultiPopulationAnalyzer analyzer in Problem.Operators.OfType<IMultiPopulationAnalyzer>().OrderBy(x => x.Name)) 519 Analyzer.Operators.Add(analyzer); 520 } 521 } 467 522 #endregion 468 523 } -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs
r3616 r3650 102 102 public ValueLookupParameter<IOperator> AnalyzerParameter { 103 103 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 104 } 105 public ValueLookupParameter<IOperator> IslandAnalyzerParameter { 106 get { return (ValueLookupParameter<IOperator>)Parameters["IslandAnalyzer"]; } 104 107 } 105 108 #endregion … … 129 132 Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 130 133 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results.")); 131 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each island.")); 134 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands.")); 135 Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island.")); 132 136 #endregion 133 137 … … 136 140 UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor(); 137 141 VariableCreator islandVariableCreator = new VariableCreator(); 138 BestQualityMemorizer islandBestQualityMemorizer1 = new BestQualityMemorizer();139 BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();140 DataTableValuesCollector islandDataTableValuesCollector1 = new DataTableValuesCollector();141 QualityDifferenceCalculator islandQualityDifferenceCalculator1 = new QualityDifferenceCalculator();142 142 Placeholder islandAnalyzer1 = new Placeholder(); 143 ResultsCollector islandResultsCollector = new ResultsCollector(); 144 BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer(); 145 BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer(); 146 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator(); 147 DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector(); 148 QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator(); 149 ResultsCollector resultsCollector = new ResultsCollector(); 143 Placeholder analyzer1 = new Placeholder(); 144 ResultsCollector resultsCollector1 = new ResultsCollector(); 145 ResultsCollector resultsCollector2 = new ResultsCollector(); 150 146 UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor(); 151 147 Placeholder selector = new Placeholder(); … … 162 158 RightReducer rightReducer = new RightReducer(); 163 159 MergingReducer mergingReducer = new MergingReducer(); 164 BestQualityMemorizer islandBestQualityMemorizer2 = new BestQualityMemorizer();165 BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();166 DataTableValuesCollector islandDataTableValuesCollector2 = new DataTableValuesCollector();167 QualityDifferenceCalculator islandQualityDifferenceCalculator2 = new QualityDifferenceCalculator();168 160 Placeholder islandAnalyzer2 = new Placeholder(); 169 161 IntCounter generationsCounter = new IntCounter(); … … 179 171 Placeholder immigrationReplacer = new Placeholder(); 180 172 Comparator generationsComparator = new Comparator(); 181 BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer(); 182 BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer(); 183 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator(); 184 DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector(); 185 QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator(); 173 Placeholder analyzer2 = new Placeholder(); 174 ResultsCollector resultsCollector3 = new ResultsCollector(); 186 175 ConditionalBranch generationsTerminationCondition = new ConditionalBranch(); 187 176 … … 190 179 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); 191 180 192 islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults", new ResultCollection())); 193 194 islandBestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality"; 195 islandBestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name; 196 islandBestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name; 197 198 islandBestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality"; 199 islandBestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality"; 200 islandBestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name; 201 islandBestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name; 202 islandBestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality"; 203 204 islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality")); 205 islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality")); 206 islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality")); 207 islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 208 islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, "BestKnownQuality")); 209 islandDataTableValuesCollector1.DataTableParameter.ActualName = "Qualities"; 210 211 islandQualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 212 islandQualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 213 islandQualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 214 islandQualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality"; 215 216 islandAnalyzer1.Name = "Analyzer"; 217 islandAnalyzer1.OperatorParameter.ActualName = "Analyzer"; 218 219 islandResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 220 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality")); 221 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality")); 222 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality")); 223 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 224 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, "BestKnownQuality")); 225 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest")); 226 islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest")); 227 islandResultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities")); 228 islandResultsCollector.ResultsParameter.ActualName = "IslandResults"; 229 230 bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality"; 231 bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name; 232 bestQualityMemorizer1.QualityParameter.ActualName = "BestQuality"; 233 234 bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name; 235 bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name; 236 bestQualityMemorizer2.QualityParameter.ActualName = "BestQuality"; 237 238 bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageBestQuality"; 239 bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestBestQuality"; 240 bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name; 241 bestAverageWorstQualityCalculator1.QualityParameter.ActualName = "CurrentBestQuality"; 242 bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstBestQuality"; 243 244 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality")); 245 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality")); 246 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality")); 247 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 248 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 249 dataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities"; 250 251 qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 252 qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 253 qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 254 qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality"; 255 256 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Migrations")); 257 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality")); 258 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality")); 259 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality")); 260 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 261 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 262 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest")); 263 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest")); 264 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("BestQualities")); 265 resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("IslandResults", "Result set for each island")); 266 resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name; 181 islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection())); 182 183 islandAnalyzer1.Name = "Island Analyzer (placeholder)"; 184 islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name; 185 186 analyzer1.Name = "Analyzer (placeholder)"; 187 analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name; 188 189 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations")); 190 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 191 resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name; 192 193 resultsCollector2.Name = "Reference Island Results"; 194 resultsCollector2.CopyValue = new BoolValue(false); 195 resultsCollector2.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("IslandResults", "Result set for each island", "Results")); 196 resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name; 267 197 268 198 selector.Name = "Selector (placeholder)"; … … 290 220 bestSelector.QualityParameter.ActualName = QualityParameter.Name; 291 221 292 islandBestQualityMemorizer2.BestQualityParameter.ActualName = "BestQuality"; 293 islandBestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name; 294 islandBestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name; 295 296 islandBestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality"; 297 islandBestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality"; 298 islandBestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name; 299 islandBestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name; 300 islandBestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality"; 301 302 islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality")); 303 islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality")); 304 islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality")); 305 islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 306 islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 307 islandDataTableValuesCollector2.DataTableParameter.ActualName = "Qualities"; 308 309 islandQualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 310 islandQualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 311 islandQualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 312 islandQualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality"; 313 314 islandAnalyzer2.Name = "Analyzer"; 315 islandAnalyzer2.OperatorParameter.ActualName = "Analyzer"; 222 islandAnalyzer2.Name = "Island Analyzer (placeholder)"; 223 islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name; 316 224 317 225 generationsCounter.Name = "Generations + 1"; … … 355 263 generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name; 356 264 357 bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality"; 358 bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name; 359 bestQualityMemorizer3.QualityParameter.ActualName = "BestQuality"; 360 361 bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name; 362 bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name; 363 bestQualityMemorizer4.QualityParameter.ActualName = "BestQuality"; 364 365 bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageBestQuality"; 366 bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestBestQuality"; 367 bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name; 368 bestAverageWorstQualityCalculator2.QualityParameter.ActualName = "CurrentBestQuality"; 369 bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstBestQuality"; 370 371 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality")); 372 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality")); 373 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality")); 374 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 375 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 376 dataTableValuesCollector2.DataTableParameter.ActualName = "BestQualities"; 377 378 qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 379 qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 380 qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 381 qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality"; 265 analyzer2.Name = "Analyzer (placeholder)"; 266 analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name; 267 268 resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Migrations")); 269 resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 270 resultsCollector3.ResultsParameter.ActualName = ResultsParameter.Name; 382 271 383 272 generationsTerminationCondition.Name = "Terminate?"; … … 389 278 variableCreator.Successor = uniformSubScopesProcessor0; 390 279 uniformSubScopesProcessor0.Operator = islandVariableCreator; 391 uniformSubScopesProcessor0.Successor = bestQualityMemorizer1; 392 islandVariableCreator.Successor = islandBestQualityMemorizer1; 393 islandBestQualityMemorizer1.Successor = islandBestAverageWorstQualityCalculator1; 394 islandBestAverageWorstQualityCalculator1.Successor = islandDataTableValuesCollector1; 395 islandDataTableValuesCollector1.Successor = islandQualityDifferenceCalculator1; 396 islandQualityDifferenceCalculator1.Successor = islandAnalyzer1; 397 islandAnalyzer1.Successor = islandResultsCollector; 398 bestQualityMemorizer1.Successor = bestQualityMemorizer2; 399 bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1; 400 bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1; 401 dataTableValuesCollector1.Successor = qualityDifferenceCalculator1; 402 qualityDifferenceCalculator1.Successor = resultsCollector; 403 resultsCollector.Successor = uniformSubScopesProcessor1; 280 uniformSubScopesProcessor0.Successor = analyzer1; 281 islandVariableCreator.Successor = islandAnalyzer1; 282 islandAnalyzer1.Successor = null; 283 analyzer1.Successor = resultsCollector1; 284 resultsCollector1.Successor = resultsCollector2; 285 resultsCollector2.Successor = uniformSubScopesProcessor1; 404 286 uniformSubScopesProcessor1.Operator = selector; 405 287 uniformSubScopesProcessor1.Successor = generationsCounter; … … 423 305 bestSelector.Successor = rightReducer; 424 306 rightReducer.Successor = null; 425 mergingReducer.Successor = islandBestQualityMemorizer2; 426 islandBestQualityMemorizer2.Successor = islandBestAverageWorstQualityCalculator2; 427 islandBestAverageWorstQualityCalculator2.Successor = islandDataTableValuesCollector2; 428 islandDataTableValuesCollector2.Successor = islandQualityDifferenceCalculator2; 429 islandQualityDifferenceCalculator2.Successor = islandAnalyzer2; 307 mergingReducer.Successor = islandAnalyzer2; 430 308 islandAnalyzer2.Successor = null; 431 309 generationsCounter.Successor = generationsSinceLastMigrationCounter; … … 442 320 uniformSubScopesProcessor4.Operator = immigrationReplacer; 443 321 uniformSubScopesProcessor4.Successor = null; 444 generationsComparator.Successor = bestQualityMemorizer3; 445 bestQualityMemorizer3.Successor = bestQualityMemorizer4; 446 bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2; 447 bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2; 448 dataTableValuesCollector2.Successor = qualityDifferenceCalculator2; 449 qualityDifferenceCalculator2.Successor = generationsTerminationCondition; 322 generationsComparator.Successor = analyzer2; 323 analyzer2.Successor = resultsCollector3; 324 resultsCollector3.Successor = generationsTerminationCondition; 450 325 generationsTerminationCondition.TrueBranch = null; 451 326 generationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1; -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r3616 r3650 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Data; 27 using HeuristicLab.Operators;28 28 using HeuristicLab.Optimization; 29 29 using HeuristicLab.Optimization.Operators; … … 101 101 get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; } 102 102 } 103 private ValueParameter<MultiAnalyzer<IPopulationAnalyzer>> AnalyzerParameter { 104 get { return (ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>)Parameters["Analyzer"]; } 105 } 103 106 #endregion 104 107 … … 167 170 get { return SelectedParentsParameter.Value; } 168 171 set { SelectedParentsParameter.Value = value; } 172 } 173 public MultiAnalyzer<IPopulationAnalyzer> Analyzer { 174 get { return AnalyzerParameter.Value; } 175 set { AnalyzerParameter.Value = value; } 169 176 } 170 177 private RandomCreator RandomCreator { … … 204 211 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false))); 205 212 Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "Should be about 2 * PopulationSize, for large problems use a smaller value to decrease memory footprint.", new IntValue(200))); 206 213 Parameters.Add(new ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer<IPopulationAnalyzer>())); 214 207 215 RandomCreator randomCreator = new RandomCreator(); 208 216 SolutionsCreator solutionsCreator = new SolutionsCreator(); … … 250 258 ParameterizMainLoop(); 251 259 ParameterizeSelectors(); 260 ParameterizeAnalyzers(); 252 261 UpdateCrossovers(); 253 262 UpdateMutators(); 263 UpdateAnalyzers(); 254 264 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 255 265 base.OnProblemChanged(); … … 266 276 ParameterizMainLoop(); 267 277 ParameterizeSelectors(); 278 ParameterizeAnalyzers(); 268 279 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 269 280 base.Problem_EvaluatorChanged(sender, e); … … 273 284 UpdateCrossovers(); 274 285 UpdateMutators(); 286 UpdateAnalyzers(); 275 287 base.Problem_OperatorsChanged(sender, e); 276 288 } … … 292 304 ParameterizMainLoop(); 293 305 ParameterizeSelectors(); 306 ParameterizeAnalyzers(); 294 307 } 295 308 #endregion … … 299 312 private void Initialize() { 300 313 InitializeSelectors(); 314 InitializeAnalyzers(); 301 315 UpdateSelectors(); 316 UpdateAnalyzers(); 302 317 InitializeComparisonFactorModifiers(); 303 318 UpdateComparisonFactorModifiers(); … … 317 332 } 318 333 private void ParameterizMainLoop() { 319 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;320 334 MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 321 335 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 330 344 selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)); 331 345 ParameterizeSelectors(); 346 } 347 private void InitializeAnalyzers() { 348 //qualityAnalyzer = new PopulationBestAverageWorstQualityAnalyzer(); 349 ParameterizeAnalyzers(); 332 350 } 333 351 private void InitializeComparisonFactorModifiers() { … … 348 366 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 349 367 } 368 } 369 } 370 private void ParameterizeAnalyzers() { 371 //qualityAnalyzer.ResultsParameter.ActualName = "Results"; 372 if (Problem != null) { 373 //qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 374 //qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 375 //qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 350 376 } 351 377 } … … 406 432 } 407 433 } 434 private void UpdateAnalyzers() { 435 Analyzer.Operators.Clear(); 436 //Analyzer.Operators.Add(qualityAnalyzer); 437 if (Problem != null) { 438 foreach (IPopulationAnalyzer analyzer in Problem.Operators.OfType<IPopulationAnalyzer>().OrderBy(x => x.Name)) 439 Analyzer.Operators.Add(analyzer); 440 } 441 } 408 442 #endregion 409 443 } -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs
r3479 r3650 46 46 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; } 47 47 } 48 public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {49 get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }50 }51 48 public ValueLookupParameter<IOperator> SelectorParameter { 52 49 get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; } … … 73 70 get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; } 74 71 } 75 public ValueLookupParameter<IOperator> VisualizerParameter { 76 get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; } 77 } 78 public LookupParameter<IItem> VisualizationParameter { 79 get { return (LookupParameter<IItem>)Parameters["Visualization"]; } 72 public ValueLookupParameter<IOperator> AnalyzerParameter { 73 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 80 74 } 81 75 public ValueLookupParameter<DoubleValue> SuccessRatioParameter { … … 120 114 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.")); 121 115 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 122 Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions.")); 123 Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions.")); 116 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 124 117 Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.")); 125 118 Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).")); … … 131 124 132 125 #region Create operators 133 ConditionalBranch initializationBranch = new ConditionalBranch();134 126 VariableCreator variableCreator = new VariableCreator(); 135 Assigner variableAssigner = new Assigner();136 BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();137 BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();138 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();139 DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();140 DataTableValuesCollector selPressDataTableValuesCollector1 = new DataTableValuesCollector();141 QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();142 Placeholder visualizer1 = new Placeholder();143 ResultsCollector resultsCollector = new ResultsCollector();144 Placeholder selector = new Placeholder();145 SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();146 ChildrenCreator childrenCreator = new ChildrenCreator();147 UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();148 Placeholder crossover = new Placeholder();149 ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();150 Placeholder evaluator1 = new Placeholder();151 IntCounter evaluationCounter1 = new IntCounter();152 WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();153 StochasticBranch mutationBranch1 = new StochasticBranch();154 Placeholder mutator1 = new Placeholder();155 Placeholder evaluator2 = new Placeholder();156 IntCounter evaluationCounter2 = new IntCounter();157 StochasticBranch mutationBranch2 = new StochasticBranch();158 Placeholder mutator2 = new Placeholder();159 Placeholder evaluator3 = new Placeholder();160 IntCounter evaluationCounter3 = new IntCounter();161 WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();162 SubScopesRemover subScopesRemover = new SubScopesRemover();163 ConditionalSelector conditionalSelector = new ConditionalSelector();164 OffspringSelector offspringSelector = new OffspringSelector();165 SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();166 BestSelector bestSelector = new BestSelector();167 RightReducer rightReducer = new RightReducer();168 MergingReducer mergingReducer = new MergingReducer();169 IntCounter intCounter = new IntCounter();170 127 Placeholder comparisonFactorModifier = new Placeholder(); 171 Comparator comparator1 = new Comparator(); 172 Comparator comparator2 = new Comparator(); 173 Assigner evaluatedSolutionsAssigner = new Assigner(); 174 ResultsCollector evalSolCollector = new ResultsCollector(); 175 BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer(); 176 BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer(); 177 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator(); 178 DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector(); 179 DataTableValuesCollector selPressDataTableValuesCollector2 = new DataTableValuesCollector(); 180 QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator(); 181 Placeholder visualizer2 = new Placeholder(); 128 Placeholder analyzer1 = new Placeholder(); 129 ResultsCollector resultsCollector1 = new ResultsCollector(); 130 OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator(); 131 IntCounter generationsCounter = new IntCounter(); 132 Comparator maxGenerationsComparator = new Comparator(); 133 Comparator maxSelectionPressureComparator = new Comparator(); 134 Placeholder analyzer2 = new Placeholder(); 135 ResultsCollector resultsCollector2 = new ResultsCollector(); 182 136 ConditionalBranch conditionalBranch1 = new ConditionalBranch(); 183 137 ConditionalBranch conditionalBranch2 = new ConditionalBranch(); 184 138 185 initializationBranch.ConditionParameter.ActualName = "IsInitialized"; 186 187 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // this variable is referenced in SASEGASAMainLoop, do not change! 139 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); 188 140 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0))); 189 141 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0))); 190 142 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0))); 191 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0)));192 variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsInitialized", new BoolValue(true)));193 194 variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor"; // this variable is referenced in SASEGASA, OffspringSelectionGeneticAlgorithm, do not change!195 variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;196 197 bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";198 bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;199 bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;200 201 bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;202 bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;203 bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;204 205 bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";206 bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";207 bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;208 bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;209 bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";210 211 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));212 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));213 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));214 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));215 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));216 dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";217 218 selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));219 selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));220 selPressDataTableValuesCollector1.DataTableParameter.ActualName = "SelectionPressures";221 222 qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";223 qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;224 qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";225 qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";226 227 visualizer1.Name = "Visualizer (placeholder)";228 visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name;229 230 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));231 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));232 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));233 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));234 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));235 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));236 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));237 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));238 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));239 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));240 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));241 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));242 resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));243 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));244 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));245 resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;246 247 selector.Name = "Selector (placeholder)";248 selector.OperatorParameter.ActualName = SelectorParameter.Name;249 250 childrenCreator.ParentsPerChild = new IntValue(2);251 252 crossover.Name = "Crossover (placeholder)";253 crossover.OperatorParameter.ActualName = CrossoverParameter.Name;254 255 osBeforeMutationBranch.Name = "Apply OS before mutation?";256 osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;257 258 evaluator1.Name = "Evaluator (placeholder)";259 evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;260 261 evaluationCounter1.Name = "EvaluatedSolutions++";262 evaluationCounter1.Increment = new IntValue(1);263 evaluationCounter1.ValueParameter.ActualName = "EvaluatedSolutions";264 265 qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor";266 qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;267 qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;268 qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;269 qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";270 271 mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;272 mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;273 274 mutator1.Name = "Mutator (placeholder)";275 mutator1.OperatorParameter.ActualName = MutatorParameter.Name;276 277 evaluator2.Name = "Evaluator (placeholder)";278 evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;279 280 evaluationCounter2.Name = "EvaluatedSolutions++";281 evaluationCounter2.Increment = new IntValue(1);282 evaluationCounter2.ValueParameter.ActualName = "EvaluatedSolutions";283 284 mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;285 mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;286 287 mutator2.Name = "Mutator (placeholder)";288 mutator2.OperatorParameter.ActualName = MutatorParameter.Name;289 290 evaluator3.Name = "Evaluator (placeholder)";291 evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;292 293 evaluationCounter3.Name = "EvaluatedSolutions++";294 evaluationCounter3.Increment = new IntValue(1);295 evaluationCounter3.ValueParameter.ActualName = "EvaluatedSolutions";296 297 qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor";298 qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;299 qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;300 qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;301 qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";302 303 subScopesRemover.RemoveAllSubScopes = true;304 305 conditionalSelector.CopySelected = new BoolValue(false);306 conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";307 308 offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";309 offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers";310 offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;311 offspringSelector.SelectionPressureParameter.ActualName = "SelectionPressure";312 offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;313 offspringSelector.WinnersParameter.ActualName = "OSWinners";314 315 bestSelector.CopySelected = new BoolValue(false);316 bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;317 bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;318 bestSelector.QualityParameter.ActualName = QualityParameter.Name;319 320 intCounter.Increment = new IntValue(1);321 intCounter.ValueParameter.ActualName = "Generations";322 143 323 144 comparisonFactorModifier.Name = "Modify ComparisonFactor (placeholder)"; 324 145 comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name; 325 146 326 comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 327 comparator1.LeftSideParameter.ActualName = "Generations"; 328 comparator1.ResultParameter.ActualName = "TerminateMaximumGenerations"; 329 comparator1.RightSideParameter.ActualName = MaximumGenerationsParameter.Name; 330 331 comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 332 comparator2.LeftSideParameter.ActualName = "SelectionPressure"; 333 comparator2.ResultParameter.ActualName = "TerminateSelectionPressure"; 334 comparator2.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name; 335 336 evaluatedSolutionsAssigner.LeftSideParameter.ActualName = "EvaluatedSolutionsResult"; 337 evaluatedSolutionsAssigner.RightSideParameter.ActualName = "EvaluatedSolutions"; 338 339 evalSolCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult")); 340 evalSolCollector.ResultsParameter.ActualName = ResultsParameter.Name; 341 342 bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality"; 343 bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name; 344 bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name; 345 346 bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name; 347 bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name; 348 bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name; 349 350 bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality"; 351 bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality"; 352 bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name; 353 bestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name; 354 bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality"; 355 356 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality")); 357 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality")); 358 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality")); 359 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 360 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 361 dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities"; 362 363 selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure")); 364 selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name)); 365 selPressDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures"; 366 367 qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 368 qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 369 qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 370 qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality"; 371 372 visualizer2.Name = "Visualizer (placeholder)"; 373 visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name; 147 analyzer1.Name = "Analyzer (placeholder)"; 148 analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name; 149 150 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 151 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions")); 152 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor")); 153 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure")); 154 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio")); 155 resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name; 156 157 mainOperator.ComparisonFactorParameter.ActualName = "ComparisonFactor"; 158 mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name; 159 mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio"; 160 mainOperator.ElitesParameter.ActualName = ElitesParameter.Name; 161 mainOperator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; 162 mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name; 163 mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name; 164 mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; 165 mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name; 166 mainOperator.MutatorParameter.ActualName = MutatorParameter.Name; 167 mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; 168 mainOperator.QualityParameter.ActualName = QualityParameter.Name; 169 mainOperator.RandomParameter.ActualName = RandomParameter.Name; 170 mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure"; 171 mainOperator.SelectorParameter.ActualName = SelectorParameter.Name; 172 mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 173 174 generationsCounter.Increment = new IntValue(1); 175 generationsCounter.ValueParameter.ActualName = "Generations"; 176 177 maxGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 178 maxGenerationsComparator.LeftSideParameter.ActualName = "Generations"; 179 maxGenerationsComparator.ResultParameter.ActualName = "TerminateMaximumGenerations"; 180 maxGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name; 181 182 maxSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 183 maxSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure"; 184 maxSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure"; 185 maxSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name; 186 187 analyzer2.Name = "Analyzer (placeholder)"; 188 analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name; 189 190 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 191 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions")); 192 resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor")); 193 resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure")); 194 resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio")); 195 resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name; 374 196 375 197 conditionalBranch1.Name = "MaximumSelectionPressure reached?"; … … 377 199 378 200 conditionalBranch2.Name = "MaximumGenerations reached?"; 379 conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations"; // this variable is referenced in SASEGASAMainLoop, do not change!201 conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations"; 380 202 #endregion 381 203 382 204 #region Create operator graph 383 OperatorGraph.InitialOperator = initializationBranch; 384 initializationBranch.FalseBranch = variableCreator; 385 initializationBranch.Successor = selector; 386 variableCreator.Successor = variableAssigner; 387 variableAssigner.Successor = bestQualityMemorizer1; 388 bestQualityMemorizer1.Successor = bestQualityMemorizer2; 389 bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1; 390 bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1; 391 dataTableValuesCollector1.Successor = selPressDataTableValuesCollector1; 392 selPressDataTableValuesCollector1.Successor = qualityDifferenceCalculator1; 393 qualityDifferenceCalculator1.Successor = visualizer1; 394 visualizer1.Successor = resultsCollector; 395 resultsCollector.Successor = null; 396 selector.Successor = subScopesProcessor1; 397 subScopesProcessor1.Operators.Add(new EmptyOperator()); 398 subScopesProcessor1.Operators.Add(childrenCreator); 399 subScopesProcessor1.Successor = offspringSelector; 400 childrenCreator.Successor = uniformSubScopesProcessor; 401 uniformSubScopesProcessor.Operator = crossover; 402 uniformSubScopesProcessor.Successor = conditionalSelector; 403 crossover.Successor = osBeforeMutationBranch; 404 osBeforeMutationBranch.TrueBranch = evaluator1; 405 osBeforeMutationBranch.FalseBranch = mutationBranch2; 406 osBeforeMutationBranch.Successor = subScopesRemover; 407 evaluator1.Successor = evaluationCounter1; 408 evaluationCounter1.Successor = qualityComparer1; 409 qualityComparer1.Successor = mutationBranch1; 410 mutationBranch1.FirstBranch = mutator1; 411 mutationBranch1.SecondBranch = null; 412 mutationBranch1.Successor = null; 413 mutator1.Successor = evaluator2; 414 evaluator2.Successor = evaluationCounter2; 415 evaluationCounter2.Successor = null; 416 mutationBranch2.FirstBranch = mutator2; 417 mutationBranch2.SecondBranch = null; 418 mutationBranch2.Successor = evaluator3; 419 mutator2.Successor = null; 420 evaluator3.Successor = evaluationCounter3; 421 evaluationCounter3.Successor = qualityComparer2; 422 subScopesRemover.Successor = null; 423 offspringSelector.OffspringCreator = selector; 424 offspringSelector.Successor = subScopesProcessor2; 425 subScopesProcessor2.Operators.Add(bestSelector); 426 subScopesProcessor2.Operators.Add(new EmptyOperator()); 427 subScopesProcessor2.Successor = mergingReducer; 428 bestSelector.Successor = rightReducer; 429 rightReducer.Successor = null; 430 mergingReducer.Successor = intCounter; 431 intCounter.Successor = comparisonFactorModifier; 432 comparisonFactorModifier.Successor = comparator1; 433 comparator1.Successor = comparator2; 434 comparator2.Successor = evaluatedSolutionsAssigner; 435 evaluatedSolutionsAssigner.Successor = evalSolCollector; 436 evalSolCollector.Successor = bestQualityMemorizer3; 437 bestQualityMemorizer3.Successor = bestQualityMemorizer4; 438 bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2; 439 bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2; 440 dataTableValuesCollector2.Successor = selPressDataTableValuesCollector2; 441 selPressDataTableValuesCollector2.Successor = qualityDifferenceCalculator2; 442 qualityDifferenceCalculator2.Successor = visualizer2; 443 visualizer2.Successor = conditionalBranch1; 205 OperatorGraph.InitialOperator = variableCreator; 206 variableCreator.Successor = comparisonFactorModifier; 207 comparisonFactorModifier.Successor = analyzer1; 208 analyzer1.Successor = resultsCollector1; 209 resultsCollector1.Successor = mainOperator; 210 mainOperator.Successor = generationsCounter; 211 generationsCounter.Successor = maxGenerationsComparator; 212 maxGenerationsComparator.Successor = maxSelectionPressureComparator; 213 maxSelectionPressureComparator.Successor = analyzer2; 214 analyzer2.Successor = resultsCollector2; 215 resultsCollector2.Successor = conditionalBranch1; 444 216 conditionalBranch1.FalseBranch = conditionalBranch2; 445 217 conditionalBranch1.TrueBranch = null; 446 218 conditionalBranch1.Successor = null; 447 conditionalBranch2.FalseBranch = selector;219 conditionalBranch2.FalseBranch = mainOperator; 448 220 conditionalBranch2.TrueBranch = null; 449 221 conditionalBranch2.Successor = null;
Note: See TracChangeset
for help on using the changeset viewer.