Index: /branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs	(revision 17517)
@@ -46,7 +46,7 @@
     private IRandom random;
 
-    private const string IterationsParameterName = "Iterations";
-    private const string BestQualityResultName = "Best quality";
-    private const string IterationsResultName = "Iterations";
+    [Storable] public IFixedValueParameter<IntValue> MaximumIterationsParameter { get; private set; }
+    [Storable] public IResultParameter<DoubleValue> BestQualityResultParameter { get; private set; }
+    [Storable] public IResultParameter<IntValue> IterationsResultParameter { get; private set; }
 
     public override Type ProblemType {
@@ -60,23 +60,8 @@
     public override bool SupportsPause { get { return false; } }
 
-    public IFixedValueParameter<IntValue> IterationsParameter {
-      get { return (IFixedValueParameter<IntValue>)Parameters[IterationsParameterName]; }
+    public int MaximumIterations {
+      get { return MaximumIterationsParameter.Value.Value; }
+      set { MaximumIterationsParameter.Value.Value = value; }
     }
-
-    public int Iterations {
-      get { return IterationsParameter.Value.Value; }
-      set { IterationsParameter.Value.Value = value; }
-    }
-
-    #region ResultsProperties
-    private double ResultsBestQuality {
-      get { return ((DoubleValue)Results[BestQualityResultName].Value).Value; }
-      set { ((DoubleValue)Results[BestQualityResultName].Value).Value = value; }
-    }
-    private int ResultsIterations {
-      get { return ((IntValue)Results[IterationsResultName].Value).Value; }
-      set { ((IntValue)Results[IterationsResultName].Value).Value = value; }
-    }
-    #endregion
 
     [StorableConstructor]
@@ -84,4 +69,7 @@
     protected HillClimber(HillClimber original, Cloner cloner)
       : base(original, cloner) {
+      MaximumIterationsParameter = cloner.Clone(original.MaximumIterationsParameter);
+      BestQualityResultParameter = cloner.Clone(original.BestQualityResultParameter);
+      IterationsResultParameter = cloner.Clone(original.IterationsResultParameter);
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -92,15 +80,11 @@
       : base() {
       random = new MersenneTwister();
-      Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "", new IntValue(100)));
+      Parameters.Add(MaximumIterationsParameter = new FixedValueParameter<IntValue>("Maximum Iterations", "", new IntValue(100)));
+      Parameters.Add(BestQualityResultParameter = new ResultParameter<DoubleValue>("Best Quality", "", "Results", new DoubleValue(double.NaN)));
+      Parameters.Add(IterationsResultParameter = new ResultParameter<IntValue>("Iterations", "", "Results", new IntValue(0)));
     }
 
-
-    protected override void Initialize(CancellationToken cancellationToken) {
-      Results.Add(new Result(BestQualityResultName, new DoubleValue(double.NaN)));
-      Results.Add(new Result(IterationsResultName, new IntValue(0)));
-      base.Initialize(cancellationToken);
-    }
     protected override void Run(CancellationToken cancellationToken) {
-      while (ResultsIterations < Iterations) {
+      while (IterationsResultParameter.ActualValue.Value < MaximumIterations) {
         cancellationToken.ThrowIfCancellationRequested();
 
@@ -114,9 +98,10 @@
 
         fitness = ImproveToLocalOptimum(Problem, solution, fitness, random);
-        if (double.IsNaN(ResultsBestQuality) || Problem.IsBetter(fitness, ResultsBestQuality)) {
-          ResultsBestQuality = fitness;
+        var bestSoFar = BestQualityResultParameter.ActualValue.Value;
+        if (double.IsNaN(bestSoFar) || Problem.IsBetter(fitness, bestSoFar)) {
+          BestQualityResultParameter.ActualValue.Value = fitness;
         }
 
-        ResultsIterations++;
+        IterationsResultParameter.ActualValue.Value++;
       }
     }
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyAlgorithm.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyAlgorithm.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyAlgorithm.cs	(revision 17517)
@@ -21,8 +21,7 @@
 
 using System;
+using HEAL.Attic;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HeuristicLab.Optimization;
-using HEAL.Attic;
 using HeuristicLab.PluginInfrastructure;
 
@@ -41,9 +40,4 @@
     }
 
-    private ResultCollection results;
-    public override Optimization.ResultCollection Results {
-      get { return results; }
-    }
-
     #region Persistence Properties
     [Storable(Name = "ExceptionMessage")]
@@ -56,14 +50,11 @@
     [StorableConstructor]
     private EmptyAlgorithm(StorableConstructorFlag _) : base(_) {
-      this.results = new ResultCollection();
     }
     private EmptyAlgorithm(EmptyAlgorithm original, Cloner cloner)
       : base(original, cloner) {
       this.exceptionMessage = original.exceptionMessage;
-      this.results = new ResultCollection();
     }
     public EmptyAlgorithm()
       : base() {
-      results = new ResultCollection();
     }
     public EmptyAlgorithm(string exceptionMessage)
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs	(revision 17517)
@@ -33,4 +33,6 @@
   [StorableType("2F6FEB34-BD19-47AF-9484-7F48565C0C43")]
   public abstract class BinaryVectorProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
+    [Storable] public IResultParameter<BinaryVector> BestSolutionParameter { get; private set; }
+
     public int Length {
       get { return Encoding.Length; }
@@ -47,4 +49,5 @@
     protected BinaryVectorProblem(BinaryVectorProblem original, Cloner cloner)
       : base(original, cloner) {
+      BestSolutionParameter = cloner.Clone(original.BestSolutionParameter);
       RegisterEventHandlers();
     }
@@ -53,4 +56,6 @@
     protected BinaryVectorProblem(BinaryVectorEncoding encoding) : base(encoding) {
       EncodingParameter.ReadOnly = true;
+      BestSolutionParameter = new ResultParameter<BinaryVector>("Best Solution", "The best solution.");
+      Parameters.Add(BestSolutionParameter);
 
       Operators.Add(new HammingSimilarityCalculator());
@@ -65,6 +70,5 @@
       base.Analyze(vectors, qualities, results, random);
       var best = GetBestSolution(vectors, qualities);
-
-      results.AddOrUpdateResult("Best Solution", (IItem)best.Item1.Clone());
+      BestSolutionParameter.ActualValue = (BinaryVector)best.Item1.Clone();
     }
 
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs	(revision 17517)
@@ -95,5 +95,9 @@
     }
 
-    public abstract ResultCollection Results { get; }
+    [Storable]
+    private readonly ResultCollection results = new ResultCollection();
+    public ResultCollection Results {
+      get { return results; }
+    }
 
     [Storable]
@@ -185,4 +189,5 @@
       storeAlgorithmInEachRun = original.storeAlgorithmInEachRun;
       runsCounter = original.runsCounter;
+      results = cloner.Clone(original.Results);
       runs = cloner.Clone(original.runs);
       Initialize();
@@ -197,4 +202,5 @@
       if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
         throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
+      results.Clear();
     }
     public void Prepare(bool clearRuns) {
@@ -286,4 +292,6 @@
     public event EventHandler Started;
     protected virtual void OnStarted() {
+      foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>())
+        param.ResultCollection = results;
       ExecutionState = ExecutionState.Started;
       EventHandler handler = Started;
@@ -292,4 +300,6 @@
     public event EventHandler Paused;
     protected virtual void OnPaused() {
+      foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>())
+        param.ResultCollection = null;
       ExecutionState = ExecutionState.Paused;
       EventHandler handler = Paused;
@@ -311,4 +321,6 @@
         }
       } finally {
+        foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>())
+          param.ResultCollection = null;
         ExecutionState = ExecutionState.Stopped;
         EventHandler handler = Stopped;
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs	(revision 17517)
@@ -22,7 +22,7 @@
 using System;
 using System.Threading;
