Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 18091)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 18092)
@@ -205,4 +205,5 @@
     <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" />
     <Compile Include="Mutators\SubVectorImprovementManipulator.cs" />
+    <Compile Include="SegmentOptimization\SegmentOptimizationProblem.cs" />
     <Compile Include="Selectors\DiversitySelector.cs" />
     <Compile Include="SymbolicDataAnalysisExpressionTreeAverageSimilarityCalculator.cs" />
@@ -404,4 +405,8 @@
       <Private>False</Private>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
+      <Project>{DDFB14DD-2A85-493C-A52D-E69729BBAEB0}</Project>
+      <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
       <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame	(revision 18091)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame	(revision 18092)
@@ -36,4 +36,7 @@
   [PluginDependency("HeuristicLab.Core", "3.3")]
   [PluginDependency("HeuristicLab.Data", "3.3")]
+  [PluginDependency("HeuristicLab.Encodings.BinaryVectorEncoding", "3.3")]
+  [PluginDependency("HeuristicLab.Encodings.IntegerVectorEncoding", "3.3")]
+  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
   [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
   [PluginDependency("HeuristicLab.NativeInterpreter", "0.1")]
Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SegmentOptimization/SegmentOptimizationProblem.cs
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SegmentOptimization/SegmentOptimizationProblem.cs	(revision 18092)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SegmentOptimization/SegmentOptimizationProblem.cs	(revision 18092)
@@ -0,0 +1,198 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 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.Linq;
+using HEAL.Attic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.IntegerVectorEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Problems.Instances;
+using HeuristicLab.Problems.Instances.Types;
+
+using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.SegmentOptimization {
+  [Item("Segment Optimization Problem (SOP)", "")]
+  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 1200)]
+  [StorableType("64107939-34A7-4530-BFAB-8EA1C321BF6F")]
+  public class SegmentOptimizationProblem : SingleObjectiveBasicProblem<IntegerVectorEncoding>, IProblemInstanceConsumer<SOPData> {
+
+    public enum Aggregation {
+      Sum,
+      Mean,
+      StandardDeviation
+    }
+
+    public override bool Maximization => false;
+
+    [Storable]
+    private IValueParameter<DoubleArray> dataVectorParameter;
+    public IValueParameter<DoubleArray> DataVectorParameter {
+      get { return dataVectorParameter; }
+    }
+    [Storable]
+    private IValueParameter<IntRange> knownBoundsParameter;
+    public IValueParameter<IntRange> KnownBoundsParameter {
+      get { return knownBoundsParameter; }
+    }
+    [Storable]
+    private IValueParameter<EnumValue<Aggregation>> aggregationParameter;
+    public IValueParameter<EnumValue<Aggregation>> AggregationParameter {
+      get { return aggregationParameter; }
+    }
+    
+    public SegmentOptimizationProblem() {
+      Encoding = new IntegerVectorEncoding("bounds");
+
+      Parameters.Add(dataVectorParameter = new ValueParameter<DoubleArray>("Data Vector", ""));
+      Parameters.Add(knownBoundsParameter = new ValueParameter<IntRange>("Known Bounds", ""));
+      Parameters.Add(aggregationParameter = new ValueParameter<EnumValue<Aggregation>>("Aggregation Function", ""));
+
+      RegisterEventHandlers();
+
+      #region Default Instance
+      Load(new SOPData() {
+        Values = Enumerable.Range(1, 50).Select(x => (double)x * x).ToArray(),
+        Lower = 20, Upper = 30,
+        Aggregation = "mean"
+      });
+      #endregion
+    }
+    private SegmentOptimizationProblem(SegmentOptimizationProblem original, Cloner cloner)
+      : base(original, cloner) {
+      dataVectorParameter = cloner.Clone(original.dataVectorParameter);
+      aggregationParameter = cloner.Clone(original.aggregationParameter);
+
+      RegisterEventHandlers();
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new SegmentOptimizationProblem(this, cloner);
+    }
+
+    [StorableConstructor]
+    private SegmentOptimizationProblem(StorableConstructorFlag _) : base(_) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      RegisterEventHandlers();
+    }
+    
+    private void RegisterEventHandlers() {
+      dataVectorParameter.ValueChanged += DataVectorChanged;
+      knownBoundsParameter.ValueChanged += KnownBoundsChanged;
+      aggregationParameter.Value.ValueChanged += AggregationFunctionChanged;
+    }
+    private void DataVectorChanged(object sender, EventArgs eventArgs) {
+      Encoding.Bounds = new IntMatrix(new[,] { { 0, DataVectorParameter.Value.Length } });
+    }
+    private void KnownBoundsChanged(object sender, EventArgs e) {
+    }
+    private void AggregationFunctionChanged(object sender, EventArgs eventArgs) {
+    }
+
+    public override double Evaluate(Individual individual, IRandom random) {
+      var data = DataVectorParameter.Value;
+      var knownBounds = KnownBoundsParameter.Value;
+      var aggregation = aggregationParameter.Value.Value;
+
+      var solution = individual.IntegerVector(Encoding.Name);
+      var bounds = new IntRange(solution.Min(), solution.Max());
+
+      double target = BoundedAggregation(data, knownBounds, aggregation);
+      double prediction = BoundedAggregation(data, bounds, aggregation);
+
+      return Math.Pow(target - prediction, 2);
+    }
+
+    public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
+      var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
+      var best = Maximization ? orderedIndividuals.Last().Individual.IntegerVector(Encoding.Name) : orderedIndividuals.First().Individual.IntegerVector(Encoding.Name);
+
+      var bounds = new IntRange(best.Min(), best.Max());
+
+      var data = DataVectorParameter.Value;
+      var knownBounds = KnownBoundsParameter.Value;
+      var aggregation = aggregationParameter.Value.Value;
+
+      double target = BoundedAggregation(data, knownBounds, aggregation);
+      double prediction = BoundedAggregation(data, bounds, aggregation);
+      double diff = target - prediction;
+
+      results.AddOrUpdateResult("Bounds", bounds);
+
+      results.AddOrUpdateResult("AggValue Diff", new DoubleValue(diff));
+      results.AddOrUpdateResult("AggValue Squared Diff", new DoubleValue(Math.Pow(diff, 2)));
+
+      results.AddOrUpdateResult("Lower Diff", new IntValue(knownBounds.Start - bounds.Start));
+      results.AddOrUpdateResult("Upper Diff", new IntValue(knownBounds.End - bounds.End));
+      results.AddOrUpdateResult("Length Diff", new IntValue(knownBounds.Size - bounds.Size));
+    }
+
+    private static double BoundedAggregation(DoubleArray data, IntRange bounds, Aggregation aggregation) {
+      if (bounds.Size == 0) {
+        return 0;
+      }
+
+      var vector = DoubleVector.Build.DenseOfEnumerable(data);
+      var segment = vector.SubVector(bounds.Start, bounds.Size);
+
+      switch (aggregation) {
+        case Aggregation.Sum:
+          return segment.Sum();
+        case Aggregation.Mean:
+         return segment.Average();
+          case Aggregation.StandardDeviation:
+          return segment.StandardDeviationPop();
+        default:
+          throw new NotImplementedException();
+      }
+    }
+
+    public void Load(SOPData data) {
+      DataVectorParameter.Value = new DoubleArray(data.Values);
+      KnownBoundsParameter.Value = new IntRange(data.Lower, data.Upper);
+      switch (data.Aggregation.ToLower()) {
+        case "sum":
+          AggregationParameter.Value.Value = Aggregation.Sum;
+          break;
+        case "mean":
+        case "avg":
+          AggregationParameter.Value.Value = Aggregation.Mean;
+          break;
+        case "standarddeviation":
+        case "std":
+        case "sd":
+          AggregationParameter.Value.Value = Aggregation.StandardDeviation;
+          break;
+        default:
+          throw new NotSupportedException();
+      }
+                                            
+      Encoding.Length = 2;
+      Encoding.Bounds = new IntMatrix(new[,] { { 0, DataVectorParameter.Value.Length } });
+
+      BestKnownQuality = 0;
+    }
+  }
+}
Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj	(revision 18091)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj	(revision 18092)
@@ -129,4 +129,5 @@
     <Compile Include="Types\DistanceHelper.cs" />
     <Compile Include="Types\OPData.cs" />
+    <Compile Include="Types\SOPData.cs" />
     <Compile Include="Types\VRP\MDCVRPTWData.cs" />
     <Compile Include="Types\VRP\MDCVRPData.cs" />
Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/Types/SOPData.cs
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/Types/SOPData.cs	(revision 18092)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances/3.3/Types/SOPData.cs	(revision 18092)
@@ -0,0 +1,14 @@
+﻿namespace HeuristicLab.Problems.Instances.Types {
+  /// <summary>
+  /// Describes instances of the Segment Optimization Problem (SOP).
+  /// </summary>
+  public class SOPData {
+    public string Name { get; set; }
+    public string Description { get; set; }
+
+    public double[] Values { get; set; } 
+    public int Upper { get; set; }
+    public int Lower { get; set; }
+    public string Aggregation { get; set; } // mean, sum, std
+  }
+}
