Index: /branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMASEvolutionStrategy.cs
===================================================================
--- /branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMASEvolutionStrategy.cs	(revision 14613)
+++ /branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMASEvolutionStrategy.cs	(revision 14614)
@@ -42,16 +42,13 @@
   [StorableClass]
   public class MOCMASEvolutionStrategy : BasicAlgorithm {
-    public override Type ProblemType
-    {
+    public override Type ProblemType {
       get { return typeof(MultiObjectiveBasicProblem<RealVectorEncoding>); }
     }
-    public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem
-    {
+    public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem {
       get { return (MultiObjectiveBasicProblem<RealVectorEncoding>)base.Problem; }
       set { base.Problem = value; }
     }
-    public override bool SupportsPause
-    {
-      get { return false; }
+    public override bool SupportsPause {
+      get { return true; }
     }
 
@@ -90,34 +87,26 @@
 
     #region ParameterProperties
-    public IFixedValueParameter<IntValue> MaximumRuntimeParameter
-    {
+    public IFixedValueParameter<IntValue> MaximumRuntimeParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[MaximumRuntimeName]; }
     }
-    public IFixedValueParameter<IntValue> SeedParameter
-    {
+    public IFixedValueParameter<IntValue> SeedParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[SeedName]; }
     }
-    public FixedValueParameter<BoolValue> SetSeedRandomlyParameter
-    {
+    public FixedValueParameter<BoolValue> SetSeedRandomlyParameter {
       get { return (FixedValueParameter<BoolValue>)Parameters[SetSeedRandomlyName]; }
     }
-    public IFixedValueParameter<IntValue> PopulationSizeParameter
-    {
+    public IFixedValueParameter<IntValue> PopulationSizeParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[PopulationSizeName]; }
     }
-    public IFixedValueParameter<IntValue> MaximumGenerationsParameter
-    {
+    public IFixedValueParameter<IntValue> MaximumGenerationsParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[MaximumGenerationsName]; }
     }
-    public IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter
-    {
+    public IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[MaximumEvaluatedSolutionsName]; }
     }
