Index: trunk/sources/HeuristicLab.Problems.Knapsack/3.3/HeuristicLab.Problems.Knapsack-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.Knapsack/3.3/HeuristicLab.Problems.Knapsack-3.3.csproj	(revision 3463)
+++ trunk/sources/HeuristicLab.Problems.Knapsack/3.3/HeuristicLab.Problems.Knapsack-3.3.csproj	(revision 3467)
@@ -87,7 +87,9 @@
     <Compile Include="Interfaces\IKnapsackMoveEvaluator.cs" />
     <Compile Include="KnapsackProblem.cs" />
+    <Compile Include="KnapsackSolution.cs" />
     <Compile Include="MoveEvaluators\KnapsackMoveEvaluator.cs" />
     <Compile Include="MoveEvaluators\KnapsackOneBitflipMoveEvaluator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Visualizers\BestKnapsackVisualizer.cs" />
   </ItemGroup>
   <ItemGroup>
Index: trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Interfaces/IKnapsackSolutionsVisualizer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Interfaces/IKnapsackSolutionsVisualizer.cs	(revision 3463)
+++ trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Interfaces/IKnapsackSolutionsVisualizer.cs	(revision 3467)
@@ -21,4 +21,7 @@
 
 using HeuristicLab.Optimization;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.BinaryVectorEncoding;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.Knapsack {
@@ -26,4 +29,9 @@
   /// An interface which represents an operator for visualizing solutions of Knapsack Problems.
   /// </summary>
-  public interface IKnapsackSolutionsVisualizer : ISingleObjectiveSolutionsVisualizer { }
+  public interface IKnapsackSolutionsVisualizer : ISingleObjectiveSolutionsVisualizer {
+    ILookupParameter<ItemArray<BinaryVector>> BinaryVectorParameter { get; }
+    ILookupParameter<IntValue> KnapsackCapacityParameter { get; }
+    ILookupParameter<IntArray> WeightsParameter { get; }
+    ILookupParameter<IntArray> ValuesParameter { get; }
+  }
 }
Index: trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs	(revision 3463)
+++ trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs	(revision 3467)
@@ -32,4 +32,5 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.Knapsack.Visualizers;
 
 namespace HeuristicLab.Problems.Knapsack {
@@ -161,4 +162,5 @@
       RandomBinaryVectorCreator creator = new RandomBinaryVectorCreator();
       KnapsackEvaluator evaluator = new KnapsackEvaluator();
+      IKnapsackSolutionsVisualizer visualizer = new BestKnapsackVisualizer();
 
       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Knapsack Problem is a maximization problem.", new BoolValue(true)));
@@ -170,5 +172,5 @@
       Parameters.Add(new ValueParameter<IKnapsackEvaluator>("Evaluator", "The operator which should be used to evaluate Knapsack solutions.", evaluator));
       Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this Knapsack instance."));
-      Parameters.Add(new ValueParameter<IKnapsackSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize Knapsack solutions.", null));
+      Parameters.Add(new ValueParameter<IKnapsackSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize Knapsack solutions.", visualizer));
 
       creator.BinaryVectorParameter.ActualName = "KnapsackSolution";
@@ -179,4 +181,5 @@
       ParameterizeSolutionCreator();
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
 
       Initialize();
@@ -219,4 +222,5 @@
       ParameterizeSolutionCreator();
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
       ParameterizeOperators();
       OnSolutionCreatorChanged();
@@ -224,15 +228,19 @@
     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
       ParameterizeOperators();
     }
     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
       OnEvaluatorChanged();
     }
     void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
     }
     void WeightsParameter_ValueChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
       ParameterizeSolutionCreator();
 
@@ -247,4 +255,5 @@
     void ValuesParameter_ValueChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ParameterizeVisualizer();
       ParameterizeSolutionCreator();
 
@@ -302,4 +311,14 @@
       }
     }
