Index: trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs	(revision 3261)
+++ trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs	(revision 3262)
@@ -36,4 +36,26 @@
     public override Image ItemImage {
       get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event; }
+    }
+
+    [Storable]
+    private ExecutionState executionState;
+    public ExecutionState ExecutionState {
+      get { return executionState; }
+      private set {
+        if (executionState != value) {
+          executionState = value;
+          OnExecutionStateChanged();
+        }
+      }
+    }
+
+    [Storable]
+    private TimeSpan executionTime;
+    public TimeSpan ExecutionTime {
+      get { return executionTime; }
+      protected set {
+        executionTime = value;
+        OnExecutionTimeChanged();
+      }
     }
 
@@ -68,54 +90,54 @@
     public abstract ResultCollection Results { get; }
 
-    public abstract TimeSpan ExecutionTime { get; }
-
-    private bool running;
-    public bool Running {
-      get { return running; }
-      protected set {
-        if (running != value) {
-          running = value;
-          OnRunningChanged();
-        }
-      }
-    }
-
-    public abstract bool Finished { get; }
-
-    private bool canceled;
-    protected bool Canceled {
-      get { return canceled; }
-      private set {
-        if (canceled != value) {
-          canceled = value;
-          OnCanceledChanged();
-        }
-      }
-    }
-
-    protected Algorithm() : base() { }
-    protected Algorithm(string name) : base(name) { }
-    protected Algorithm(string name, ParameterCollection parameters) : base(name, parameters) { }
-    protected Algorithm(string name, string description) : base(name, description) { }
-    protected Algorithm(string name, string description, ParameterCollection parameters) : base(name, description, parameters) { }
+    protected Algorithm()
+      : base() {
+      executionState = ExecutionState.Stopped;
+      executionTime = TimeSpan.Zero;
+    }
+    protected Algorithm(string name)
+      : base(name) {
+      executionState = ExecutionState.Stopped;
+      executionTime = TimeSpan.Zero;
+    }
+    protected Algorithm(string name, ParameterCollection parameters)
+      : base(name, parameters) {
+      executionState = ExecutionState.Stopped;
+      executionTime = TimeSpan.Zero;
+    }
+    protected Algorithm(string name, string description)
+      : base(name, description) {
+      executionState = ExecutionState.Stopped;
+      executionTime = TimeSpan.Zero;
+    }
+    protected Algorithm(string name, string description, ParameterCollection parameters)
+      : base(name, description, parameters) {
+      executionState = ExecutionState.Stopped;
+      executionTime = TimeSpan.Zero;
+    }
 
     public override IDeepCloneable Clone(Cloner cloner) {
       Algorithm clone = (Algorithm)base.Clone(cloner);
+      clone.executionState = executionState;
+      clone.executionTime = executionTime;
       clone.Problem = (IProblem)cloner.Clone(problem);
-      clone.running = running;
-      clone.canceled = canceled;
       return clone;
     }
 
-    public void Prepare() {
-      OnPrepared();
-    }
-    public void Start() {
-      OnStarted();
-      Running = true;
-      Canceled = false;
-    }
-    public void Stop() {
-      Canceled = true;
+    public virtual void Prepare() {
+      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
+        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
+      ExecutionTime = TimeSpan.Zero;
+    }
+    public virtual void Start() {
+      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
+        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
+    }
+    public virtual void Pause() {
+      if (ExecutionState != ExecutionState.Started)
+        throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState));
+    }
+    public virtual void Stop() {
+      if ((ExecutionState != ExecutionState.Started) && (ExecutionState != ExecutionState.Paused))
+        throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState));
     }
 
@@ -130,41 +152,47 @@
 
     #region Events
