Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/AgentBasedSimulation.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/AgentBasedSimulation.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/AgentBasedSimulation.cs	(revision 6623)
@@ -0,0 +1,67 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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 HeuristicLab.Common;
+
+namespace HeuristicLab.SimulationCore.AgentBased {
+  [Item("AgentBasedSimulation", "A base class for agent based simulations.")]
+  [StorableClass]
+  public abstract class AgentBasedSimulation: Simulation {
+    [Storable]
+    private ItemList<IAgent> agents;
+    protected ItemList<IAgent> Agents {
+      get {
+        return agents;
+      }
+    }
+    
+    [StorableConstructor]
+    protected AgentBasedSimulation(bool deserializing) : base(deserializing) { }
+    protected AgentBasedSimulation()
+      : base() {
+        agents = new ItemList<IAgent>();  
+    }
+    protected AgentBasedSimulation(AgentBasedSimulation original, Cloner cloner)
+      : base(original, cloner) {
+        agents = cloner.Clone(original.agents) as ItemList<IAgent>;
+    }
+
+    protected void Step() {
+      foreach (IAgent agent in agents) {
+        agent.InitStep();
+      }
+
+      foreach (IAgent agent in agents) {
+        agent.PerformStep();
+      }
+
+      foreach (IAgent agent in agents) {
+        agent.FinalizeStep();
+      }
+    }
+  }
+}
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/IAgent.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/IAgent.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/AgentBased/IAgent.cs	(revision 6623)
@@ -0,0 +1,34 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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;
+
+namespace HeuristicLab.SimulationCore.AgentBased {
+  public interface IAgent: IItem {
+    void InitStep();
+    void PerformStep();
+    void FinalizeStep();
+  }
+}
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLab.SimulationCore-3.3.csproj
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLab.SimulationCore-3.3.csproj	(revision 6621)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLab.SimulationCore-3.3.csproj	(revision 6623)
@@ -106,4 +106,5 @@
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
@@ -112,6 +113,12 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AgentBased\AgentBasedSimulation.cs" />
+    <Compile Include="AgentBased\IAgent.cs" />
     <Compile Include="HeuristicLabSimulationCorePlugin.cs" />
+    <Compile Include="IScenario.cs" />
+    <Compile Include="ISimulation.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Scenario.cs" />
+    <Compile Include="Simulation.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -125,4 +132,8 @@
       <Name>HeuristicLab.Collections-3.3</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
+      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
+      <Name>HeuristicLab.Common.Resources-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
@@ -132,4 +143,8 @@
       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
       <Name>HeuristicLab.Core-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
+      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
+      <Name>HeuristicLab.Optimization-3.3</Name>
     </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
@@ -142,4 +157,5 @@
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLabSimulationCorePlugin.cs.frame
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLabSimulationCorePlugin.cs.frame	(revision 6621)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/HeuristicLabSimulationCorePlugin.cs.frame	(revision 6623)
@@ -33,4 +33,5 @@
   [PluginDependency("HeuristicLab.Collections", "3.3")]
   [PluginDependency("HeuristicLab.Common", "3.3")]
