Index: /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithm.cs
===================================================================
--- /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithm.cs	(revision 16582)
+++ /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithm.cs	(revision 16583)
@@ -24,4 +24,8 @@
 
     protected override void Run(CancellationToken cancellationToken) {
+      if (previousExecutionState != ExecutionState.Paused) {
+        InitializeAlgorithm(cancellationToken);
+      }
+
       var populationSize = PopulationSize.Value;
       bool[] maximization = ((BoolArray)Problem.MaximizationParameter.ActualValue).CloneAsArray();
Index: /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs
===================================================================
--- /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs	(revision 16582)
+++ /branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs	(revision 16583)
@@ -3,4 +3,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Data;
+using HeuristicLab.ExpressionGenerator;
 using HeuristicLab.Optimization;
 using HeuristicLab.Parameters;
@@ -58,4 +59,7 @@
     [Storable]
     protected IScope globalScope;
+
+    [Storable]
+    protected ExecutionState previousExecutionState;
     #endregion
 
@@ -211,4 +215,5 @@
       functionType = original.functionType;
       evaluatedSolutions = original.evaluatedSolutions;
+      previousExecutionState = original.previousExecutionState;
 
       if (original.IdealPoint != null) {
@@ -291,5 +296,5 @@
     }
 
-    protected override void Initialize(CancellationToken cancellationToken) {
+    protected void InitializeAlgorithm(CancellationToken cancellationToken) {
       globalScope = new Scope("Global Scope");
       executionContext = new ExecutionContext(null, this, globalScope);
@@ -335,4 +340,50 @@
 
       evaluatedSolutions = populationSize;
+    }
+
+    protected override void Initialize(CancellationToken cancellationToken) {
+      globalScope = new Scope("Global Scope");
+      executionContext = new ExecutionContext(null, this, globalScope);
+
+      // set the execution context for parameters to allow lookup
+      foreach (var parameter in Problem.Parameters.OfType<IValueParameter>()) {
+        // we need all of these in order for the wiring of the operators to work
+        globalScope.Variables.Add(new Variable(parameter.Name, parameter.Value));
+      }
+      globalScope.Variables.Add(new Variable("Results", Results)); // make results available as a parameter for analyzers etc.
+
+      var rand = RandomParameter.Value;
+      if (SetSeedRandomly) Seed = RandomSeedGenerator.GetSeed();
+      rand.Reset(Seed);
+
+      bool[] maximization = ((BoolArray)Problem.MaximizationParameter.ActualValue).CloneAsArray();
+      var dimensions = maximization.Length;
+
+      var populationSize = PopulationSize.Value;
+
+      InitializePopulation(executionContext, cancellationToken, rand, maximization);
+      InitializeUniformWeights(rand, populationSize, dimensions);
+      InitializeNeighbourHood(lambda, populationSize, NeighbourSize);
+
+      IdealPoint = new double[dimensions];
+      IdealPoint.UpdateIdeal(population);
+
+      NadirPoint = new double[dimensions];
+      NadirPoint.UpdateNadir(population);
+
+      var functionTypeString = FunctionTypeParameter.Value.Value;
+      switch (functionTypeString) {
+        case "Chebyshev":
+          functionType = FunctionType.TCHE;
+          break;
+        case "PBI":
+          functionType = FunctionType.PBI;
+          break;
+        case "Weighted Sum":
+          functionType = FunctionType.AGG;
+          break;
+      }
+
+      evaluatedSolutions = populationSize;
 
       base.Initialize(cancellationToken);
@@ -342,16 +393,19 @@
 
     protected void InitializeUniformWeights(IRandom random, int populationSize, int dimensions) {
-      if (dimensions > 2) {
-        throw new ArgumentException("The current implementation doesn't support more than 2 dimensions.");
-      }
-
-      lambda = new double[populationSize][];
-      var values = SequenceGenerator.GenerateSteps(0m, 1m, 1m / populationSize).ToArray();
-
-      for (int i = 0; i < populationSize; ++i) {
-        var w = (double)values[i];
-        lambda[i] = new[] { w, 1 - w };
-      }
-      lambda.ShuffleInPlace(random);
+      lambda = Enumerable.Range(0, populationSize).Select(_ => GenerateSample(random, dimensions)).ToArray();
+    }
+
+    // implements random number generation from https://en.wikipedia.org/wiki/Dirichlet_distribution#Random_number_generation
+    private double[] GenerateSample(IRandom random, int dim) {
+      var sum = 0d;
+      var sample = new double[dim];
+      for (int i = 0; i < dim; ++i) {
+        sample[i] = GammaDistributedRandom.NextDouble(random, 1, 1);
+        sum += sample[i];
+      }
+      for (int i = 0; i < dim; ++i) {
+        sample[i] /= sum;
+      }
+      return sample;
     }
 
@@ -446,10 +500,13 @@
       switch (functionType) {
         case FunctionType.TCHE: {
-            double maxFun = -1.0e+30;
+            double maxFun = double.MinValue;
 
             for (int n = 0; n < dim; n++) {
               double diff = Math.Abs(qualities[n] - IdealPoint[n]);
 
-              double feval = lambda[n] == 0 ? 0.0001 * diff : diff * lambda[n];
+              var l = lambda[n].IsAlmost(0) ? 0.0001 : lambda[n];
+              //var feval = l * diff;
+              // introduce objective scaling
+              var feval = l * (qualities[n] - IdealPoint[n]) / (NadirPoint[n] - IdealPoint[n]);
               if (feval > maxFun) {
                 maxFun = feval;
@@ -608,4 +665,9 @@
     }
 
+    protected override void OnExecutionStateChanged() {
+      previousExecutionState = ExecutionState;
+      base.OnExecutionStateChanged();
+    }
+
     protected override void OnStopped() {
       if (solutions != null) {
@@ -621,4 +683,5 @@
         jointPopulation.Clear();
       }
+      executionContext.Scope.SubScopes.Clear();
       base.OnStopped();
     }