+    public event EventHandler ExecutionStateChanged;
+    protected virtual void OnExecutionStateChanged() {
+      EventHandler handler = ExecutionStateChanged;
+      if (handler != null) handler(this, EventArgs.Empty);
+    }
+    public event EventHandler ExecutionTimeChanged;
+    protected virtual void OnExecutionTimeChanged() {
+      EventHandler handler = ExecutionTimeChanged;
+      if (handler != null) handler(this, EventArgs.Empty);
+    }
     public event EventHandler ProblemChanged;
     protected virtual void OnProblemChanged() {
-      if (ProblemChanged != null)
-        ProblemChanged(this, EventArgs.Empty);
-    }
-    public event EventHandler ExecutionTimeChanged;
-    protected virtual void OnExecutionTimeChanged() {
-      if (ExecutionTimeChanged != null)
-        ExecutionTimeChanged(this, EventArgs.Empty);
-    }
-    public event EventHandler RunningChanged;
-    protected virtual void OnRunningChanged() {
-      if (RunningChanged != null)
-        RunningChanged(this, EventArgs.Empty);
+      EventHandler handler = ProblemChanged;
+      if (handler != null) handler(this, EventArgs.Empty);
     }
     public event EventHandler Prepared;
     protected virtual void OnPrepared() {
-      if (Prepared != null)
-        Prepared(this, EventArgs.Empty);
+      ExecutionState = ExecutionState.Prepared;
+      EventHandler handler = Prepared;
+      if (handler != null) handler(this, EventArgs.Empty);
     }
     public event EventHandler Started;
     protected virtual void OnStarted() {
-      if (Started != null)
-        Started(this, EventArgs.Empty);
+      ExecutionState = ExecutionState.Started;
+      EventHandler handler = Started;
+      if (handler != null) handler(this, EventArgs.Empty);
+    }
+    public event EventHandler Paused;
+    protected virtual void OnPaused() {
+      ExecutionState = ExecutionState.Paused;
+      EventHandler handler = Paused;
+      if (handler != null) handler(this, EventArgs.Empty);
     }
     public event EventHandler Stopped;
     protected virtual void OnStopped() {
-      Canceled = false;
-      Running = false;
-      if (Stopped != null)
-        Stopped(this, EventArgs.Empty);
-    }
-    protected virtual void OnCanceledChanged() { }
+      ExecutionState = ExecutionState.Stopped;
+      EventHandler handler = Stopped;
+      if (handler != null) handler(this, EventArgs.Empty);
+    }
     public event EventHandler<EventArgs<Exception>> ExceptionOccurred;
     protected virtual void OnExceptionOccurred(Exception exception) {
-      if (ExceptionOccurred != null)
-        ExceptionOccurred(this, new EventArgs<Exception>(exception));
+      EventHandler<EventArgs<Exception>> handler = ExceptionOccurred;
+      if (handler != null) handler(this, new EventArgs<Exception>(exception));
     }
 
Index: trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs	(revision 3261)
+++ trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs	(revision 3262)
@@ -94,18 +94,4 @@
     }
 
-    public override TimeSpan ExecutionTime {
-      get {
-        if (engine == null) return TimeSpan.Zero;
-        else return engine.ExecutionTime;
-      }
-    }
-
-    public override bool Finished {
-      get {
-        if (engine == null) return true;
-        else return engine.Finished;
-      }
-    }
-
     protected EngineAlgorithm()
       : base() {
@@ -172,9 +158,6 @@
     }
 
-    protected override void OnCanceledChanged() {
-      if (Canceled && (engine != null))
-        engine.Stop();
-    }
-    protected override void OnPrepared() {
+    public override void Prepare() {
+      base.Prepare();
       globalScope.Clear();
       globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
@@ -195,13 +178,19 @@
         engine.Prepare(context);
       }
-      base.OnPrepared();
-    }
-    protected override void OnStarted() {
+    }
+    public override void Start() {
+      base.Start();
       if (engine != null) engine.Start();
-      base.OnStarted();
-    }
-
-    protected virtual void OnOperatorGraphChanged() { }
-
+    }
+    public override void Pause() {
+      base.Pause();
+      if (engine != null) engine.Pause();
+    }
+    public override void Stop() {
+      base.Stop();
+      if (engine != null) engine.Stop();
+    }
+
+    #region Events
     public event EventHandler EngineChanged;
     protected virtual void OnEngineChanged() {
@@ -209,29 +198,45 @@
         EngineChanged(this, EventArgs.Empty);
     }