+  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
   [PluginDependency("HeuristicLab.Core", "3.3")]
   [PluginDependency("HeuristicLab.Persistence", "3.3")]
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/IScenario.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/IScenario.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/IScenario.cs	(revision 6623)
@@ -0,0 +1,32 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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.Optimization;
+
+namespace HeuristicLab.SimulationCore {
+  public interface IScenario : IProblem {
+  }
+}
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/ISimulation.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/ISimulation.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/ISimulation.cs	(revision 6623)
@@ -0,0 +1,32 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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.Optimization;
+
+namespace HeuristicLab.SimulationCore {
+  public interface ISimulation: IAlgorithm {
+  }
+}
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Scenario.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Scenario.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Scenario.cs	(revision 6623)
@@ -0,0 +1,51 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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 HeuristicLab.Common;
+
+namespace HeuristicLab.SimulationCore {
+  [Item("Scenario", "Represents the base class for a simulation scenario.")]
+  [StorableClass]
+  public abstract class Scenario : ParameterizedNamedItem, IScenario  {
+    [StorableConstructor]
+    protected Scenario(bool deserializing) : base(deserializing) { }
+    protected Scenario(Scenario original, Cloner cloner)
+      : base(original, cloner) {
+    }
+
+    protected Scenario() : base() {}
+
+    #region IProblem Members
+    public IEnumerable<IOperator> Operators {
+      get { return null; }
+    }
+    
+    public event EventHandler OperatorsChanged;
+    public event EventHandler Reset;
+    #endregion
+  }
+}
Index: branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Simulation.cs
===================================================================
--- branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Simulation.cs	(revision 6623)
+++ branches/SimulationCore/HeuristicLab.SimulationCore/3.3/Simulation.cs	(revision 6623)
@@ -0,0 +1,164 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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 System.Drawing;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+using HeuristicLab.Collections;
+using HeuristicLab.Optimization;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace HeuristicLab.SimulationCore {
+  [Item("Simulation", "A base class for simulations.")]
+  [StorableClass]
+  public abstract class Simulation: Algorithm, ISimulation, IStorableContent {
+    public string Filename { get; set; }
+        
+    public override Type ProblemType {
+      get { return typeof(IScenario); }
+    }
+
+    [Storable]
+    private ResultCollection results;
+    public override ResultCollection Results {
+      get {
+        return results;
+      }
+    }
+
+    #region Variables for communication between threads
+    private CancellationTokenSource cancellationTokenSource;
+    private bool stopPending;
+    private DateTime lastUpdateTime;
+    #endregion
+
+    [StorableConstructor]
+    protected Simulation(bool deserializing) : base(deserializing) { }
+    protected Simulation()
+      : base() {
+        results = new ResultCollection();
+    }
+    protected Simulation(Simulation original, Cloner cloner)
+      : base(original, cloner) {
+        results = cloner.Clone(original.results) as ResultCollection;
+    }
+
+    public sealed override void Prepare() {
+      base.Prepare();
+      results.Clear();
+      OnPrepared();
+    }
+    protected override void OnPrepared() {
+      base.OnPrepared();
+    }
+
+    public override void Start() {
+      base.Start();
+      cancellationTokenSource = new CancellationTokenSource();
+      stopPending = false;
+      Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
+      task.ContinueWith(t => {
+        try {
+          t.Wait();
+        }
+        catch (AggregateException ex) {
+          try {
+            ex.Flatten().Handle(x => x is OperationCanceledException);
+          }
+          catch (AggregateException remaining) {
+            if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
+            else OnExceptionOccurred(remaining);
+          }
+        }
+        cancellationTokenSource.Dispose();
+        cancellationTokenSource = null;
+        if (stopPending) OnStopped();
+        else OnPaused();
+      });
+    }
+    protected override void OnStarted() {
+      base.OnStarted();
+    }
+
+    public override void Pause() {
+      base.Pause();
+      cancellationTokenSource.Cancel();
+    }
+    protected override void OnPaused() {
+      base.OnPaused();
+    }
+
+    public override void Stop() {
+      base.Stop();
+      if (ExecutionState == ExecutionState.Paused) {
+        OnStopped();
+      } else {
+        stopPending = true;
+        cancellationTokenSource.Cancel();
+      }
+    }
+    protected override void OnStopped() {
+      base.OnStopped();
+    }
+
+    protected override void OnExceptionOccurred(Exception exception) {
+      base.OnExceptionOccurred(exception);
+    }
+
+    private void Run(object state) {
+      CancellationToken cancellationToken = (CancellationToken)state;
+
+      OnStarted();
+      lastUpdateTime = DateTime.Now;
+      System.Timers.Timer timer = new System.Timers.Timer(250);
+      timer.AutoReset = true;
+      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
+      timer.Start();
+      try {
+        Run(cancellationToken);
+      }
+      finally {
+        timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
+        timer.Stop();
+        ExecutionTime += DateTime.Now - lastUpdateTime;
+      }
+      Stop();
+
+      cancellationToken.ThrowIfCancellationRequested();
+    }
+    protected abstract void Run(CancellationToken cancellationToken);
+
+    private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
+      System.Timers.Timer timer = (System.Timers.Timer)sender;
+      timer.Enabled = false;
+      DateTime now = DateTime.Now;
+      ExecutionTime += now - lastUpdateTime;
+      lastUpdateTime = now;
+      timer.Enabled = true;
+    }
+  }
+}
