Changeset 13604
- Timestamp:
- 02/08/16 15:55:31 (9 years ago)
- Location:
- branches/IslandALPS/IslandALPS/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj
r13595 r13604 105 105 </ItemGroup> 106 106 <ItemGroup> 107 <Compile Include="LayerMigrator.cs" /> 107 108 <Compile Include="ResultsExtractor.cs" /> 108 109 <Compile Include="IslandALPSAlgorithm.cs" /> -
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
r13595 r13604 83 83 get { return (IValueParameter<IntValue>)Parameters["MigrationInterval"]; } 84 84 } 85 85 public IConstrainedValueParameter<IMigrator> MigratorParameter { 86 get { return (IConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; } 87 } 88 public IConstrainedValueParameter<ISelector> EmigrantsSelectorParameter { 89 get { return (IConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; } 90 } 91 public IConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter { 92 get { return (IConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; } 93 } 86 94 #endregion 87 95 … … 284 292 Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number Generations before a migration occurs.", new IntValue(20))); 285 293 Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); 294 Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy.")); 295 Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); 296 Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants.")); 286 297 287 298 #endregion … … 429 440 UpdateTerminators(); 430 441 ParameterizeAgeLimits(); 442 ParametrizeMigration(); 431 443 #endregion 432 444 … … 585 597 ElitesParameter.ValueChanged += ElitesParameter_ValueChanged; 586 598 Elites.ValueChanged += Elites_ValueChanged; 599 MigrationRateParameter.Value.ValueChanged += MigrationRate_ValueChanged; 600 MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged; 587 601 588 602 Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded; … … 603 617 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 604 618 619 } 620 621 private void MigrationRate_ValueChanged(object sender, EventArgs e) { 622 var migrationSize = (int)Math.Ceiling(MigrationRateParameter.Value.Value * PopulationSize.Value); 623 foreach (var selector in EmigrantsSelectorParameter.ValidValues) { 624 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); 625 } 605 626 } 606 627 … … 719 740 MainLoop.NumberOfLayersParameter.ActualName = NumberOfLayersParameter.Name; 720 741 MainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name; 742 MainLoop.MigratorParameter.ActualName = MigratorParameter.Name; 743 MainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name; 744 MainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name; 745 746 747 721 748 MainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name; 722 749 MainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize"; … … 738 765 } 739 766 767 private void ParametrizeMigration() { 768 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value *PopulationSize.Value); 769 foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) { 770 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); 771 selector.NumberOfSelectedSubScopesParameter.Hidden = true; 772 773 ParameterizeStochasticOperatorForLayer(selector); 774 775 EmigrantsSelectorParameter.ValidValues.Add(selector); 776 } 777 778 foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) { 779 ParameterizeStochasticOperatorForLayer(replacer); 780 ImmigrationReplacerParameter.ValidValues.Add(replacer); 781 } 782 783 MigratorParameter.ValidValues.Add(new LayerMigrator()); 784 } 785 740 786 private void ParameterizeSolutionsCreator() { 741 787 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; … … 750 796 ParameterizeStochasticOperatorForLayer(selector); 751 797 } 798 752 799 if (Problem != null) { 753 800 foreach (var selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) { 754 selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 755 selector.MaximizationParameter.Hidden = true; 756 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 757 selector.QualityParameter.Hidden = true; 758 } 759 } 801 ParametrizeSingleObjectiveSelector(selector); 802 } 803 foreach (var replacer in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) { 804 ParametrizeSingleObjectiveSelector(replacer); 805 } 806 foreach (var selector in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveSelector>()) { 807 ParametrizeSingleObjectiveSelector(selector); 808 } 809 810 } 811 } 812 813 private void ParametrizeSingleObjectiveSelector(ISingleObjectiveSelector selector) { 814 selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 815 selector.MaximizationParameter.Hidden = true; 816 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 817 selector.QualityParameter.Hidden = true; 760 818 } 761 819 -
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorthmsMainLoop.cs
r13595 r13604 225 225 var resultsCollector = new ResultsCollector(); 226 226 227 var processIslandsUssp = new UniformSubScopesProcessor() {Name = "Process Islands" };227 var processIslandsUssp = new UniformSubScopesProcessor() {Name = "Process Islands", Parallel = new BoolValue(true)}; 228 228 var initIslandGenerationsAss = new Assigner() {Name = "Init Island Generations"}; 229 229 var initIslandEvaluationsAss = new Assigner() {Name = "Init Island Evaluations"}; … … 231 231 var incrementGenerationDr = new DataReducer() { Name = "Increment Generations" }; 232 232 var incrementEvaluatedSolutionDr = new DataReducer() { Name = "Increment Evaluated Solutions" }; 233 //TODO: increase migration count + migrate234 233 235 234 var elderMigrator = CreateEldersEmigrator(); … … 250 249 var groupResultsExtractor = new ResultsExtractor() {Name = "Collect group results into variable"}; 251 250 var groupResultsCollector = new ResultsCollector() {Name = "Collect group results into into global results"}; 252 251 var groupLayerNumberResultsCollector = new ResultsCollector() {Name = "Add Layernumber to Results"}; 253 252 254 253 var matingPoolCreator = new MatingPoolCreator(); 255 254 var matingPoolUssp = new UniformSubScopesProcessor() {Name = "Process Mating Pools"}; 256 var alpsMainOperator = new AlpsGeneticAlgorithmMainOperator();255 var alpsMainOperator = new AlpsGeneticAlgorithmMainOperator(); 257 256 258 257 var incrementIslandGeneration = new IntCounter() {Name = "incrementIslandGeneration" }; 259 258 var setIslandEvaluatedSolutions = new DataReducer() {Name = "Set IslandEvaluatedSolutions" }; 259 260 var migrationCounter = new IntCounter() {Name = "Increment Migrations"}; 261 var selectforMigrationUssp = new UniformSubScopesProcessor(); 262 var emigrantSelector = new Placeholder() {Name = "Emigrant Selector (Placeholder)"}; 263 var migrator = new LayerMigrator(); 264 var replaceforMigrationUssp = new UniformSubScopesProcessor(); 265 var immigrantSelector = new Placeholder() { Name = "Immigrant Replacer (Placeholder)" }; 260 266 261 267 var migrateComparator = new Comparator(); … … 283 289 resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults","","IslandResults")); 284 290 resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("GroupResults","","GroupResults")); 291 resultsCollector.CollectedValues.Add(new ValueLookupParameter<IntValue>("Migrations")); 285 292 resultsCollector.CopyValue = new BoolValue(false); 286 293 … … 314 321 migrateCondBranch.ConditionParameter.ActualName = "Migrate"; 315 322 323 migrationCounter.ValueParameter.ActualName = "Migrations"; 324 selectforMigrationUssp.Depth = new IntValue(2); 325 emigrantSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name; 326 327 replaceforMigrationUssp.Depth = new IntValue(2); 328 immigrantSelector.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name; 329 316 330 groupAnalyzer.OperatorParameter.ActualName = GroupAnalyzerParameter.Name; 331 groupLayerNumberResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("LayerNumber")); 332 groupLayerNumberResultsCollector.ResultsParameter.ActualName = "GroupResults"; 333 317 334 layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name; 318 335 layerResultsCollector.ResultsParameter.ActualName = "LayerResults"; … … 384 401 processIslandsUssp.Successor = incrementGenerationDr; 385 402 incrementGenerationDr.Successor = incrementEvaluatedSolutionDr; 386 incrementEvaluatedSolutionDr.Successor = globalAnalyzerPlacerholder; 403 incrementEvaluatedSolutionDr.Successor = migrationCounter; 404 405 migrationCounter.Successor = selectforMigrationUssp; 406 selectforMigrationUssp.Operator = emigrantSelector; 407 emigrantSelector.Successor = null; 408 selectforMigrationUssp.Successor = migrator; 409 410 migrator.Successor = replaceforMigrationUssp; 411 replaceforMigrationUssp.Operator = immigrantSelector; 412 immigrantSelector.Successor = null; 413 replaceforMigrationUssp.Successor = globalAnalyzerPlacerholder; 414 387 415 globalAnalyzerPlacerholder.Successor = groupingOperator; 388 416 groupingOperator.Operator = groupAnalyzer; 389 groupAnalyzer.Successor = null; 417 groupAnalyzer.Successor = groupLayerNumberResultsCollector; 418 groupLayerNumberResultsCollector.Successor = null; 390 419 groupingOperator.Successor = groupResultsExtractor; 391 420 groupResultsExtractor.Successor = groupResultsCollector;
Note: See TracChangeset
for help on using the changeset viewer.