-
-    private void OperatorGraph_InitialOperatorChanged(object sender, EventArgs e) {
-      Prepare();
-    }
+    protected virtual void OnOperatorGraphChanged() { }
+
     private void RegisterEngineEvents() {
       Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
       Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged);
+      Engine.Paused += new EventHandler(Engine_Paused);
+      Engine.Prepared += new EventHandler(Engine_Prepared);
+      Engine.Started += new EventHandler(Engine_Started);
       Engine.Stopped += new EventHandler(Engine_Stopped);
     }
-
     private void DeregisterEngineEvents() {
       Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
       Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged);
+      Engine.Paused -= new EventHandler(Engine_Paused);
+      Engine.Prepared -= new EventHandler(Engine_Prepared);
+      Engine.Started -= new EventHandler(Engine_Started);
       Engine.Stopped -= new EventHandler(Engine_Stopped);
     }
-
     private void Engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
       OnExceptionOccurred(e.Value);
     }
     private void Engine_ExecutionTimeChanged(object sender, EventArgs e) {
-      OnExecutionTimeChanged();
+      ExecutionTime = Engine.ExecutionTime;
+    }
+    private void Engine_Paused(object sender, EventArgs e) {
+      OnPaused();
+    }
+    private void Engine_Prepared(object sender, EventArgs e) {
+      OnPrepared();
+    }
+    private void Engine_Started(object sender, EventArgs e) {
+      OnStarted();
     }
     private void Engine_Stopped(object sender, EventArgs e) {
       OnStopped();
     }
+
+    private void OperatorGraph_InitialOperatorChanged(object sender, EventArgs e) {
+      Prepare();
+    }
+    #endregion
   }
 }
Index: trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj	(revision 3261)
+++ trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj	(revision 3262)
@@ -86,5 +86,4 @@
     <None Include="HeuristicLabOptimizationPlugin.cs.frame" />
     <Compile Include="Algorithm.cs" />
-    <Compile Include="BatchRun.cs" />
     <Compile Include="RunCollection.cs" />
     <Compile Include="Run.cs" />
Index: trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs	(revision 3261)
+++ trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs	(revision 3262)
@@ -29,25 +29,12 @@
   /// Interface to represent an algorithm.
   /// </summary>
-  public interface IAlgorithm : IParameterizedNamedItem {
+  public interface IAlgorithm : IParameterizedNamedItem, IExecutable {
     Type ProblemType { get; }
     IProblem Problem { get; set; }
     ResultCollection Results { get; }
-    TimeSpan ExecutionTime { get; }
-    bool Running { get; }
-    bool Finished { get; }
-
-    void Prepare();
-    void Start();
-    void Stop();
 
     void CollectResultValues(IDictionary<string, IItem> values);
 
     event EventHandler ProblemChanged;
-    event EventHandler ExecutionTimeChanged;
-    event EventHandler RunningChanged;
-    event EventHandler Prepared;
-    event EventHandler Started;
-    event EventHandler Stopped;
-    event EventHandler<EventArgs<Exception>> ExceptionOccurred;
   }
 }
Index: trunk/sources/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs	(revision 3261)
+++ trunk/sources/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs	(revision 3262)
@@ -55,6 +55,6 @@
     public event EventHandler OperatorGraphChanged;
     protected override void OnOperatorGraphChanged() {
-      if (OperatorGraphChanged != null)
-        OperatorGraphChanged(this, EventArgs.Empty);
+      EventHandler handler = OperatorGraphChanged;
+      if (handler != null) handler(this, EventArgs.Empty);
     }
   }