+using HEAL.Attic;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HEAL.Attic;
 
 namespace HeuristicLab.Optimization {
@@ -42,9 +42,4 @@
     [Storable]
     private bool initialized;
-    [Storable]
-    private readonly ResultCollection results;
-    public override ResultCollection Results {
-      get { return results; }
-    }
 
     private CancellationTokenSource cancellationTokenSource;
@@ -58,10 +53,8 @@
     protected BasicAlgorithm(BasicAlgorithm original, Cloner cloner)
       : base(original, cloner) {
-      results = cloner.Clone(original.Results);
       initialized = original.initialized;
     }
     protected BasicAlgorithm()
       : base() {
-      results = new ResultCollection();
     }
 
@@ -69,5 +62,4 @@
       if (Problem == null) return;
       base.Prepare();
-      results.Clear();
       initialized = false;
       OnPrepared();
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs	(revision 17517)
@@ -76,14 +76,8 @@
     }
 
-    public override ResultCollection Results {
-      get {
-        return (ResultCollection)globalScope.Variables["Results"].Value;
-      }
-    }
-
     protected EngineAlgorithm()
       : base() {
       globalScope = new Scope("Global Scope");
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
       operatorGraph = new OperatorGraph();
       Initialize();
@@ -92,5 +86,5 @@
       : base(name) {
       globalScope = new Scope("Global Scope");
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
       operatorGraph = new OperatorGraph();
       Initialize();
@@ -99,5 +93,5 @@
       : base(name, parameters) {
       globalScope = new Scope("Global Scope");
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
       operatorGraph = new OperatorGraph();
       Initialize();
@@ -106,5 +100,5 @@
       : base(name, description) {
       globalScope = new Scope("Global Scope");
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
       operatorGraph = new OperatorGraph();
       Initialize();
@@ -113,5 +107,5 @@
       : base(name, description, parameters) {
       globalScope = new Scope("Global Scope");
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
       operatorGraph = new OperatorGraph();
       Initialize();
@@ -160,5 +154,5 @@
       base.Prepare();
       globalScope.Clear();
-      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
+      globalScope.Variables.Add(new Variable("Results", Results));
 
       if ((engine != null) && (operatorGraph.InitialOperator != null)) {
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/IResultParameter.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/IResultParameter.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/IResultParameter.cs	(revision 17517)
@@ -28,4 +28,6 @@
   public interface IResultParameter : ILookupParameter {
     string ResultCollectionName { get; set; }
+    ResultCollection ResultCollection { get; set; }
+
     event EventHandler ResultCollectionNameChanged;
   }
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs	(revision 17517)
@@ -60,4 +60,7 @@
     }
 
+    [Storable]
+    public ResultCollection ResultCollection { get; set; }
+
     [StorableConstructor]
     private ResultParameter(StorableConstructorFlag _) : base(_) { }
@@ -66,4 +69,5 @@
       resultCollectionName = original.resultCollectionName;
       defaultValue = cloner.Clone(original.defaultValue);
+      ResultCollection = cloner.Clone(original.ResultCollection);
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -89,19 +93,21 @@
 
     protected override IItem GetActualValue() {
-      ResultCollection results;
-      if (CachedActualValue != null) {
-        results = CachedActualValue as ResultCollection;
-        if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection not found.");
-      } else {
-        var tmp = ResultCollectionName;
-        // verifyType has to be disabled, because the ResultCollection may not be identical to the generic type of the parameter
-        results = GetValue(ExecutionContext, ref tmp) as ResultCollection;
-        if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection with name " + tmp + " not found.");
-        CachedActualValue = results;
+      ResultCollection results = ResultCollection;
+      if (results == null) {
+        if (CachedActualValue != null) {
+          results = CachedActualValue as ResultCollection;
+          if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection not found.");
+        } else {
+          var tmp = ResultCollectionName;
+          // verifyType has to be disabled, because the ResultCollection may not be identical to the generic type of the parameter
+          results = GetValue(ExecutionContext, ref tmp) as ResultCollection;
+          if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection with name " + tmp + " not found.");
+          CachedActualValue = results;
+        }
       }
 
       IResult result;
       if (!results.TryGetValue(ActualName, out result)) {
-        if (DefaultValue == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): Result not found and no default value specified.");
+        if (DefaultValue == null) return null;
         result = ItemDescription == Description ? new Result(ActualName, (T)DefaultValue.Clone()) : new Result(ActualName, Description, (T)DefaultValue.Clone());
         results.Add(result);
@@ -116,13 +122,15 @@
 
     protected override void SetActualValue(IItem value) {
-      ResultCollection results;
-      if (CachedActualValue != null) {
-        results = CachedActualValue as ResultCollection;
-        if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection not found.");
-      } else {
-        var tmp = ResultCollectionName;
-        results = GetValue(ExecutionContext, ref tmp) as ResultCollection;
-        if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection with name " + tmp + " not found.");
-        CachedActualValue = results;
+      ResultCollection results = ResultCollection;
+      if (results == null) {
+        if (CachedActualValue != null) {
+          results = CachedActualValue as ResultCollection;
+          if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection not found.");
+        } else {
+          var tmp = ResultCollectionName;
+          results = GetValue(ExecutionContext, ref tmp) as ResultCollection;
+          if (results == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): ResultCollection with name " + tmp + " not found.");
+          CachedActualValue = results;
+        }
       }
 
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs	(revision 17517)
@@ -107,4 +107,9 @@
       set { ObjectiveParameter.Value.Value = value; }
     }
+
+    public new IScheduleEncoding Encoding {
+      get { return base.Encoding; }
+      set { base.Encoding = value; }
+    }
     #endregion
 
Index: /branches/2521_ProblemRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/TSP.cs
===================================================================
--- /branches/2521_ProblemRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/TSP.cs	(revision 17516)
+++ /branches/2521_ProblemRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/TSP.cs	(revision 17517)
@@ -47,4 +47,5 @@
     [Storable] public IValueParameter<ITSPData> TSPDataParameter { get; private set; }
     [Storable] public IValueParameter<ITSPSolution> BestKnownSolutionParameter { get; private set; }
+    [Storable] public IResultParameter<ITSPSolution> BestTSPSolutionParameter { get; private set; }
 
     public ITSPData TSPData {
@@ -64,4 +65,5 @@
       TSPDataParameter = cloner.Clone(original.TSPDataParameter);
       BestKnownSolutionParameter = cloner.Clone(original.BestKnownSolutionParameter);
+      BestTSPSolutionParameter = cloner.Clone(original.BestTSPSolutionParameter);
     }
 
@@ -70,5 +72,6 @@
       Parameters.Add(TSPDataParameter = new ValueParameter<ITSPData>("TSPData", "The main parameters of the TSP."));
       Parameters.Add(BestKnownSolutionParameter = new OptionalValueParameter<ITSPSolution>("BestKnownSolution", "The best known solution."));
-
+      Parameters.Add(BestTSPSolutionParameter = new ResultParameter<ITSPSolution>("Best TSP Solution", "The best so far solution found."));
+      
       TSPData = new EuclideanTSPData();
       Encoding.Length = TSPData.Cities;
@@ -112,12 +115,8 @@
       }
 
-      IResult bestSolutionResult;
-      if (results.TryGetValue("Best TSP Solution", out bestSolutionResult)) {
-        var bestSolution = bestSolutionResult.Value as ITSPSolution;
-        if (bestSolution == null || Maximization && bestSolution.TourLength.Value < qualities[i]
-          || !Maximization && bestSolution.TourLength.Value > qualities[i]) {
-          bestSolutionResult.Value = TSPData.GetSolution(solutions[i], qualities[i]);
-        }
-      } else results.Add(new Result("Best TSP Solution", TSPData.GetSolution(solutions[i], qualities[i])));
+      var bestSolution = BestTSPSolutionParameter.ActualValue;
+      if (bestSolution == null || IsBetter(qualities[i], bestSolution.TourLength.Value)) {
+        BestTSPSolutionParameter.ActualValue = TSPData.GetSolution(solutions[i], qualities[i]);
+      }
     }
 
