Index: /branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj
===================================================================
--- /branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj	(revision 13603)
+++ /branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj	(revision 13604)
@@ -105,4 +105,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="LayerMigrator.cs" />
     <Compile Include="ResultsExtractor.cs" />
     <Compile Include="IslandALPSAlgorithm.cs" />
Index: /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
===================================================================
--- /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs	(revision 13603)
+++ /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs	(revision 13604)
@@ -83,5 +83,13 @@
       get { return (IValueParameter<IntValue>)Parameters["MigrationInterval"]; }
     }
-
+    public IConstrainedValueParameter<IMigrator> MigratorParameter {
+      get { return (IConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; }
+    }
+    public IConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {
+      get { return (IConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; }
+    }
+    public IConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
+      get { return (IConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
+    }
     #endregion
 
@@ -284,4 +292,7 @@
       Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number Generations before a migration occurs.", new IntValue(20)));
       Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
+      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
+      Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
+      Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants."));
 
       #endregion
@@ -429,4 +440,5 @@
       UpdateTerminators();
       ParameterizeAgeLimits();
+      ParametrizeMigration();
       #endregion
 
@@ -585,4 +597,6 @@
       ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
       Elites.ValueChanged += Elites_ValueChanged;
+      MigrationRateParameter.Value.ValueChanged += MigrationRate_ValueChanged;
+      MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged;
 
       Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded; 
@@ -603,4 +617,11 @@
       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
 
+    }
+
+    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
+      var migrationSize = (int)Math.Ceiling(MigrationRateParameter.Value.Value * PopulationSize.Value);
+      foreach (var selector in EmigrantsSelectorParameter.ValidValues) {
+        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
+      }
     }
 
@@ -719,4 +740,10 @@
       MainLoop.NumberOfLayersParameter.ActualName = NumberOfLayersParameter.Name;
       MainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
+      MainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
+      MainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
+      MainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
+
+
+
       MainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
       MainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
@@ -738,4 +765,23 @@
     }
 
+    private void ParametrizeMigration() {
+      var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value *PopulationSize.Value);
+      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) {
+        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
+        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
+
+        ParameterizeStochasticOperatorForLayer(selector);
+
+        EmigrantsSelectorParameter.ValidValues.Add(selector);
+      }
+
+      foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) {
+        ParameterizeStochasticOperatorForLayer(replacer);
+        ImmigrationReplacerParameter.ValidValues.Add(replacer);
+      }
+
+      MigratorParameter.ValidValues.Add(new LayerMigrator());
+    }
+
     private void ParameterizeSolutionsCreator() {
       SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
@@ -750,12 +796,24 @@
         ParameterizeStochasticOperatorForLayer(selector);
       }
+
       if (Problem != null) {
         foreach (var selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
-          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
-          selector.MaximizationParameter.Hidden = true;
-          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
-          selector.QualityParameter.Hidden = true;
-        }
-      }
+          ParametrizeSingleObjectiveSelector(selector);
+        }
+        foreach (var replacer in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
+          ParametrizeSingleObjectiveSelector(replacer);
+        }
+        foreach (var selector in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
+          ParametrizeSingleObjectiveSelector(selector);
+        }
+
+      }
+    }
+
+    private void ParametrizeSingleObjectiveSelector(ISingleObjectiveSelector selector) {
+      selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
+      selector.MaximizationParameter.Hidden = true;
+      selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
+      selector.QualityParameter.Hidden = true;
     }
 
Index: /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorthmsMainLoop.cs
===================================================================
--- /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorthmsMainLoop.cs	(revision 13603)
+++ /branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorthmsMainLoop.cs	(revision 13604)
@@ -225,5 +225,5 @@
       var resultsCollector = new ResultsCollector();
 
-      var processIslandsUssp = new UniformSubScopesProcessor() {Name = "Process Islands"};
+      var processIslandsUssp = new UniformSubScopesProcessor() {Name = "Process Islands", Parallel = new BoolValue(true)};
       var initIslandGenerationsAss = new Assigner() {Name = "Init Island Generations"};
       var initIslandEvaluationsAss = new Assigner() {Name = "Init Island Evaluations"};
@@ -231,5 +231,4 @@
       var incrementGenerationDr = new DataReducer() { Name = "Increment Generations" };
       var incrementEvaluatedSolutionDr = new DataReducer() { Name = "Increment Evaluated Solutions" };
-      //TODO: increase migration count + migrate
 
       var elderMigrator = CreateEldersEmigrator();
@@ -250,12 +249,19 @@
       var groupResultsExtractor = new ResultsExtractor() {Name = "Collect group results into variable"};
       var groupResultsCollector = new ResultsCollector() {Name = "Collect group results into into global results"};
-
+      var groupLayerNumberResultsCollector = new ResultsCollector() {Name = "Add Layernumber to Results"};
 
       var matingPoolCreator = new MatingPoolCreator();
       var matingPoolUssp = new UniformSubScopesProcessor() {Name = "Process Mating Pools"};
-      var alpsMainOperator =new AlpsGeneticAlgorithmMainOperator();
+      var alpsMainOperator = new AlpsGeneticAlgorithmMainOperator();
 
       var incrementIslandGeneration = new IntCounter() {Name = "incrementIslandGeneration" };
       var setIslandEvaluatedSolutions = new DataReducer() {Name = "Set IslandEvaluatedSolutions" };
