Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 9166)
@@ -6,4 +6,6 @@
 using Microsoft.WindowsAzure;
 using Microsoft.WindowsAzure.StorageClient;
+using Microsoft.WindowsAzure.ServiceRuntime;
+using System.Diagnostics;
 
 namespace HeuristicLab.Services.Optimization.ControllerService.Azure {
@@ -98,5 +100,11 @@
       get {
         if (storageAccount == null) {
-          storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(AzureConstants.CLOUD_SETTINGS_KEY));
+          try {
+            storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(AzureConstants.CLOUD_SETTINGS_KEY));
+          }
+          catch (Exception ex) {
+            Trace.WriteLine(ex.Message);
+            storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=optimizationstorage1;AccountKey=n7Leom8ZFWkof/VQ2a4aRSvwOlX+Gwr3uojQF9CFJw1osmGCV0WwaNC8s7nkZ+qteLduAgW2l75WFpbXrkvG4Q==");
+          }
         }
         return storageAccount; 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/General/Configuration.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/General/Configuration.cs	(revision 9166)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/General/Configuration.cs	(revision 9166)
@@ -0,0 +1,22 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.WindowsAzure.ServiceRuntime;
+using System.Configuration;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.General {
+  public static class Configuration {
+    private static string GetSetting(string setting) {
+      if (RoleEnvironment.IsAvailable) {
+        return RoleEnvironment.GetConfigurationSettingValue(setting);
+      }
+      else {
+        return ConfigurationManager.AppSettings[setting];
+      }
+    }
+
+    public static string HiveEndpointName { get { return GetSetting("HiveEndpointName"); } }
+    public static string ControllerEndpointName { get { return GetSetting("ControllerEndpointName"); } }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs	(revision 9166)
@@ -11,5 +11,5 @@
 namespace HeuristicLab.Services.Optimization.ControllerService {
   public interface IScenarioMapper {
-    void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm);
+    void MapScenario(OptimizationScenario scenario, out IAlgorithm algorithm);
   }
 
@@ -18,4 +18,9 @@
       var dv = parameter.Value as DecimalValue;
       return new DoubleValue(dv.Value);      
+    }
+
+    public static T Create<T>(Parameter typeParameter) {
+      var type = Type.GetType((typeParameter.Value as TypeValue).Value);      
+      return (T)Activator.CreateInstance(type, null);
     }
 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs	(revision 9166)
@@ -7,5 +7,5 @@
 namespace HeuristicLab.Services.Optimization.ControllerService.Model {
   public static class HiveMapper {    
-    public static double FindDoubleValue(this InputParameters ip, string what) {     
+    public static double FindDoubleValue(this ProblemParameters ip, string what) {     
       foreach (var param in ip.Items) {
         if (param.Value.Name == what) {
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 9166)
@@ -20,4 +20,5 @@
 using HeuristicLab.Services.Optimization.ControllerService.Azure;
 using System.Data;
+using HeuristicLab.Services.Optimization.ControllerService.General;
 
 namespace HeuristicLab.Services.Optimization.ControllerService {
@@ -43,5 +44,5 @@
     private static object lockable;
     private Dictionary<string, IScenarioMapper> mappers = new Dictionary<string, IScenarioMapper>();
-    private IDataAccessLayer dal = new AzureDataAccessLayer();
+    private IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
 
     public static readonly string SCENARIO_TABLE = "Scenario";
@@ -51,15 +52,23 @@
     }
 
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
-      Experiment experiment = new Experiment();
-      var problem = new TravelingSalesmanProblem();
-      var algo = new GeneticAlgorithm();
-      algo.Problem = problem;      
+    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+      // Experiment experiment = new Experiment();
+      // var problem = new TravelingSalesmanProblem();
+      // var algo = new GeneticAlgorithm();
+      // algo.Problem = problem;      
       
       IScenarioMapper mapper = GetMapper(scenario);
-      mapper.MapScenario(scenario, algo);  
-
-      //experiment.Optimizers.Add(algo);
-      SendExperimentToHive(user, algo);
+      IAlgorithm algo;
+      mapper.MapScenario(scenario, out algo);
+      if (details.Repititions > 1) {
+        BatchRun br = new BatchRun();
+        //br.Name = details.JobTitle;
+        br.Optimizer = algo;        
+        br.Repetitions = details.Repititions;
+        SendExperimentToHive(user, br, details);
+      }
+      else {       
+        SendExperimentToHive(user, algo, details);
+      }
     }
 
@@ -73,5 +82,5 @@
     }
 
-    private IScenarioMapper CompileMapper(string scenarioMapper) {
+    public static IScenarioMapper CompileMapper(string scenarioMapper) {
        // http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe
       using (var csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()) {
@@ -105,13 +114,14 @@
 
     private IScenarioMapper GetMapper(Model.OptimizationScenario scenario) {
-      if (!mappers.ContainsKey(scenario.Name)) {
+      var id = scenario.Id;
+      if (!mappers.ContainsKey(id)) {
         lock (lockable) {
-          if (mappers.ContainsKey(scenario.Name))
-            return mappers[scenario.Name];
+          if (mappers.ContainsKey(id))
+            return mappers[id];
           
-          var mapperString = GetMapperFromBlobStore(scenario.Name);
+          var mapperString = GetMapperFromBlobStore(id);
           var mapper = CompileMapper(mapperString);
 
-          mappers[scenario.Name] = mapper;
+          mappers[id] = mapper;
           return mapper;
         } // lock        
@@ -120,19 +130,26 @@
      }  
 
-    private void MapExperiment(Model.OptimizationScenario scenario, IAlgorithm algorithm) {      
+    private void MapExperiment(Model.OptimizationScenario scenario, out IAlgorithm algorithm) {      
       IScenarioMapper mapper = GetMapper(scenario);
-      mapper.MapScenario(scenario, algorithm);     
-    }
-
-    private void SendExperimentToHive(Model.User user, IAlgorithm exp) {
+      mapper.MapScenario(scenario, out algorithm);     
+    }
+
+    private void ConfigureHive(Model.User user) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = Configuration.HiveEndpointName;      
+    }
+
+    private void SendExperimentToHive(Model.User user, IOptimizer exp, JobExecutionDetails details) {      
       var job = new RefreshableJob();
       job.IsAllowedPrivileged = true;      
-      job.Job.Name = "Web Scheduled Traveling Salesman Job";
-      job.Job.ResourceNames = "TESTGROUP";
-      job.RefreshAutomatically = false;
+      job.Job.Name = details.JobTitle;
+      job.Job.ResourceNames = details.Group;      
+      job.RefreshAutomatically = false;     
+      if (exp.ExecutionState != ExecutionState.Prepared) {
+        exp.Prepare();
+      }      
       job.HiveTasks.Add(new OptimizerHiveTask(exp));
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      ConfigureHive(user);
       
       HiveClient.StartJob((ex) => { 
@@ -145,10 +162,8 @@
 
     public IList<Model.Job> GetJobs(User user) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      ConfigureHive(user);
       var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
       IList<Model.Job> jobs = new List<Model.Job>();
-      
+
       foreach (var job in jobsLoaded) {
         jobs.Add(ConvertJob(user, job));
@@ -163,28 +178,8 @@
       if (job.CalculatingCount > 0)
         state = JobState.Calculating;
-      else if (job.JobCount == job.FinishedCount)
+      else if (job.JobCount > 0 && job.JobCount == job.FinishedCount)
         state = JobState.Finished;
       else
         state = JobState.Waiting;
-      /*var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
-      
-      foreach (var task in jobTasks) {        
-        switch (task.State) {
-          case TaskState.Aborted:
-            state = JobState.Aborted;
-            break;
-          case TaskState.Failed:
-            state = JobState.Failed;
-            break;
-        }
-      }
-      if (!state.HasValue) {
-        if (job.CalculatingCount > 0)
-          state = JobState.Calculating;
-        else if (waitingJobs > 0)
-          state = JobState.Waiting;
-        else
-          state = JobState.Finished;        
-      }*/
       return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value, DateCreated = job.DateCreated };
     }
@@ -192,7 +187,5 @@
 
     public Model.Job GetJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      ConfigureHive(user);
       var guid = Guid.Parse(id);
       return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
@@ -201,7 +194,5 @@
 
     public void DeleteJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      ConfigureHive(user);
       var guid = Guid.Parse(id);
       HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
@@ -209,7 +200,5 @@
 
     public IList<Model.Run> GetJobResults(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      ConfigureHive(user);
       var guid = Guid.Parse(id);
       var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManagerOld.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManagerOld.cs	(revision 9062)
+++ 	(revision )
@@ -1,311 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
-using HeuristicLab.Optimization;
-using HeuristicLab.Algorithms.GeneticAlgorithm;
-using HeuristicLab.Problems.TravelingSalesman;
-using HeuristicLab;
-using System.Reflection;
-using HeuristicLab.Services.Optimization.ControllerService.Model;
-using HeuristicLab.Core;
-using System.Collections;
-using HeuristicLab.Clients.Hive;
-using System.Threading;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public class HiveScenarioManagerOld : IScenarioManager {
-    public object MapControllerDataType(object model, Parameter param) {
-      switch (param.Type) {
-        case ParameterType.Boolean:
-          return (param.Value as Model.BoolValue).Value;
-        case ParameterType.Integer:
-          return Convert.ToInt32((param.Value as Model.DecimalValue).Value);          
-        case ParameterType.Percent:        
-        case ParameterType.Decimal:
-          return (param.Value as Model.DecimalValue).Value;
-        case ParameterType.DecimalMatrix:
-          return Utility.ToMultiD(((param.Value as Model.DecimalMatrix).Value));
-        case ParameterType.DecimalVector:
-          return (param.Value as Model.DecimalVector).Value;
-        case ParameterType.Type:
-          //TODO handle type correctly!
-          var typeValue = param.Value as Model.TypeValue;
-          
-          IProblem problem = model as IProblem;
-          IAlgorithm algoModel = model as IAlgorithm;
-          if (problem == null && algoModel != null) {
-            problem = algoModel.Problem;
-          }
-
-          if (problem != null) {
-            var toselect = problem.Operators.OfType<IOperator>().FirstOrDefault(x => x.Name == typeValue.Value);            
-            if (toselect != null) {
-              return toselect;
-            }
-          }
-          
-          string parameterPropertyName = typeValue.Name.EndsWith("Parameter") ? typeValue.Name : typeValue.Name + "Parameter";
-          var parameterProperty = model.GetType().GetProperty(parameterPropertyName);
-          if (parameterProperty != null) {
-            var parameterPropertyValue = parameterProperty.GetGetMethod().Invoke(model, null);
-            var vvProp = parameterPropertyValue.GetType().GetProperty("ValidValues");
-            if (vvProp != null) {
-              //http://stackoverflow.com/questions/245607/how-is-generic-covariance-contra-variance-implemented-in-c-sharp-4-0 because of covariance declared in IEnumerable
-              var options = vvProp.GetGetMethod().Invoke(parameterPropertyValue, null) as IEnumerable<IItem>;
-              if (options != null) {
-                var result = options.FirstOrDefault(x => x.ItemName == typeValue.Value);
-                if (result != null)
-                  return result;
-              }
-            }
-          }
-
-          Type type = null;
-          foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
-            type = asm.GetType(typeValue.Value);
-            if (type != null)
-              break;
-          }
-          
-          return Activator.CreateInstance(type);
-      }
-      return null;
-    }
-
-    public object CreateHLObjectForType(object obj, Type type, Parameter prop) {
-      var value = MapControllerDataType(obj, prop);
-      if (prop.Type == ParameterType.Type)
-        return value;
-
-      if (type == typeof(HeuristicLab.Encodings.PermutationEncoding.Permutation)) {
-        double[] input = value as double[];
-        int[] arr = new int[input.Length];
-        for (int i = 0; i < input.Length; i++) {
-          arr[i] = Convert.ToInt32(input[i]);
-        }
-        var valueObj = new HeuristicLab.Encodings.PermutationEncoding.Permutation(Encodings.PermutationEncoding.PermutationTypes.RelativeUndirected, arr);
-        return valueObj;
-      }
-      var propertyGetter = obj.GetType().GetProperty(prop.Value.Name).GetGetMethod();        
-      return Activator.CreateInstance(propertyGetter.ReturnType, value);
-    }
-
-    private void MapProperty(object model, Parameter prop) {
-      var propertyGetter = model.GetType().GetProperty(prop.Value.Name).GetGetMethod();
-      var propertySetter = model.GetType().GetProperty(prop.Value.Name).GetSetMethod();
-      var value = propertyGetter.Invoke(model, null);
-      var valueProperty = value != null ? value.GetType().GetProperty("Value") : null;
-      if (propertySetter != null) {
-        var instance = CreateHLObjectForType(model, propertyGetter.ReturnType, prop);
-        propertySetter.Invoke(model, new object[] { instance });
-      }
-      else if (valueProperty != null) {        
-        valueProperty.GetSetMethod().Invoke(value, new object[] { MapControllerDataType(model, prop) });
-      }
-      else {
-        Console.WriteLine("Failed to handle property!");
-      }
-    }
-
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
-      Experiment experiment = new Experiment();
-      var problem = new TravelingSalesmanProblem();
-      foreach (var prop in scenario.InputParameters.Items) {
-        MapProperty(problem, prop);
-      }
-
-      var algo = new GeneticAlgorithm();
-      algo.Problem = problem;      
-      foreach (var prop in scenario.AlgorithmParameters.Items) {
-        MapProperty(algo, prop);
-      }
-
-      experiment.Optimizers.Add(algo);
-      SendExperimentToHive(user, experiment);
-    }
-
-    private void SendExperimentToHive(Model.User user, Experiment exp) {
-      var job = new RefreshableJob();
-      job.IsAllowedPrivileged = true;      
-      job.Job.Name = "Web Scheduled Traveling Salesman Job";
-      job.Job.ResourceNames = "TESTGROUP";
-      job.RefreshAutomatically = false;
-      job.HiveTasks.Add(new OptimizerHiveTask(exp));
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      
-      HiveClient.StartJob((ex) => { 
-        Console.WriteLine(ex.StackTrace); 
-      }, job, new CancellationToken());
-
-      job.StopResultPolling();
-    }
-
-
-    public IList<Model.Job> GetJobs(User user) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
-      IList<Model.Job> jobs = new List<Model.Job>();
-      
-      foreach (var job in jobsLoaded) {
-        jobs.Add(ConvertJob(user, job));
-      }
-      return jobs;
-    }
-
-    private Model.Job ConvertJob(User user, HeuristicLab.Clients.Hive.Job job) 
-    {
-      var waitingJobs = job.JobCount - job.CalculatingCount - job.FinishedCount;
-      Model.JobState? state = null;
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
-      
-      foreach (var task in jobTasks) {        
-        switch (task.State) {
-          case TaskState.Aborted:
-            state = JobState.Aborted;
-            break;
-          case TaskState.Failed:
-            state = JobState.Failed;
-            break;
-        }
-      }
-      if (!state.HasValue) {
-        if (job.CalculatingCount > 0)
-          state = JobState.Calculating;
-        else if (waitingJobs > 0)
-          state = JobState.Waiting;
-        else
-          state = JobState.Finished;
-      }
-      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value };
-    }
-
-
-    public Model.Job GetJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
-    }
-
-
-    public void DeleteJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
-    }
-
-    public IList<Model.Run> GetJobResults(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
-
-      IList<Guid> taskIds = new List<Guid>();
-      foreach (var task in jobTasks) {
-        taskIds.Add(task.Id);
-      }
-      TaskDownloader downloader = new TaskDownloader(taskIds);
-      downloader.StartAsync();
-      while (!downloader.IsFinished) {        
-        Thread.Sleep(500);
-
-        if (downloader.IsFaulted) {
-          throw downloader.Exception;
-        }
-      }
-      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
-      IList<Model.Run> runs = new List<Model.Run>();
-      foreach (var keyTask in hiveTasks.Keys) {
-        var oht = hiveTasks[keyTask] as OptimizerHiveTask;
-        if (oht != null) {
-          foreach (var run in oht.ItemTask.Item.Runs) {
-            Model.Run taskRun = new Model.Run();
-            taskRun.Id = taskRun.Name = run.Name;
-            IList<Parameter> resultValues = new List<Model.Parameter>();
-            foreach (var key in run.Results.Keys) {
-              var value = run.Results[key];              
-              Parameter result = MapHiveDataType(key, value);
-              resultValues.Add(result);
-            }
-            taskRun.Results = resultValues;
-            runs.Add(taskRun);
-          }
-        }
-      }
-      return runs;
-    }
-    private Parameter MapHiveDataType(string name, IItem item) {
-      Parameter result = new Parameter();
-      result.Type = ParameterType.String;
-      if (item is IStringConvertibleValue) {
-        var value = (item as IStringConvertibleValue).GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleValueTuple) {
-        var value1 = (item as IStringConvertibleValueTuple).Item1.GetValue();
-        var value2 = (item as IStringConvertibleValueTuple).Item2.GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "{" + value1 + ", " + value2 + "}" };
-      }
-      else if (item is IStringConvertibleArray) {
-        StringBuilder sb = new StringBuilder();
-        var array = item as IStringConvertibleArray;
-        if (array.Length == 0) {
-          sb.Append("[ ]");
-        } else {
-          sb.Append("[");
-          for (int i=0; i < array.Length - 1; i++) {
-            sb.Append(array.GetValue(i)).Append(", ");          
-          }
-          sb.Append(array.GetValue(array.Length - 1));
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleMatrix) {
-        StringBuilder sb = new StringBuilder();
-        var matrix = item as IStringConvertibleMatrix;
-        if (matrix.Rows == 0 || matrix.Columns == 0) {
-          sb.Append("[ ]");
-        }
-        else {
-          sb.Append("[ ");
-          for (int r = 0; r < matrix.Rows; r++) {
-            sb.Append("( ");
-            for (int c = 0; c < matrix.Columns - 1; c++) {
-              sb.Append(matrix.GetValue(r, c)).Append(", ");
-            }
-            sb.Append(matrix.GetValue(r, matrix.Columns - 1)).Append(r < matrix.Rows - 1 ? " ), " : " )");
-          }
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else {
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayed as string" };
-      }
-      return result;
-    }
-
-
-    public bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper) {
-      throw new NotImplementedException();
-    }
-
-    public bool DeleteScenario(User user, string scenarioName) {
-      throw new NotImplementedException();
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs	(revision 9166)
@@ -9,4 +9,5 @@
 using HeuristicLab.Services.Optimization.ControllerService.Azure;
 using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using System.Diagnostics;
 
 namespace HeuristicLab.Services.Optimization.ControllerService {
@@ -15,5 +16,5 @@
     private static object lockable = new object();
 
-    private IDataAccessLayer dal = new AzureDataAccessLayer();
+    private IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
 
     public IList<Model.OptimizationScenario> Scenarios {
@@ -32,5 +33,5 @@
     public Model.OptimizationScenario GetByName(string name) {
       foreach (var scen in Scenarios) {
-        if (scen.Name == name) {
+        if (scen.Id == name) {
           return scen;
         }
@@ -115,4 +116,72 @@
     } */
 
+    private Model.Problem ParseProblem(XmlReader reader) {
+      var problem = new Model.Problem();
+      while (reader.Read()) {
+        if (reader.NodeType == XmlNodeType.EndElement)
+          break;
+        if (reader.Name == "parameters")
+          problem.Parameters.Items = ParseParameters(reader);
+      }
+      return problem;
+    }
+
+    private void ParseAlgorithms(out IList<Model.Algorithm> algos, XmlReader reader) {
+      algos = new List<Model.Algorithm>();
+      var depth = reader.Depth;
+      do {
+        if (reader.Name == "algorithm" && reader.Depth == depth) {
+          var innerAlg = new Model.Algorithm();
+          algos.Add(innerAlg);
+          
+          innerAlg.Mapper = reader.GetAttribute("mapper");
+          reader.Read();
+          for (;;) {
+            if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.EndElement)
+              break;
+
+            if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.Element) {
+              innerAlg.Parameters.Items = ParseParameters(reader);
+              continue;
+            }
+            else if (reader.Name == "problem" && reader.NodeType == XmlNodeType.Element) {
+              innerAlg.Problem = ParseProblem(reader);
+              continue;
+            }
+            else if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.Element) {
+              IList<Model.Algorithm> childAlgos;
+              ParseAlgorithms(out childAlgos, reader);
+              innerAlg.ChildAlgorithms = childAlgos;
+              //TODO: Test with child algorithms
+              continue;
+            }
+            reader.Read();
+          }
+        }
+      } while (reader.Read() && reader.Depth >= depth);
+    }
+
+    private Model.OptimizationScenario ParseScenarioElement(XmlReader reader) {
+      var scenario = new Model.OptimizationScenario();
+      var depth = reader.Depth;
+      while (reader.Depth >= depth) {
+        if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.EndElement)
+          break;
+
+        if (reader.Name == "name") {
+          scenario.Id = reader.ReadElementContentAsString();
+          continue;
+        }
+        else if (reader.Name == "algorithm") {
+          IList<Model.Algorithm> algos;
+          ParseAlgorithms(out algos, reader);
+          scenario.Algorithm = algos;
+          continue;
+        }
+        reader.Read();
+      }
+      return scenario;
+    }
+
     private Model.OptimizationScenario ParseScenario(StringReader str) {
       // Set the validation settings.      
@@ -120,29 +189,12 @@
       var settings = GetSettings();
       settings.ValidationEventHandler += (sender, args) => {
-        Console.WriteLine(args.Message);
+        Trace.WriteLine(args.Message);
         isErrorPresent = true;
       };
-      Model.OptimizationScenario scenario = null;
+      Model.OptimizationScenario scenario = null;      
       using (var reader = XmlReader.Create(str, settings)) {        
-        while (!isErrorPresent && !reader.EOF) {
+        while (!reader.EOF) {
           if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.Element) {
-            scenario = new Model.OptimizationScenario();
-            scenario.ProblemType = reader.GetAttribute("mapper");
-            scenario.ProblemType = reader.GetAttribute("algorithmType");
-            scenario.ProblemType = reader.GetAttribute("problemType");
-          }
-          else if (reader.Name == "name") {
-            scenario.Name = reader.ReadElementContentAsString();
-            continue;
-          }
-          else if (reader.Name == "problemParameters") {
-            IList<Model.Parameter> problemParameters = ParseParameters(reader);
-            foreach (var param in problemParameters)
-              scenario.InputParameters.Items.Add(param);
-          }
-          else if (reader.Name == "algorithmParameters") {
-            IList<Model.Parameter> algoParameters = ParseParameters(reader);
-            foreach (var param in algoParameters)
-              scenario.AlgorithmParameters.Items.Add(param);
+            scenario = ParseScenarioElement(reader);            
           }
           reader.Read();
@@ -185,8 +237,8 @@
       IList<Model.Parameter> parameters = new List<Model.Parameter>();
       while (reader.Read()) {
-        if (reader.Name.EndsWith("Parameters"))
+        if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.EndElement)
           break;
         // parse parameter
-        if (reader.Depth == 2 && reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
+        if (reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
           var param = new Model.Parameter();
           var typeAtt = reader.GetAttribute("type");
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 9166)
@@ -36,4 +36,10 @@
       <HintPath>..\bin\ALGLIB-3.5.0.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.ALGLIB-3.5.0">
+      <HintPath>..\bin\HeuristicLab.ALGLIB-3.5.0.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Algorithms.Benchmarks-3.3">
+      <HintPath>..\bin\HeuristicLab.Algorithms.Benchmarks-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3">
       <HintPath>..\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
@@ -92,4 +98,7 @@
       <HintPath>..\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.Operators.Views.GraphVisualization-3.3">
+      <HintPath>..\bin\HeuristicLab.Operators.Views.GraphVisualization-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.Optimization-3.3">
       <HintPath>..\HeuristicLab.Optimization\3.3\obj\Debug\HeuristicLab.Optimization-3.3.dll</HintPath>
@@ -129,4 +138,7 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\bin\HeuristicLab.Selection-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.SequentialEngine-3.3">
+      <HintPath>..\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Tracing-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
@@ -153,5 +165,5 @@
   <ItemGroup>
     <Compile Include="Azure\DAL.cs" />
-    <Compile Include="HL\HiveScenarioManagerOld.cs" />
+    <Compile Include="General\Configuration.cs" />
     <Compile Include="HL\HiveMapper.cs" />
     <Compile Include="HL\HiveScenarioManager.cs" />
@@ -161,4 +173,6 @@
     <Compile Include="Interfaces\IScenarioManager.cs" />
     <Compile Include="Interfaces\Model\ControllerModel.cs" />
+    <Compile Include="Mockup\MockupDAL.cs" />
+    <Compile Include="Mockup\MockupScenarioManager.cs" />
     <Compile Include="PlaceholderControllerService.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -172,4 +186,5 @@
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 9166)
@@ -27,4 +27,13 @@
     IBlobDao CreateBlobDao();
   }
+
+  public static class DataAccessLayerProvider {    
+    private static IDataAccessLayer layer = new Azure.AzureDataAccessLayer();
+    //private static IDataAccessLayer layer = new Mockup.MockupDataAccessLayer();
+
+    public static IDataAccessLayer GetLayer() { 
+      return layer; 
+    }
+  }
 }
 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 9166)
@@ -20,5 +20,5 @@
 
     [OperationContract]
-    void ScheduleOptimizationScenario(User user, OptimizationScenario scenario);
+    void ScheduleOptimizationScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
 
     [OperationContract]
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 9166)
@@ -7,5 +7,5 @@
 namespace HeuristicLab.Services.Optimization.ControllerService.Interfaces {
   public interface IScenarioManager {
-    void DispatchScenario(User user, OptimizationScenario scenario);
+    void DispatchScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
     IList<Job> GetJobs(User user);
     Job GetJob(User user, string id);
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs	(revision 9166)
@@ -45,4 +45,40 @@
     public string[] RowNames { get; set; }
 
+    public void CopyRow(int index) {
+      var newData = new double[Value.Length + 1][];
+      var copyRow = new double[Value[index].Length];
+      for (var i = 0; i < copyRow.Length; i++) {
+        copyRow[i] = Value[index][i];
+      }
+      for (var i = 0; i < newData.Length; i++) {
+        if (i < index) {
+          newData[i] = Value[i];
+        }
+        else if (i == index) {
+          newData[i] = copyRow;
+        }
+        else if (i > index) {
+          newData[i] = Value[i - 1];
+        }
+      }
+      Value = newData;
+    }
+
+    public void DeleteRow(int index) {
+      if (Value.Length == 1)
+        return;
+
+      var newData = new double[Value.Length - 1][];
+      for (var i = 0; i < Value.Length; i++) {
+        if (i < index) {
+          newData[i] = Value[i];
+        }
+        else if (i > index) {
+          newData[i - 1] = Value[i];
+        }
+      }
+      Value = newData;
+    }
+
     public override bool TrySetFromString(string input) {
       var splitted = input.Split(':');
@@ -61,5 +97,5 @@
         return false;
       // very, very buggy
-      if (i >= Value.Length || j >= Value[0].Length ) {
+      /*if (i >= Value.Length || j >= Value[0].Length ) {
         double[][] valueArr = new double[i >= Value.GetLength(0) ? i : Value.GetLength(0)][];        
         for (int k = 0; k < Value.Length; k++) {
@@ -70,5 +106,5 @@
         }
         Value = valueArr;
-      }
+      }*/
 
       Value[i][j] = value;
@@ -186,5 +222,5 @@
 
   [DataContract]
-  public class InputParameters {
+  public class ProblemParameters {
     private IList<Parameter> items = new List<Parameter>();
 
@@ -226,76 +262,108 @@
 
   [DataContract]
+  public class Problem {
+    public Problem() { Parameters = new ProblemParameters(); }
+
+    [DataMember]
+    public ProblemParameters Parameters { get; set; }
+
+    [DataMember]
+    public string Class { get; set; }
+  }
+
+  [DataContract]
+  public class Algorithm {
+    public Algorithm() { Parameters = new AlgorithmParameters(); }
+
+    [DataMember]
+    public AlgorithmParameters Parameters { get; set; }
+
+    [DataMember]
+    public Problem Problem{ get; set; }
+
+    [DataMember]
+    public IList<Algorithm> ChildAlgorithms { get; set; }
+
+    [DataMember]
+    public string Class { get; set; }
+
+    [DataMember]
+    public string Mapper { get; set; }
+  }
+
+  [DataContract]
   public class OptimizationScenario {
     [DataMember]
+    public string Id { get; set; }
+   
+    [DataMember]
+    public IList<Algorithm> Algorithm { get; set; }
+
+    public Algorithm FirstAlgorithm { get { return Algorithm.FirstOrDefault(); } }  
+  }
+
+  [DataContract]
+  public class Experiment {
+    [DataMember]
+    public IList<OptimizationScenario> Scenarios { get; set; }
+
+    public Experiment() {
+      Scenarios = new List<OptimizationScenario>();
+    }
+  }
+
+  [DataContract]
+  public enum JobState {
+    [EnumMember]
+    Waiting,
+    [EnumMember]
+    Calculating,
+    [EnumMember]
+    Aborted,
+    [EnumMember]
+    Failed,
+    [EnumMember]
+    Finished
+  }
+
+  [DataContract]
+  public class JobExecutionDetails {
+    [DataMember]
+    public int Repititions { get; set; }
+
+    [DataMember]
+    public string JobTitle { get; set; }
+
+    [DataMember]
+    public string Group { get; set; }
+  }
+
+  [DataContract]
+  public class Job {
+    [DataMember]
+    public string Id { get; set; }
+
+    [DataMember]
+    public JobState State { get; set; }
+
+    [DataMember]
     public string Name { get; set; }
 
     [DataMember]
-    public string ProblemType { get; set; }
-
-    [DataMember]
-    public string AlgorithmType { get; set; }
-
-    [DataMember]
-    public string MapperType { get; set; }
-
-    private InputParameters inputParams = new InputParameters();
-
-    [DataMember]
-    public InputParameters InputParameters {
-      get { return inputParams; }
-      set { inputParams = value; }
-    }
-
-
-    private AlgorithmParameters algorithmParameters = new AlgorithmParameters();
-
-    [DataMember]
-    public AlgorithmParameters AlgorithmParameters {
-      get { return algorithmParameters; }
-      set { algorithmParameters = value; }
-    }
-  }
-
-  [DataContract]
-  public enum JobState {
-    [EnumMember]
-    Waiting,
-    [EnumMember]
-    Calculating,
-    [EnumMember]
-    Aborted,
-    [EnumMember]
-    Failed,
-    [EnumMember]
-    Finished
-  }
-
-  [DataContract]
-  public class Job {
+    public string Resource { get; set; }
+
+    [DataMember]
+    public DateTime DateCreated { get; set; }
+  }
+
+  [DataContract]
+  public class Run {
     [DataMember]
     public string Id { get; set; }
 
     [DataMember]
-    public JobState State { get; set; }
-
-    [DataMember]
     public string Name { get; set; }
 
     [DataMember]
-    public string Resource { get; set; }
-
-    [DataMember]
-    public DateTime DateCreated { get; set; }
-  }
-
-  [DataContract]
-  public class Run {
-    [DataMember]
-    public string Id { get; set; }
-
-    [DataMember]
-    public string Name { get; set; }
-
-    [DataMember]
     public IList<Parameter> Results { get; set; }
   }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs	(revision 9166)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs	(revision 9166)
@@ -0,0 +1,256 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using Microsoft.WindowsAzure;
+using Microsoft.WindowsAzure.StorageClient;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.Mockup {
+  public static class AzureConstants {
+    public static readonly string SCENARIO_TABLE = "Scenario";
+    public static readonly string SCENARIO_BLOB_CONTAINER = "scenario";
+    public static readonly string CLOUD_SETTINGS_KEY = "Cloudia.WindowsAzure.Storage";
+  }
+
+  public class ScenarioDao : IScenarioDao {
+    private static List<ScenarioEntity> scenarios;
+
+    static ScenarioDao() {
+      // TODO: Add tsp scenario to list
+      scenarios = new List<ScenarioEntity>() {
+        new ScenarioEntity("Benchmark Algorithm", "bmx", "bmm"),
+        new ScenarioEntity("Traveling Salesman Problem", "scenario1", "mapper1")
+      };      
+    }
+
+
+    public bool Add(ScenarioEntity entity) {
+      var dbEntity = scenarios.Find(e => e.Scenario == entity.Scenario);
+
+      if (dbEntity != null)
+        return false;
+
+      scenarios.Add(entity);
+      return true;
+    }
+
+    public bool DeleteByName(string scenarioName) {
+      return scenarios.RemoveAll(e => e.RowKey == scenarioName) == 1;
+    }
+
+    public ScenarioEntity FindByName(string scenarioName) {
+      return scenarios.Find(e => e.RowKey == scenarioName);      
+    }
+
+
+    public IEnumerable<ScenarioEntity> GetAllEntities() {
+      return new List<ScenarioEntity>(scenarios);
+    }
+  }
+
+  public class BlobDao : IBlobDao {
+    private static List<StringEntry> entries;
+
+    static BlobDao() {
+      entries = new List<StringEntry>() {
+        new StringEntry() {
+          Key="bmm",
+          Text=@"
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Optimization;
+using HeuristicLab.Services.Optimization.ControllerService;
+using HeuristicLab.Algorithms.Benchmarks;
+using HeuristicLab.Parameters;
+using HeuristicLab.PluginInfrastructure;
+
+
+namespace HeuristicLab.Mappers {
+  public class BenchmarkScenarioMapper : IScenarioMapper {
+    public void MapScenario(OptimizationScenario scenario, out IAlgorithm algorithm) {
+      var alg = scenario.FirstAlgorithm;
+      var bm = new BenchmarkAlgorithm();
+      var bmFullName = HLMapper.GetStringValue(alg.Parameters.FindByName(""Benchmark""));
+      bm.BenchmarkParameter.Value = bm.Benchmark = bm.BenchmarkParameter.ValidValues.First(b => b.GetType().FullName == bmFullName);      
+      ((ValueParameter<IntValue>)bm.Parameters[""ChunkSize""]).Value = HLMapper.ConvertToIntValue(alg.Parameters.FindByName(""ChunkSize""));
+      ((ValueParameter<DoubleValue>)bm.Parameters[""TimeLimit""]).Value = HLMapper.ConvertToDoubleValue(alg.Parameters.FindByName(""TimeLimit""));
+
+      algorithm = bm;
+    }
+  }
+}
+"
+        },
+        new StringEntry() {
+           Key="bmx",
+           Text=@"<?xml version='1.0'?>
+<scenario xmlns=""urn:scenario-schema"">
+  <name>Benchmark Algorithm</name>
+  <algorithm mapper=""HeuristicLab.Mappers.BenchmarkScenarioMapper"">
+    <parameters>
+		<param type=""Type"" name=""Benchmark"">
+		  <choice name=""HeuristicLab.Algorithms.Benchmarks.Dhrystone"" selected=""true"" />
+		  <choice name=""HeuristicLab.Algorithms.Benchmarks.Linpack"" />
+		  <choice name=""HeuristicLab.Algorithms.Benchmarks.Whetstone""/>
+		</param>    
+		<param type=""Decimal"" name=""ChunkSize"" value=""0""/>
+		<param type=""Decimal"" name=""TimeLimit"" value=""0""/> 
+	</parameters>
+  </algorithm>  
+</scenario>"
+        },
+        new StringEntry() { 
+          Key = "scenario1",
+          Text = @"<?xml version='1.0'?>
+<scenario xmlns=""urn:scenario-schema"">
+  <name>Traveling Salesman Problem</name>
+  <algorithm mapper=""HeuristicLab.Mappers.TSPScenarioMapper"">
+    <parameters>
+		<param type=""Type"" name=""CrossoverParameter"">
+		  <choice name=""OrderCrossover2""/>
+		  <choice name=""CosaCrossover"" selected=""true""/>
+		</param>    
+		<param type=""Integer"" name=""Elites"" value=""1""/>
+		<param type=""Integer"" name=""MaximumGenerations"" value=""1000""/>
+		<param type=""Percent"" name=""MutationProbability"" value=""5""/>
+		<param type=""Type"" name=""Mutator"">
+		  <choice name=""InversionManipulator"" selected=""true""/>
+		  <choice name=""ScrambleManipulator""/>
+		</param>
+		<param type=""Integer"" name=""PopulationSize"" value=""100""/>
+		<param type=""Integer"" name=""Seed"" value=""100""/>
+		<param type=""Type"" name=""Selector"">
+		  <choice name=""ProportionalSelector"" selected=""true""/>
+		  <choice name=""BestSelector""/>
+		</param>
+		<param type=""Boolean"" name=""SetSeedRandomly"" value=""true""/>
+    </parameters>
+	<problem>
+		<parameters>
+			<param type=""Decimal"" name=""BestKnownQuality"" value=""6110.0""/>
+			<param type=""DecimalVector"" name=""BestKnownSolution"">
+			  <value v1=""0""/>
+			  <value v1=""40""/>
+			  <value v1=""38""/>
+			  <value v1=""60""/>
+			</param>
+			<param type=""DecimalMatrix"" name=""Coordinates"">
+			  <value v1=""334.5909"" v2=""161.7809""/>
+			  <value v1=""503.5909"" v2=""172.7809""/>
+			  <value v1=""400.5909"" v2=""300.7809""/>
+			  <value v1=""700.5909"" v2=""700.7809""/>
+			</param>
+			<param type=""Type"" name=""EvaluatorParameter"">
+			  <choice name=""HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator"" />
+			  <choice name=""HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator"" selected=""true""/>
+			  <choice name=""HeuristicLab.Problems.TravelingSalesman.TSPEuclideanPathEvaluator""/>
+			</param>    
+			<param type=""Boolean"" name=""UseDistanceMatrix"" value=""true""/> 
+		</parameters>
+	</problem>
+  </algorithm>
+</scenario>"
+        },
+        new StringEntry() { 
+          Key = "mapper1",
+          Text = @"using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Optimization;
+using HeuristicLab.Services.Optimization.ControllerService;
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Problems.TravelingSalesman;
+namespace HeuristicLab.Mappers {
+  public class TSPScenarioMapper : IScenarioMapper {
+    public void MapScenario(OptimizationScenario scenario, out IAlgorithm algorithm) {
+      Console.WriteLine(""Mapping scenario!"");
+      var ga = new GeneticAlgorithm();
+      var problem = new TravelingSalesmanProblem();
+      ga.Problem = problem;
+      algorithm = ga;
+
+      problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName(""BestKnownQuality""));
+      problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.FirstAlgorithm.Problem.Parameters.FindByName(""BestKnownSolution""));
+      problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.FirstAlgorithm.Problem.Parameters.FindByName(""Coordinates""));
+      var evalParam = HLMapper.GetStringValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName(""EvaluatorParameter""));
+      if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator"") {
+        problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
+      }
+      else if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator"") {
+        problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
+      }
+      else {
+        problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
+      }
+      problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName(""UseDistanceMatrix""));
+      Console.WriteLine(""Mapping algorithm..."");
+      ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.FirstAlgorithm.Parameters.FindByName(""Mutator""));
+      ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.FirstAlgorithm.Parameters.FindByName(""CrossoverParameter""));
+      ga.Elites = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName(""Elites""));
+      ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName(""MaximumGenerations""));
+      ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.FirstAlgorithm.Parameters.FindByName(""MutationProbability""));
+      ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName(""PopulationSize""));
+      ga.Seed = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName(""Seed""));
+      ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.FirstAlgorithm.Parameters.FindByName(""Selector""));
+      ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.FirstAlgorithm.Parameters.FindByName(""SetSeedRandomly""));
+    }
+  }
+}"
+        }
+      };
+    }
+
+    public bool Add(StringEntry entry) {
+      entries.RemoveAll(e => e.Key == entry.Key);
+      entries.Add(entry);      
+      return true;
+    }
+
+    public bool DeleteByKey(string entryKey) {
+      return entries.RemoveAll(e => e.Key == entryKey) == 1;      
+    }
+
+    public StringEntry FindByKey(string entryKey) {
+      return entries.Find(e => e.Key == entryKey);      
+    }
+  }
+
+  public class MockupDataAccessLayer : IDataAccessLayer {
+    private IScenarioDao scenarioDao;
+    private IBlobDao blobDao;
+
+    public IScenarioDao ScenarioDao {
+      get {
+        if (scenarioDao == null) {
+          scenarioDao = new ScenarioDao();
+        }
+        return scenarioDao;
+      }
+    }
+
+    public IBlobDao BlobDao {
+      get {
+        if (blobDao == null) {
+          blobDao = new BlobDao();
+        }
+        return blobDao;
+      }
+    }
+
+    public IScenarioDao CreateScenarioDao() {
+      return new ScenarioDao();
+    }
+
+    public IBlobDao CreateBlobDao() {
+      return new BlobDao();
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs	(revision 9166)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs	(revision 9166)
@@ -0,0 +1,240 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using HeuristicLab.Optimization;
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Problems.TravelingSalesman;
+using HeuristicLab;
+using System.Reflection;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Core;
+using System.Collections;
+using HeuristicLab.Clients.Hive;
+using System.Threading;
+using HeuristicLab.Data;
+using System.IO;
+using Microsoft.WindowsAzure;
+using Microsoft.WindowsAzure.StorageClient;
+using HeuristicLab.Services.Optimization.ControllerService.Azure;
+using System.Data;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public class MockupScenarioManager : IScenarioManager {
+    private static List<Model.Job> jobs;
+    private static Dictionary<string, List<Model.Run>> jobResults;
+    private static IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
+    private Dictionary<string, IScenarioMapper> mappers = new Dictionary<string, IScenarioMapper>();
+    private static object lockable = new object();
+
+    static MockupScenarioManager() {
+      jobs = new List<Model.Job>() {
+        new Model.Job() { DateCreated = DateTime.Now, Id = "1", Name="Webscheduled TSP", Resource="TESTGROUP", State=JobState.Finished },
+        new Model.Job() { DateCreated = DateTime.Now, Id = "2", Name="Webscheduled TSP 2", Resource="TESTGROUP", State=JobState.Calculating }
+      };
+      jobResults = new Dictionary<string, List<Model.Run>>();
+      jobResults["1"] = new List<Model.Run>() {
+        new Model.Run() {
+          Id = "Webscheduled TSP Run 1",
+          Name = "Webscheduled TSP Run 1",
+          Results = new List<Parameter>() {
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "AbsoluteDifferenceBestKnownToBest",
+                Value = 0
+              },
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "BestKnownQuality",
+                Value = 1600
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "BestQuality",
+                Value = 1600
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "CurrentAverageQuality",
+                Value = 1600
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "CurrentBestQuality",
+                Value = 1600
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "CurrentWorstQuality",
+                Value = 1600
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "Evaluated Solutions",
+                Value = 99100
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "Generations",
+                Value = 1000
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalValue(){
+                Name = "RelativeDifferenceBestKnownToBest",
+                Value = 0
+              },              
+              Type = ParameterType.Decimal
+            },
+            new Parameter() { 
+              Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalMatrix {
+                Name = "Qualities",
+                RowNames = new string[] { "CurrentBestQuality", "CurrentAverageQuality", "CurrentWorstQuality", "BestQuality", "BestKnownQuality" },
+                Value = new double[][] {
+                  // Best Quality
+                  new double[]{4000, 3900, 3950, 2500, 3000, 2700, 2300, 2200, 1700, 1850, 1600},
+                  // Average
+                  new double[]{6000, 5000, 5650, 3750, 4500, 4050, 3450, 3300, 2550, 2775, 2400},
+                  // Worst Quality
+                  new double[]{8000, 7200, 7350, 5000, 6000, 5400, 4600, 4400, 3400, 3700, 3200},
+                  // Best Quality
+                  new double[]{4000, 3900, 3950, 2500, 3000, 2700, 2300, 2200, 1700, 1850, 1600},
+                  // Best Known Quality
+                  new double[]{4000, 3900, 3950, 2500, 3000, 2700, 2300, 2200, 1700, 1850, 1600},
+                }
+              },              
+              Type = ParameterType.Decimal
+            }
+          }
+        }
+      };
+    }
+
+    public MockupScenarioManager() {
+      
+    }
+
+    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+      // does nothign
+    }
+
+    public IList<Model.Job> GetJobs(User user) {
+      return jobs;
+    }
+
+    public Model.Job GetJob(User user, string id) {
+      return (from j in jobs where j.Id == id select j).FirstOrDefault();
+    }
+
+
+    public void DeleteJob(User user, string id) {
+      jobs.RemoveAll(j => j.Id == id);
+    }
+
+    public IList<Model.Run> GetJobResults(User user, string id) {      
+      return jobResults[id];
+    }
+
+    private static string AssemblyDirectory {
+      get {
+        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
+        UriBuilder uri = new UriBuilder(codeBase);
+        string path = Uri.UnescapeDataString(uri.Path);
+        return Path.GetDirectoryName(path);
+      }
+     }
+
+    private IScenarioMapper CompileMapper(string scenarioMapper) {
+       // http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe
+      using (var csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()) {
+        var cp = new System.CodeDom.Compiler.CompilerParameters() {
+          GenerateInMemory = true
+        };
+
+        var referencedPaths = Directory.GetFiles(AssemblyDirectory, "*.dll");
+        foreach (var loadedAssembly in referencedPaths) {
+          cp.ReferencedAssemblies.Add(loadedAssembly);
+        }
+        cp.ReferencedAssemblies.Add("System.dll");
+        cp.ReferencedAssemblies.Add("System.Core.dll");
+        cp.ReferencedAssemblies.Add("System.Data.dll");
+        cp.ReferencedAssemblies.Add("System.Xml.dll");
+        cp.ReferencedAssemblies.Add("System.Xml.Linq.dll");
+
+        var res = csCodeProvider.CompileAssemblyFromSource(
+          cp,
+          scenarioMapper
+        );
+
+        foreach (var error in res.Errors) {
+          Console.WriteLine(error);
+        }
+        
+        var firstMapper = res.CompiledAssembly.GetTypes().Where(p => typeof(IScenarioMapper).IsAssignableFrom(p)).FirstOrDefault();        
+        return Activator.CreateInstance(firstMapper) as IScenarioMapper;
+      }
+    }
+
+    public bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper) {     
+      // create scenario mapper
+      var mapper = CompileMapper(scenarioMapper);
+      if (mapper == null)
+        return false;
+      
+      // insert into table & blob store
+      var scenDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+      
+      Guid scenarioXmlGuid = Guid.NewGuid();
+      Guid scenarioMapperGuid = Guid.NewGuid();
+      string scenarioXmlId = scenarioName + "_" + scenarioXmlGuid.ToString();
+      string scenarioMapperId = scenarioName + "_" + scenarioMapperGuid.ToString();
+      if (!blobDao.Add(new StringEntry() { Key = scenarioXmlId, Text = scenarioXml }))
+        return false;
+      if (!blobDao.Add(new StringEntry() { Key = scenarioMapperId, Text = scenarioMapper }))
+        return false;
+      if (!scenDao.Add(new ScenarioEntity(scenarioName, scenarioXmlId, scenarioMapperId)))
+        return false;
+
+      // everything stored in the DB -> add mapper to dictionary
+      if (!mappers.ContainsKey(scenarioName)) {
+        lock (lockable) {
+          if (!mappers.ContainsKey(scenarioName))
+            mappers[scenarioName] = mapper;
+        }
+      }
+      return true;
+    }
+
+    public bool DeleteScenario(User user, string scenarioName) {
+      // delete from table & blob store
+      var scenarioDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+
+      var entity = scenarioDao.FindByName(scenarioName);
+      if (entity == null)
+        return false;
+
+      blobDao.DeleteByKey(entity.Mapper);
+      blobDao.DeleteByKey(entity.Scenario);
+      scenarioDao.DeleteByName(scenarioName);            
+      return true;
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 9062)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 9166)
@@ -51,4 +51,5 @@
       this.scenarios = new List<Model.OptimizationScenario>() { tsp };*/      
       //hiveManager.DispatchScenario(tsp);
+      //hiveManager = new MockupScenarioManager();
       hiveManager = new HiveScenarioManager();
       scenarios = parser.Scenarios;
@@ -63,11 +64,11 @@
     public Model.OptimizationScenario GetOptimizationScenarioByName(string name) {
       var scen = (from e in scenarios
-                  where e.Name == name
+                  where e.Id == name
                   select e).FirstOrDefault();      
       return scen;
     }
 
-    public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario) {
-      hiveManager.DispatchScenario(user, scenario);
+    public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+      hiveManager.DispatchScenario(user, scenario, details);
     }
 
@@ -97,5 +98,5 @@
         return false;
       }      
-      var added = hiveManager.AddScenario(user, scenario.Name, scenarioXml, scenarioMapper);
+      var added = hiveManager.AddScenario(user, scenario.Id, scenarioXml, scenarioMapper);
       if (added) 
         scenarios.Add(scenario);
@@ -114,5 +115,5 @@
     public IEnumerable<string> GetOptimizationScenarioNames() {
       return (from e in scenarios
-              select e.Name).AsEnumerable();      
+              select e.Id).AsEnumerable();      
     }
   }