+    private void ParameterizeVisualizer() {
+      if (Visualizer is IKnapsackSolutionsVisualizer) {
+        IKnapsackSolutionsVisualizer visualizer =
+          (IKnapsackSolutionsVisualizer)Visualizer;
+        visualizer.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
+        visualizer.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;
+        visualizer.WeightsParameter.ActualName = WeightsParameter.Name;
+        visualizer.ValuesParameter.ActualName = ValuesParameter.Name;
+      }
+    }
     private void InitializeOperators() {
       operators = new List<IBinaryVectorOperator>();
Index: trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackSolution.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackSolution.cs	(revision 3467)
+++ trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackSolution.cs	(revision 3467)
@@ -0,0 +1,221 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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 System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Drawing;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.BinaryVectorEncoding;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.Knapsack {
+  /// <summary>
+  /// Represents a knapsack solution which can be visualized in the GUI.
+  /// </summary>
+  [Item("KnapsackSolution", "Represents a knapsack solution which can be visualized in the GUI.")]
+  [StorableClass]
+  public class KnapsackSolution : Item {
+    public override Image ItemImage {
+      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Image; }
+    }
+
+    [Storable]
+    private BinaryVector binaryVector;
+    public BinaryVector BinaryVector {
+      get { return binaryVector; }
+      set {
+        if (binaryVector != value) {
+          if (binaryVector != null) DeregisterBinaryVectorEvents();
+          binaryVector = value;
+          if (binaryVector != null) RegisterBinaryVectorEvents();
+          OnBinaryVectorChanged();
+        }
+      }
+    }
+
+    [Storable]
+    private IntValue capacity;
+    public IntValue Capacity {
+      get { return capacity; }
+      set {
+        if (capacity != value) {
+          if (capacity != null) DeregisterCapacityEvents();
+          capacity = value;
+          if (capacity != null) RegisterCapacityEvents();
+          OnCapacityChanged();
+        }
+      }
+    }
+
+    [Storable]
+    private IntArray weights;
+    public IntArray Weights {
+      get { return weights; }
+      set {
+        if (weights != value) {
+          if (weights != null) DeregisterWeightsEvents();
+          weights = value;
+          if (weights != null) RegisterWeightsEvents();
+          OnWeightsChanged();
+        }
+      }
+    }
+
+    [Storable]
+    private IntArray values;
+    public IntArray Values {
+      get { return values; }
+      set {
+        if (values != value) {
+          if (values != null) DeregisterValuesEvents();
+          values = value;
+          if (values != null) RegisterValuesEvents();
+          OnValuesChanged();
+        }
+      }
+    }
+
+    public KnapsackSolution() : base() { }
+    public KnapsackSolution(BinaryVector binaryVector, IntValue capacity, IntArray weights, IntArray values)
+      : base() {
+      this.binaryVector = binaryVector;
+      this.capacity = capacity;
+      this.weights = weights;
+      this.values = values;
+      Initialize();
+    }
+    [StorableConstructor]
+    private KnapsackSolution(bool deserializing) : base(deserializing) { }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void Initialize() {
+      if (binaryVector != null) RegisterBinaryVectorEvents();
+      if (capacity != null) RegisterCapacityEvents();
+      if (weights != null) RegisterWeightsEvents();
+      if (values != null) RegisterValuesEvents();
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      KnapsackSolution clone = new KnapsackSolution();
+      cloner.RegisterClonedObject(this, clone);
+      clone.binaryVector = (BinaryVector)cloner.Clone(binaryVector);
+      clone.capacity = (IntValue)cloner.Clone(capacity);
+      clone.weights = (IntArray)cloner.Clone(weights);
+      clone.values = (IntArray)cloner.Clone(values);
+      clone.Initialize();
+      return clone;
+    }
+
+    #region Events
+    public event EventHandler BinaryVectorChanged;
+    private void OnBinaryVectorChanged() {
+      var changed = BinaryVectorChanged;
+      if (changed != null)
+        changed(this, EventArgs.Empty);
+    }
+
+    public event EventHandler CapacityChanged;
+    private void OnCapacityChanged() {
+      var changed = CapacityChanged;
+      if (changed != null)
+        changed(this, EventArgs.Empty);
+    }
+
+    public event EventHandler WeightsChanged;
+    private void OnWeightsChanged() {
+      var changed = WeightsChanged;
+      if (changed != null)
+        changed(this, EventArgs.Empty);
+    }
+
+    public event EventHandler ValuesChanged;
+    private void OnValuesChanged() {
+      var changed = ValuesChanged;
+      if (changed != null)
+        changed(this, EventArgs.Empty);
+    }
+
+    private void RegisterBinaryVectorEvents() {
+      BinaryVector.ItemChanged += new EventHandler<EventArgs<int>>(BinaryVector_ItemChanged);
+      BinaryVector.Reset += new EventHandler(BinaryVector_Reset);
+    }
+
+    private void DeregisterBinaryVectorEvents() {
+      BinaryVector.ItemChanged -= new EventHandler<EventArgs<int>>(BinaryVector_ItemChanged);
+      BinaryVector.Reset -= new EventHandler(BinaryVector_Reset);
+    }
+
+    private void RegisterCapacityEvents() {
+      Capacity.ValueChanged += new EventHandler(Capacity_ValueChanged);
+    }
+
+    private void DeregisterCapacityEvents() {
+      Capacity.ValueChanged -= new EventHandler(Capacity_ValueChanged);
+    }
+
+    private void RegisterWeightsEvents() {
+      Weights.ItemChanged += new EventHandler<EventArgs<int>>(Weights_ItemChanged);
+      Weights.Reset += new EventHandler(Weights_Reset);
+    }
+
+    private void DeregisterWeightsEvents() {
+      Weights.ItemChanged -= new EventHandler<EventArgs<int>>(Weights_ItemChanged);
+      Weights.Reset -= new EventHandler(Weights_Reset);
+    }
+
+    private void RegisterValuesEvents() {
+      Values.ItemChanged += new EventHandler<EventArgs<int>>(Values_ItemChanged);
+      Values.Reset += new EventHandler(Values_Reset);
+    }
+
+    private void DeregisterValuesEvents() {
+      Values.ItemChanged -= new EventHandler<EventArgs<int>>(Values_ItemChanged);
+      Values.Reset -= new EventHandler(Values_Reset);
+    }
+
+    private void BinaryVector_ItemChanged(object sender, EventArgs<int> e) {
+      OnBinaryVectorChanged();
+    }
+    private void BinaryVector_Reset(object sender, EventArgs e) {
+      OnBinaryVectorChanged();
+    }
+    void Capacity_ValueChanged(object sender, EventArgs e) {
+      OnCapacityChanged();
+    }
+    private void Weights_ItemChanged(object sender, EventArgs<int> e) {
+      OnWeightsChanged();
+    }
+    private void Weights_Reset(object sender, EventArgs e) {
+      OnWeightsChanged();
+    }
+    private void Values_ItemChanged(object sender, EventArgs<int> e) {
+      OnValuesChanged();
+    }
+    private void Values_Reset(object sender, EventArgs e) {
+      OnValuesChanged();
+    }
+    #endregion
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Visualizers/BestKnapsackVisualizer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Visualizers/BestKnapsackVisualizer.cs	(revision 3467)
+++ trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Visualizers/BestKnapsackVisualizer.cs	(revision 3467)
@@ -0,0 +1,94 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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 System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Optimization;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+using HeuristicLab.Operators;
+using HeuristicLab.Encodings.BinaryVectorEncoding;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.Knapsack.Visualizers {
+  /// <summary>
+  /// An operator for visualizing the best solution for a knapsack problem.
+  /// </summary>
+  [Item("BestKnapsackVisualizer", "An operator for visualizing the best solution for a knapsack problem.")]
+  [StorableClass]
+  class BestKnapsackVisualizer : SingleSuccessorOperator, IKnapsackSolutionsVisualizer {
+
+    public ILookupParameter<ItemArray<BinaryVector>> BinaryVectorParameter {
+      get { return (ILookupParameter<ItemArray<BinaryVector>>)Parameters["BinaryVector"]; }
+    }
+    public ILookupParameter<IntValue> KnapsackCapacityParameter {
+      get { return (ILookupParameter<IntValue>)Parameters["KnapsackCapacity"]; }
+    }
+    public ILookupParameter<IntArray> WeightsParameter {
+      get { return (ILookupParameter<IntArray>)Parameters["Weights"]; }
+    }
+    public ILookupParameter<IntArray> ValuesParameter {
+      get { return (ILookupParameter<IntArray>)Parameters["Values"]; }
+    }
+    public ILookupParameter<ItemArray<DoubleValue>> QualityParameter {
+      get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Quality"]; }
+    }
+    public ILookupParameter<KnapsackSolution> KnapsackSolutionParameter {
+      get { return (ILookupParameter<KnapsackSolution>)Parameters["KnapsackSolutionVisualization"]; }
+    }
+
+    ILookupParameter ISolutionsVisualizer.VisualizationParameter {
+      get { return KnapsackSolutionParameter; }
+    }
+
+    public BestKnapsackVisualizer()
+      : base() {
+      Parameters.Add(new SubScopesLookupParameter<BinaryVector>("BinaryVector", "The knapsack solutions from which the best solution should be visualized."));
+      Parameters.Add(new LookupParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack."));
+      Parameters.Add(new LookupParameter<IntArray>("Weights", "The weights of the items."));
+      Parameters.Add(new LookupParameter<IntArray>("Values", "The values of the items."));
+      
+      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The qualities of the knapsack solutions which should be visualized."));
+      Parameters.Add(new LookupParameter<KnapsackSolution>("KnapsackSolutionVisualization", "The visual representation of the best knapsack solution."));
+    }
+
+    public override IOperation Apply() {
+      ItemArray<BinaryVector> binaryVectors = BinaryVectorParameter.ActualValue;
+      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
+
+      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
+      KnapsackSolution solution = KnapsackSolutionParameter.ActualValue;
+      if (solution == null) KnapsackSolutionParameter.ActualValue = new KnapsackSolution(binaryVectors[i], 
+        KnapsackCapacityParameter.ActualValue, WeightsParameter.ActualValue, ValuesParameter.ActualValue);
+      else {
+        solution.BinaryVector = binaryVectors[i];
+        solution.Capacity = KnapsackCapacityParameter.ActualValue;
+        solution.Weights = WeightsParameter.ActualValue;
+        solution.Values = ValuesParameter.ActualValue;
+      }
+
+      return base.Apply();
+    }
+  }
+}
