Changeset 13595
- Timestamp:
- 02/08/16 10:15:36 (9 years ago)
- Location:
- branches/IslandALPS/IslandALPS
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/IslandALPS/IslandALPS
-
Property
svn:global-ignores
set to
.vs
-
Property
svn:global-ignores
set to
-
branches/IslandALPS/IslandALPS/3.3
-
Property
svn:global-ignores
set to
.vs
obj
-
Property
svn:global-ignores
set to
-
branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj
r13493 r13595 105 105 </ItemGroup> 106 106 <ItemGroup> 107 <Compile Include="ResultsExtractor.cs" /> 107 108 <Compile Include="IslandALPSAlgorithm.cs" /> 108 109 <Compile Include="IslandALPSAlgorthmsMainLoop.cs" /> 109 110 <Compile Include="Plugin.cs" /> 110 111 <Compile Include="Properties\AssemblyInfo.cs" /> 112 <Compile Include="GroupedLayerOperator.cs" /> 111 113 </ItemGroup> 112 114 <ItemGroup> -
branches/IslandALPS/IslandALPS/3.3/IslandALPS
-
Property
svn:global-ignores
set to
bin
obj
-
Property
svn:global-ignores
set to
-
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
r13493 r13595 62 62 get { return (IValueParameter<MultiAnalyzer>)Parameters["LayerAnalyzer"]; } 63 63 } 64 private IValueParameter<MultiAnalyzer> GroupAnalyzerParameter { 65 get { return (IValueParameter<MultiAnalyzer>)Parameters["GroupAnalyzer"]; } 66 } 64 67 private IValueParameter<BoolValue> PlusSelectionParameter { 65 68 get { return (IValueParameter<BoolValue>)Parameters["PlusSelection"]; } … … 149 152 set { LayerAnalyzerParameter.Value = value; } 150 153 } 154 public MultiAnalyzer GroupAnalyzer { 155 get { return GroupAnalyzerParameter.Value; } 156 set { GroupAnalyzerParameter.Value = value; } 157 } 151 158 public ISelector Selector { 152 159 get { return SelectorParameter.Value; } … … 224 231 [Storable] private readonly BestAverageWorstQualityAnalyzer islandQualityAnalyzer; 225 232 [Storable] private readonly BestAverageWorstQualityAnalyzer layerQualityAnalyzer; 233 [Storable] private readonly BestAverageWorstQualityAnalyzer groupQualityAnalyzer; 226 234 227 235 #endregion … … 246 254 islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer); 247 255 layerQualityAnalyzer = cloner.Clone(original.layerQualityAnalyzer); 256 groupQualityAnalyzer = cloner.Clone(original.groupQualityAnalyzer); 248 257 //terminator 249 258 generationsTerminator = cloner.Clone(original.generationsTerminator); … … 266 275 Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "", new IntValue(10))); 267 276 Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer())); 277 Parameters.Add(new ValueParameter<MultiAnalyzer>("GroupAnalyzer", "The operator used to analyze each layergroup.", new MultiAnalyzer())); 268 278 Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.", new BoolValue(false))); 269 279 … … 334 344 islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 335 345 layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 346 groupQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 336 347 #endregion 337 348 … … 519 530 LayerAnalyzer.Operators.Clear(); 520 531 IslandAnalyzer.Operators.Clear(); 532 GroupAnalyzer.Operators.Clear(); 521 533 Analyzer.Operators.Clear(); 522 534 523 535 //add analyzer 536 GroupAnalyzer.Operators.Add(groupQualityAnalyzer, groupQualityAnalyzer.EnabledByDefault); 524 537 LayerAnalyzer.Operators.Add(layerQualityAnalyzer, layerQualityAnalyzer.EnabledByDefault); 525 538 IslandAnalyzer.Operators.Add(islandQualityAnalyzer, islandQualityAnalyzer.EnabledByDefault); 526 539 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 527 528 540 //depth for each analyzer gets set when added 529 541 if (Problem != null) { … … 532 544 IslandAnalyzer.Operators.Add((IAnalyzer)analyzer.Clone(),false); 533 545 LayerAnalyzer.Operators.Add((IAnalyzer)analyzer.Clone(), false); 546 GroupAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(),false); 534 547 } 535 548 } … … 576 589 IslandAnalyzer.Operators.ItemsAdded += IslandAnalyzerOperators_ItemsAdded; 577 590 LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded; 591 GroupAnalyzer.Operators.ItemsAdded += GroupAnalyzerOperators_ItemsAdded; 578 592 579 593 if (Problem != null) { … … 589 603 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 590 604 605 } 606 607 private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 608 foreach (var analyzer in e.Items) { 609 IParameter resultParameter; 610 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 611 var lookupParameter = resultParameter as ILookupParameter; 612 if (lookupParameter != null) 613 lookupParameter.ActualName = "GroupResults"; 614 } 615 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 616 parameter.Depth = 1; 617 } 618 } 591 619 } 592 620 … … 685 713 686 714 MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 687 MainLoop.LayerEvaluatedSolutionsParameter.ActualName = " EvaluatedSolutions";715 MainLoop.LayerEvaluatedSolutionsParameter.ActualName = "LayerEvaluatedSolutions"; 688 716 689 717 MainLoop.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name; … … 700 728 MainLoop.TerminatorParameter.ActualName = TerminatorParameter.Name; 701 729 730 MainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 731 MainLoop.LayerAnalyzerParameter.ActualName = LayerAnalyzerParameter.Name; 732 MainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name; 733 MainLoop.GroupAnalyzerParameter.ActualName = GroupAnalyzerParameter.Name; 734 735 702 736 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 703 737 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 735 769 qualityAnalyzer.ResultsParameter.ActualName = "Results"; 736 770 qualityAnalyzer.ResultsParameter.Hidden = true; 737 771 772 groupQualityAnalyzer.ResultsParameter.ActualName = "GroupResults"; 773 groupQualityAnalyzer.ResultsParameter.Hidden = true; 738 774 739 775 if (Problem != null) { 740 741 layerQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 742 layerQualityAnalyzer.MaximizationParameter.Hidden = true; 743 layerQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 744 layerQualityAnalyzer.QualityParameter.Hidden = true; 745 layerQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 746 layerQualityAnalyzer.BestKnownQualityParameter.Hidden = true; 747 islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 748 islandQualityAnalyzer.MaximizationParameter.Hidden = true; 749 islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 750 islandQualityAnalyzer.QualityParameter.Hidden = true; 751 islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 752 islandQualityAnalyzer.BestKnownQualityParameter.Hidden = true; 753 qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 754 qualityAnalyzer.MaximizationParameter.Hidden = true; 755 qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 756 qualityAnalyzer.QualityParameter.Hidden = true; 757 qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 758 qualityAnalyzer.BestKnownQualityParameter.Hidden = true; 759 } 776 SetAnalyzerParameter(layerQualityAnalyzer); 777 SetAnalyzerParameter(islandQualityAnalyzer); 778 SetAnalyzerParameter(qualityAnalyzer); 779 SetAnalyzerParameter(groupQualityAnalyzer); 780 } 781 } 782 783 private void SetAnalyzerParameter(BestAverageWorstQualityAnalyzer analyzer) { 784 analyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 785 analyzer.MaximizationParameter.Hidden = true; 786 analyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 787 analyzer.QualityParameter.Hidden = true; 788 analyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 789 analyzer.BestKnownQualityParameter.Hidden = true; 760 790 } 761 791 -
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorthmsMainLoop.cs
r13493 r13595 80 80 get { return (ValueLookupParameter<IOperator>)Parameters["LayerAnalyzer"]; } 81 81 } 82 83 public ValueLookupParameter<IOperator> GroupAnalyzerParameter { 84 get { return (ValueLookupParameter<IOperator>)Parameters["GroupAnalyzer"]; } 85 } 86 82 87 public LookupParameter<IntValue> LayerEvaluatedSolutionsParameter { 83 88 get { return (LookupParameter<IntValue>)Parameters["LayerEvaluatedSolutions"]; } … … 196 201 Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island.")); 197 202 Parameters.Add(new ValueLookupParameter<IOperator>("LayerAnalyzer", "The operator used to analyze each Layer.")); 203 Parameters.Add(new ValueLookupParameter<IOperator>("GroupAnalyzer", "The operator used to analyze each Layergroup.")); 204 198 205 Parameters.Add(new LookupParameter<IntValue>("LayerEvaluatedSolutions", "The number of times a solution has been evaluated.")); 199 206 Parameters.Add(new LookupParameter<IntValue>("IslandGenerations", "The number of generations calculated on one island.")); … … 208 215 var islandVarCreatorUssp = new UniformSubScopesProcessor(); 209 216 var islandVariableCreator = new VariableCreator() {Name = "Initialize Results"}; 217 var groupVariableCreator = new VariableCreator() {Name = "Initialize Group Results"}; 210 218 211 219 var layerUssp = new UniformSubScopesProcessor(); … … 221 229 var initIslandEvaluationsAss = new Assigner() {Name = "Init Island Evaluations"}; 222 230 223 var incrementGenerationDr = new IntCounter(){ Name = "Increment Generations" };231 var incrementGenerationDr = new DataReducer() { Name = "Increment Generations" }; 224 232 var incrementEvaluatedSolutionDr = new DataReducer() { Name = "Increment Evaluated Solutions" }; 225 233 //TODO: increase migration count + migrate … … 234 242 var layerResultsCollector = new ResultsCollector() {Name = "Collect Additional Infos"}; 235 243 var islandAnalyzerPlaceholder = new Placeholder() { Name = "Island Analyzer (Placeholder)" }; 244 var islandResultsCollector = new ResultsCollector() { Name = "Collect layer results into IslandResults" }; 245 236 246 var globalAnalyzerPlacerholder = new Placeholder() { Name = "Global Analyzer (Placeholder)" }; 247 248 var groupingOperator = new GroupedLayerOperator() {Name = "Grouped Analyzer"}; 249 var groupAnalyzer = new Placeholder() {Name = "Group Analyzer (Placeholder)"}; 250 var groupResultsExtractor = new ResultsExtractor() {Name = "Collect group results into variable"}; 251 var groupResultsCollector = new ResultsCollector() {Name = "Collect group results into into global results"}; 252 237 253 238 254 var matingPoolCreator = new MatingPoolCreator(); 239 255 var matingPoolUssp = new UniformSubScopesProcessor() {Name = "Process Mating Pools"}; 240 256 var alpsMainOperator =new AlpsGeneticAlgorithmMainOperator(); 257 258 var incrementIslandGeneration = new IntCounter() {Name = "incrementIslandGeneration" }; 259 var setIslandEvaluatedSolutions = new DataReducer() {Name = "Set IslandEvaluatedSolutions" }; 260 261 var migrateComparator = new Comparator(); 262 var migrateCondBranch = new ConditionalBranch() {Name = "Migrate?"}; 241 263 242 264 var terminator = new TerminationOperator(); … … 245 267 globalVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations",new IntValue(0))); 246 268 247 islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>( "IslandGenerations", new IntValue(0)));269 islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>(IslandGenerations.Name, new IntValue(0))); 248 270 islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OpenLayers", new IntValue(1))); 249 271 islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults")); … … 252 274 layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("LayerResults")); 253 275 276 groupVariableCreator.CollectedValues.Add((new ValueParameter<ResultCollection>("GroupResults"))); 277 //TODO: groupAnalyze 254 278 initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name; 255 256 279 initIslandAnalyzerPlaceholder.OperatorParameter.ActualName = IslandAnalyzerParameter.Name; 257 258 280 initGlobalAnalyzerPlacerholder.OperatorParameter.ActualName = AnalyzerParameter.Name; 259 281 260 282 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 261 283 resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults","","IslandResults")); 262 resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>(" LayerResults","","LayerResults",2));284 resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("GroupResults","","GroupResults")); 263 285 resultsCollector.CopyValue = new BoolValue(false); 264 286 … … 269 291 initIslandEvaluationsAss.RightSideParameter.Value = new IntValue(0); 270 292 271 incrementGenerationDr.ValueParameter.ActualName = "Generations"; 272 incrementGenerationDr.Increment = new IntValue(1); 273 274 incrementEvaluatedSolutionDr.ParameterToReduce.ActualName = LayerEvaluatedSolutionsParameter.Name; 293 incrementGenerationDr.TargetParameter.ActualName = "Generations"; 294 incrementGenerationDr.ParameterToReduce.ActualName = IslandGenerations.Name; 295 incrementGenerationDr.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum); 296 incrementGenerationDr.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Min); 297 298 incrementEvaluatedSolutionDr.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name; 275 299 incrementEvaluatedSolutionDr.TargetParameter.ActualName = EvaluatedSolutions.Name; 276 300 incrementEvaluatedSolutionDr.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 277 301 incrementEvaluatedSolutionDr.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum); 278 302 303 incrementIslandGeneration.ValueParameter.ActualName = IslandGenerations.Name; 304 setIslandEvaluatedSolutions.ParameterToReduce.ActualName = LayerEvaluatedSolutionsParameter.Name; 305 setIslandEvaluatedSolutions.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 306 setIslandEvaluatedSolutions.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); 307 setIslandEvaluatedSolutions.TargetParameter.ActualName = IslandEvaluatedSolutions.Name; 308 309 migrateComparator.Comparison.Value = ComparisonType.GreaterOrEqual; 310 migrateComparator.LeftSideParameter.ActualName = IslandGenerations.Name; 311 migrateComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name; 312 migrateComparator.ResultParameter.ActualName = "Migrate"; 313 314 migrateCondBranch.ConditionParameter.ActualName = "Migrate"; 315 316 groupAnalyzer.OperatorParameter.ActualName = GroupAnalyzerParameter.Name; 279 317 layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name; 280 318 layerResultsCollector.ResultsParameter.ActualName = "LayerResults"; 281 319 layerResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Layer")); 282 320 islandAnalyzerPlaceholder.OperatorParameter.ActualName = IslandAnalyzerParameter.Name; 321 islandResultsCollector.ResultsParameter.ActualName = "IslandResults"; 322 islandResultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("LayerResults")); 283 323 globalAnalyzerPlacerholder.OperatorParameter.ActualName = AnalyzerParameter.Name; 284 324 325 //TODO: implement check for grouped layer analyzer 326 groupResultsExtractor.SourceNameParameter.Value = new StringValue("GroupScope"); 327 groupResultsExtractor.TargetNameParameter.Value = new StringValue("GroupResults"); 328 groupResultsCollector.CollectedValues.Add(new LookupParameter<ItemArray<ResultCollection>>("GroupResults")); 285 329 matingPoolCreator.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name; 286 330 … … 328 372 layerAnalyzerPlaceholder.Successor = layerResultsCollector; 329 373 layerResultsCollector.Successor = null; 374 330 375 analyzeLayerUssp.Successor = islandAnalyzerPlaceholder; 331 islandAnalyzerPlaceholder.Successor = null; 376 islandAnalyzerPlaceholder.Successor = islandResultsCollector; 377 islandResultsCollector.Successor = setIslandEvaluatedSolutions; 378 setIslandEvaluatedSolutions.Successor = incrementIslandGeneration; 379 incrementIslandGeneration.Successor = migrateComparator; 380 migrateComparator.Successor = migrateCondBranch; 381 migrateCondBranch.FalseBranch = matingPoolCreator; 382 migrateCondBranch.TrueBranch = null; 383 332 384 processIslandsUssp.Successor = incrementGenerationDr; 333 385 incrementGenerationDr.Successor = incrementEvaluatedSolutionDr; 334 386 incrementEvaluatedSolutionDr.Successor = globalAnalyzerPlacerholder; 335 globalAnalyzerPlacerholder.Successor = terminator; 387 globalAnalyzerPlacerholder.Successor = groupingOperator; 388 groupingOperator.Operator = groupAnalyzer; 389 groupAnalyzer.Successor = null; 390 groupingOperator.Successor = groupResultsExtractor; 391 groupResultsExtractor.Successor = groupResultsCollector; 392 groupResultsCollector.Successor = terminator; 336 393 terminator.ContinueBranch = processIslandsUssp; 337 394 … … 454 511 createChildrenViaCrossover.Successor = incrEvaluatedSolutionsForNewLayer; 455 512 456 incrEvaluatedSolutionsForNewLayer.ValueParameter.ActualName = EvaluatedSolutions.Name;513 incrEvaluatedSolutionsForNewLayer.ValueParameter.ActualName = LayerEvaluatedSolutionsParameter.Name; 457 514 incrEvaluatedSolutionsForNewLayer.AccumulateParameter.Value = new BoolValue(true); 458 515 459 516 incrOpenLayers.ValueParameter.ActualName = "OpenLayers"; 460 517 incrOpenLayers.Increment = new IntValue(1); 461 //incrOpenLayers.Successor = newLayerResultsCollector;462 463 //newLayerResultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("LayerResults", "Result set for each layer", "LayerResults"));464 //newLayerResultsCollector.CopyValue = new BoolValue(false);465 //newLayerResultsCollector.Successor = null;466 518 467 519 return layerOpener; … … 494 546 initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>(AgeParameter.Name, new DoubleValue(0))); 495 547 496 incrEvaluatedSolutionsAfterReseeding.ValueParameter.ActualName = EvaluatedSolutions.Name;548 incrEvaluatedSolutionsAfterReseeding.ValueParameter.ActualName = LayerEvaluatedSolutionsParameter.Name; 497 549 incrEvaluatedSolutionsAfterReseeding.AccumulateParameter.Value = new BoolValue(true); 498 550
Note: See TracChangeset
for help on using the changeset viewer.