+       
+      var migrationCounter = new IntCounter() {Name = "Increment  Migrations"};
+      var selectforMigrationUssp = new UniformSubScopesProcessor();
+      var emigrantSelector = new Placeholder() {Name = "Emigrant Selector (Placeholder)"};
+      var migrator = new LayerMigrator();
+      var replaceforMigrationUssp = new UniformSubScopesProcessor();
+      var immigrantSelector = new Placeholder() { Name = "Immigrant Replacer (Placeholder)" };
 
       var migrateComparator = new Comparator();
@@ -283,4 +289,5 @@
       resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults","","IslandResults"));
       resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("GroupResults","","GroupResults"));
+      resultsCollector.CollectedValues.Add(new ValueLookupParameter<IntValue>("Migrations"));
       resultsCollector.CopyValue = new BoolValue(false);
 
@@ -314,5 +321,15 @@
       migrateCondBranch.ConditionParameter.ActualName = "Migrate";
 
+      migrationCounter.ValueParameter.ActualName = "Migrations";
+      selectforMigrationUssp.Depth = new IntValue(2);
+      emigrantSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
+
+      replaceforMigrationUssp.Depth = new IntValue(2);
+      immigrantSelector.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
+
       groupAnalyzer.OperatorParameter.ActualName = GroupAnalyzerParameter.Name;
+      groupLayerNumberResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("LayerNumber"));
+      groupLayerNumberResultsCollector.ResultsParameter.ActualName = "GroupResults";
+
       layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
       layerResultsCollector.ResultsParameter.ActualName = "LayerResults";
@@ -384,8 +401,20 @@
       processIslandsUssp.Successor = incrementGenerationDr;
       incrementGenerationDr.Successor = incrementEvaluatedSolutionDr;
-      incrementEvaluatedSolutionDr.Successor = globalAnalyzerPlacerholder;
+      incrementEvaluatedSolutionDr.Successor = migrationCounter;
+      
+      migrationCounter.Successor = selectforMigrationUssp;
+      selectforMigrationUssp.Operator = emigrantSelector;
+      emigrantSelector.Successor = null;
+      selectforMigrationUssp.Successor = migrator;
+
+      migrator.Successor = replaceforMigrationUssp;
+      replaceforMigrationUssp.Operator = immigrantSelector;
+      immigrantSelector.Successor = null;
+      replaceforMigrationUssp.Successor = globalAnalyzerPlacerholder;
+
       globalAnalyzerPlacerholder.Successor = groupingOperator;
       groupingOperator.Operator = groupAnalyzer;
-      groupAnalyzer.Successor = null;
+      groupAnalyzer.Successor = groupLayerNumberResultsCollector;
+      groupLayerNumberResultsCollector.Successor = null;
       groupingOperator.Successor = groupResultsExtractor;
       groupResultsExtractor.Successor = groupResultsCollector;
Index: /branches/IslandALPS/IslandALPS/3.3/LayerMigrator.cs
===================================================================
--- /branches/IslandALPS/IslandALPS/3.3/LayerMigrator.cs	(revision 13604)
+++ /branches/IslandALPS/IslandALPS/3.3/LayerMigrator.cs	(revision 13604)
@@ -0,0 +1,57 @@
+﻿using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.IslandALPS {
+
+  /// <summary>
+  /// <pre> 
+  ///          __ scope __                    __ scope __         
+  ///         /           \                  /           \        
+  ///       Island1      Island2     =>    Island1      Island2   
+  ///       /    \         / \             /    \         / \     
+  ///     L1     L2      L1     L2       L1     L2      L1     L2 
+  ///     / \    / \     / \    / \      / \    / \     / \    / \
+  ///    R  S   R  S    R  S   R  S     R  S   R  S    R  S   R  S
+  ///   /|\ |  /|\ |   /|\ |  /|\ |    /|\ |  /|\ |   /|\ |  /|\ |
+  ///   ABC A  DEF D   GHI G  JKL J    ABC J  DEF A   GHI D  JKL G                        
+  /// 
+  /// </pre>
+  /// </summary>
+  [Item("LayerMigrator", "Migrates the selected scopes of each layer to the correspondant layer of the next island (clockwise).")]
+  [StorableClass]
+  public class LayerMigrator : SingleSuccessorOperator, IMigrator {
+
+    [StorableConstructor]
+    public LayerMigrator(bool deserializing) : base(deserializing) {}
+    public LayerMigrator(LayerMigrator original, Cloner cloner) : base(original, cloner) {}
+    public LayerMigrator() {}
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+     return new LayerMigrator(this,cloner);
+    }
+
+    public override IOperation Apply() {
+      var globalScope = ExecutionContext.Scope;
+      var openLayer = globalScope.SubScopes[0].SubScopes.Count;
+
+      for (int layerIndex = 0; layerIndex < openLayer; layerIndex++) {
+        IScope emigrants = null;
+        for (int islandIndex = 0; islandIndex < globalScope.SubScopes.Count; islandIndex++) {
+          var currentLayer = globalScope.SubScopes[islandIndex].SubScopes[layerIndex];
+          if (emigrants != null) {
+            currentLayer.SubScopes.Add(emigrants);              
+          }
+          emigrants = currentLayer.SubScopes[1];
+          currentLayer.SubScopes.Remove(emigrants);
+        }
+        //first island gets the individuals from the last island
+        globalScope.SubScopes[0].SubScopes[layerIndex].SubScopes.Add(emigrants);
+      }
+
+      return base.Apply();
+    }
+  }
+}