-    public IFixedValueParameter<DoubleValue> InitialSigmaParameter
-    {
-      get { return (IFixedValueParameter<DoubleValue>)Parameters[InitialSigmaName]; }
-    }
-    public IConstrainedValueParameter<IIndicator> IndicatorParameter
-    {
+    public IValueParameter<DoubleArray> InitialSigmaParameter {
+      get { return (IValueParameter<DoubleArray>)Parameters[InitialSigmaName]; }
+    }
+    public IConstrainedValueParameter<IIndicator> IndicatorParameter {
       get { return (IConstrainedValueParameter<IIndicator>)Parameters[IndicatorName]; }
     }
@@ -125,41 +114,33 @@
 
     #region Properties
-    public int MaximumRuntime
-    {
+    public int MaximumRuntime {
       get { return MaximumRuntimeParameter.Value.Value; }
       set { MaximumRuntimeParameter.Value.Value = value; }
     }
-    public int Seed
-    {
+    public int Seed {
       get { return SeedParameter.Value.Value; }
       set { SeedParameter.Value.Value = value; }
     }
-    public bool SetSeedRandomly
-    {
+    public bool SetSeedRandomly {
       get { return SetSeedRandomlyParameter.Value.Value; }
       set { SetSeedRandomlyParameter.Value.Value = value; }
     }
-    public int PopulationSize
-    {
+    public int PopulationSize {
       get { return PopulationSizeParameter.Value.Value; }
       set { PopulationSizeParameter.Value.Value = value; }
     }
-    public int MaximumGenerations
-    {
+    public int MaximumGenerations {
       get { return MaximumGenerationsParameter.Value.Value; }
       set { MaximumGenerationsParameter.Value.Value = value; }
     }
-    public int MaximumEvaluatedSolutions
-    {
+    public int MaximumEvaluatedSolutions {
       get { return MaximumEvaluatedSolutionsParameter.Value.Value; }
       set { MaximumEvaluatedSolutionsParameter.Value.Value = value; }
     }
-    public double InitialSigma
-    {
-      get { return InitialSigmaParameter.Value.Value; }
-      set { InitialSigmaParameter.Value.Value = value; }
-    }
-    public IIndicator Indicator
-    {
+    public DoubleArray InitialSigma {
+      get { return InitialSigmaParameter.Value; }
+      set { InitialSigmaParameter.Value = value; }
+    }
+    public IIndicator Indicator {
       get { return IndicatorParameter.Value; }
       set { IndicatorParameter.Value = value; }
@@ -170,86 +151,68 @@
 
     #region ResultsProperties
-    private int ResultsEvaluations
-    {
+    private int ResultsEvaluations {
       get { return ((IntValue)Results[EvaluationsResultName].Value).Value; }
       set { ((IntValue)Results[EvaluationsResultName].Value).Value = value; }
     }
-    private int ResultsIterations
-    {
+    private int ResultsIterations {
       get { return ((IntValue)Results[IterationsResultName].Value).Value; }
       set { ((IntValue)Results[IterationsResultName].Value).Value = value; }
     }
     #region Datatable
-    private DataTable ResultsQualities
-    {
+    private DataTable ResultsQualities {
       get { return (DataTable)Results[TimetableResultName].Value; }
     }
-    private DataRow ResultsBestHypervolumeDataLine
-    {
+    private DataRow ResultsBestHypervolumeDataLine {
       get { return ResultsQualities.Rows[BestHypervolumeResultName]; }
     }
-    private DataRow ResultsHypervolumeDataLine
-    {
+    private DataRow ResultsHypervolumeDataLine {
       get { return ResultsQualities.Rows[HypervolumeResultName]; }
     }
-    private DataRow ResultsGenerationalDistanceDataLine
-    {
+    private DataRow ResultsGenerationalDistanceDataLine {
       get { return ResultsQualities.Rows[GenerationalDistanceResultName]; }
     }
-    private DataRow ResultsInvertedGenerationalDistanceDataLine
-    {
+    private DataRow ResultsInvertedGenerationalDistanceDataLine {
       get { return ResultsQualities.Rows[InvertedGenerationalDistanceResultName]; }
     }
-    private DataRow ResultsCrowdingDataLine
-    {
+    private DataRow ResultsCrowdingDataLine {
       get { return ResultsQualities.Rows[CrowdingResultName]; }
     }
-    private DataRow ResultsSpacingDataLine
-    {
+    private DataRow ResultsSpacingDataLine {
       get { return ResultsQualities.Rows[SpacingResultName]; }
     }
-    private DataRow ResultsHypervolumeDifferenceDataLine
-    {
+    private DataRow ResultsHypervolumeDifferenceDataLine {
       get { return ResultsQualities.Rows[DifferenceToBestKnownHypervolumeResultName]; }
     }
     #endregion
     //QualityIndicators
-    private double ResultsHypervolume
-    {
+    private double ResultsHypervolume {
       get { return ((DoubleValue)Results[HypervolumeResultName].Value).Value; }
       set { ((DoubleValue)Results[HypervolumeResultName].Value).Value = value; }
     }
-    private double ResultsGenerationalDistance
-    {
+    private double ResultsGenerationalDistance {
       get { return ((DoubleValue)Results[GenerationalDistanceResultName].Value).Value; }
       set { ((DoubleValue)Results[GenerationalDistanceResultName].Value).Value = value; }
     }
-    private double ResultsInvertedGenerationalDistance
-    {
+    private double ResultsInvertedGenerationalDistance {
       get { return ((DoubleValue)Results[InvertedGenerationalDistanceResultName].Value).Value; }
       set { ((DoubleValue)Results[InvertedGenerationalDistanceResultName].Value).Value = value; }
     }
-    private double ResultsCrowding
-    {
+    private double ResultsCrowding {
       get { return ((DoubleValue)Results[CrowdingResultName].Value).Value; }
       set { ((DoubleValue)Results[CrowdingResultName].Value).Value = value; }
     }
-    private double ResultsSpacing
-    {
+    private double ResultsSpacing {
       get { return ((DoubleValue)Results[SpacingResultName].Value).Value; }
       set { ((DoubleValue)Results[SpacingResultName].Value).Value = value; }
     }
-    private double ResultsBestHypervolume
-    {
+    private double ResultsBestHypervolume {
       get { return ((DoubleValue)Results[BestHypervolumeResultName].Value).Value; }
       set { ((DoubleValue)Results[BestHypervolumeResultName].Value).Value = value; }
     }
-    private double ResultsBestKnownHypervolume
-    {
+    private double ResultsBestKnownHypervolume {
       get { return ((DoubleValue)Results[BestKnownHypervolumeResultName].Value).Value; }
       set { ((DoubleValue)Results[BestKnownHypervolumeResultName].Value).Value = value; }
     }
-    private double ResultsDifferenceBestKnownHypervolume
-    {
+    private double ResultsDifferenceBestKnownHypervolume {
       get { return ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value; }
       set { ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value = value; }
@@ -257,11 +220,9 @@
     }
     //Solutions
-    private DoubleMatrix ResultsSolutions
-    {
+    private DoubleMatrix ResultsSolutions {
       get { return ((DoubleMatrix)Results[CurrentFrontResultName].Value); }
       set { Results[CurrentFrontResultName].Value = value; }
     }
-    private ScatterPlotContent ResultsScatterPlot
-    {
+    private ScatterPlotContent ResultsScatterPlot {
       get { return ((ScatterPlotContent)Results[ScatterPlotResultName].Value); }
       set { Results[ScatterPlotResultName].Value = value; }
@@ -275,5 +236,5 @@
       Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
       Parameters.Add(new FixedValueParameter<IntValue>(PopulationSizeName, "λ (lambda) - the size of the offspring population.", new IntValue(20)));
-      Parameters.Add(new FixedValueParameter<DoubleValue>(InitialSigmaName, "The initial sigma is a single value > 0.", new DoubleValue(0.5)));
+      Parameters.Add(new ValueParameter<DoubleArray>(InitialSigmaName, "The initial sigma can be a single value or a value for each dimension. All values need to be > 0.", new DoubleArray(new[] { 0.5 })));
       Parameters.Add(new FixedValueParameter<IntValue>(MaximumGenerationsName, "The maximum number of generations which should be processed.", new IntValue(1000)));
       Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluatedSolutionsName, "The maximum number of evaluated solutions that should be computed.", new IntValue(int.MaxValue)));
@@ -289,6 +250,6 @@
 
     #region Mainloop
-    protected override void Run(CancellationToken cancellationToken) {
-      // Set up the algorithm
+
+    protected override void Initialize(CancellationToken cancellationToken) {
       if (SetSeedRandomly) Seed = new System.Random().Next();
       random.Reset(Seed);
@@ -300,11 +261,15 @@
       AnalyzeSolutions();
 
+      ResultsIterations = 1;
+    }
+
+    protected override void Run(CancellationToken cancellationToken) {
       // Loop until iteration limit reached or canceled.
-      for (ResultsIterations = 1; ResultsIterations < MaximumGenerations; ResultsIterations++) {
+      while (ResultsIterations < MaximumGenerations) {
         try {
           Iterate();
+          ResultsIterations++;
           cancellationToken.ThrowIfCancellationRequested();
-        }
-        finally {
+        } finally {
           AnalyzeSolutions();
         }
@@ -328,8 +293,12 @@
     #region Initialization
     private MOCMAESIndividual InitializeIndividual(RealVector x) {
-      var zeros = new RealVector(Enumerable.Range(0, Problem.Encoding.Length).Select(i => (Problem.Encoding.Bounds[i, 1] + Problem.Encoding.Bounds[i, 0]) / 2).ToArray());
-      var identity = new double[x.Length, x.Length];
-      for (var i = 0; i < x.Length; i++) identity[i, i] = (Problem.Encoding.Bounds[i % Problem.Encoding.Bounds.Rows, 1] - Problem.Encoding.Bounds[i % Problem.Encoding.Bounds.Rows, 0]);
-      return new MOCMAESIndividual(x, internals.TargetSuccessProbability, InitialSigma, zeros, identity, internals);
+      var zeros = new RealVector(x.Length);
+      var c = new double[x.Length, x.Length];
+      double sigma = InitialSigma.Max();
+      for (var i = 0; i < x.Length; i++) {
+        double d = InitialSigma[i % InitialSigma.Length] / sigma;
+        c[i, i] = d * d;
+      }
+      return new MOCMAESIndividual(x, internals.TargetSuccessProbability, sigma, zeros, c, internals);
     }
     private void InitSolutions() {
