Index: branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs
===================================================================
--- branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs	(revision 16583)
+++ branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs	(revision 16630)
@@ -1,3 +1,25 @@
-﻿using HeuristicLab.Analysis;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HEAL.Attic;
+using HeuristicLab.Analysis;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -6,15 +28,14 @@
 using HeuristicLab.Optimization;
 using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
 using HeuristicLab.Random;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-
 using CancellationToken = System.Threading.CancellationToken;
 
 namespace HeuristicLab.Algorithms.MOEAD {
   [Item("MOEADAlgorithmBase", "Base class for all MOEA/D algorithm variants.")]
-  [StorableClass]
+  [StorableType("E00BAC79-C6F9-42B6-8468-DEEC7FFCE804")]
   public abstract class MOEADAlgorithmBase : BasicAlgorithm {
     #region data members
@@ -62,4 +83,7 @@
     [Storable]
     protected ExecutionState previousExecutionState;
+
+    [Storable]
+    protected ExecutionState executionState;
     #endregion
 
@@ -81,4 +105,5 @@
     private const string MaximumNumberOfReplacedSolutionsParameterName = "MaximumNumberOfReplacedSolutions";
     private const string FunctionTypeParameterName = "FunctionType";
+    private const string NormalizeObjectivesParameterName = "NormalizeObjectives";
 
     public IValueParameter<MultiAnalyzer> AnalyzerParameter {
@@ -91,4 +116,7 @@
     public IFixedValueParameter<IntValue> NeighbourSizeParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[NeighbourSizeParameterName]; }
+    }
+    public IFixedValueParameter<BoolValue> NormalizeObjectivesParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[NormalizeObjectivesParameterName]; }
     }
     public IFixedValueParameter<IntValue> MaximumNumberOfReplacedSolutionsParameter {
@@ -141,4 +169,8 @@
       get { return SetSeedRandomlyParameter.Value.Value; }
       set { SetSeedRandomlyParameter.Value.Value = value; }
+    }
+    public bool NormalizeObjectives {
+      get { return NormalizeObjectivesParameter.Value.Value; }
+      set { NormalizeObjectivesParameter.Value.Value = value; }
     }
     public IntValue PopulationSize {
@@ -204,4 +236,5 @@
       Parameters.Add(new FixedValueParameter<IntValue>(MaximumNumberOfReplacedSolutionsParameterName, new IntValue(2)));
       Parameters.Add(new FixedValueParameter<DoubleValue>(NeighbourhoodSelectionProbabilityParameterName, new DoubleValue(0.1)));
+      Parameters.Add(new FixedValueParameter<BoolValue>(NormalizeObjectivesParameterName, new BoolValue(true)));
 
       var functionTypeParameter = new ConstrainedValueParameter<StringValue>(FunctionTypeParameterName);
@@ -258,6 +291,14 @@
     }
 
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey(NormalizeObjectivesParameterName)) {
+        Parameters.Add(new FixedValueParameter<BoolValue>(NormalizeObjectivesParameterName, new BoolValue(true)));
+      }
+    }
+
     [StorableConstructor]
-    protected MOEADAlgorithmBase(bool deserializing) : base(deserializing) { }
+    protected MOEADAlgorithmBase(StorableConstructorFlag _) : base(_) { }
     #endregion
 
@@ -292,19 +333,5 @@
     }
 
-    public override void Prepare() {
-      base.Prepare();
-    }
-
     protected void InitializeAlgorithm(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();
@@ -320,7 +347,9 @@
       InitializeNeighbourHood(lambda, populationSize, NeighbourSize);
 
+      //IdealPoint = Enumerable.Repeat(double.MaxValue, dimensions).ToArray();
       IdealPoint = new double[dimensions];
       IdealPoint.UpdateIdeal(population);
 
+      //NadirPoint = Enumerable.Repeat(double.MinValue, dimensions).ToArray();
       NadirPoint = new double[dimensions];
       NadirPoint.UpdateNadir(population);
@@ -353,38 +382,4 @@
       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);
     }
@@ -396,5 +391,5 @@
     }
 
-    // implements random number generation from https://en.wikipedia.org/wiki/Dirichlet_distribution#Random_number_generation
+    // 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;
@@ -503,10 +498,11 @@
 
             for (int n = 0; n < dim; n++) {
-              double diff = Math.Abs(qualities[n] - IdealPoint[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]);
+              var diff = qualities[n] - IdealPoint[n];
+              if (NormalizeObjectives) {
+                diff /= NadirPoint[n] - IdealPoint[n];
+              }
+              var l = lambda[n].IsAlmost(0) ? 1e-4 : lambda[n];
+              var feval = l * Math.Abs(diff);
+
               if (feval > maxFun) {
                 maxFun = feval;
@@ -666,9 +662,10 @@
 
     protected override void OnExecutionStateChanged() {
-      previousExecutionState = ExecutionState;
+      previousExecutionState = executionState;
+      executionState = ExecutionState;
       base.OnExecutionStateChanged();
     }
 
-    protected override void OnStopped() {
+    public void ClearState() {
       if (solutions != null) {
         solutions.Clear();
@@ -683,5 +680,13 @@
         jointPopulation.Clear();
       }
-      executionContext.Scope.SubScopes.Clear();
+      lambda = null;
+      neighbourhood = null;
+      if (executionContext != null && executionContext.Scope != null) {
+        executionContext.Scope.SubScopes.Clear();
+      }
+    }
+
+    protected override void OnStopped() {
+      ClearState();
       base.OnStopped();
     }
