Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/13 15:50:53 (11 years ago)
Author:
fschoepp
Message:

#1888:

  • Model: OptimizationScenario may be a tree of algorithms (and problems)
  • Model: Renamed InputParameters to ProblemParameters (as they are the parameters of a problem)
  • Model: Added JobExecutionDetails which contain Repetitions + Group (resource to use)
  • ScenarioParser parses the new XML scenario files
  • Website + Model: You are now able to add/remove rows from a table (no JavaScript involved yet)
  • Website + Controller: Added repetitions (enables batch jobs) and group (resource to use) to OaaS which will be used by the controller to schedule the job
  • Website: Updated templates to use new model structure
  • Website + Scenarios: Added the new algorithm Benchmark Algorithm
  • Controller: Added a singleton to make the (Azure/Mockup)-DAL exchangeable
  • Controller: Added mockup classes for DAL + IScenarioManager
  • Website/Result Page: Line Diagrams will be added via JavaScript, crawling their data using AJAX
  • Website: Most configuration parameters can be set in the ServiceDefinition directly
  • Added a mockup for the Membership classes: These can be used if no network connection is available or if other parts of the app shall be tested
  • Scenarios: Updated TSP mappings to new xsd
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs

    r9062 r9166  
    2020using HeuristicLab.Services.Optimization.ControllerService.Azure;
    2121using System.Data;
     22using HeuristicLab.Services.Optimization.ControllerService.General;
    2223
    2324namespace HeuristicLab.Services.Optimization.ControllerService {
     
    4344    private static object lockable;
    4445    private Dictionary<string, IScenarioMapper> mappers = new Dictionary<string, IScenarioMapper>();
    45     private IDataAccessLayer dal = new AzureDataAccessLayer();
     46    private IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
    4647
    4748    public static readonly string SCENARIO_TABLE = "Scenario";
     
    5152    }
    5253
    53     public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
    54       Experiment experiment = new Experiment();
    55       var problem = new TravelingSalesmanProblem();
    56       var algo = new GeneticAlgorithm();
    57       algo.Problem = problem;     
     54    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
     55      // Experiment experiment = new Experiment();
     56      // var problem = new TravelingSalesmanProblem();
     57      // var algo = new GeneticAlgorithm();
     58      // algo.Problem = problem;     
    5859     
    5960      IScenarioMapper mapper = GetMapper(scenario);
    60       mapper.MapScenario(scenario, algo); 
    61 
    62       //experiment.Optimizers.Add(algo);
    63       SendExperimentToHive(user, algo);
     61      IAlgorithm algo;
     62      mapper.MapScenario(scenario, out algo);
     63      if (details.Repititions > 1) {
     64        BatchRun br = new BatchRun();
     65        //br.Name = details.JobTitle;
     66        br.Optimizer = algo;       
     67        br.Repetitions = details.Repititions;
     68        SendExperimentToHive(user, br, details);
     69      }
     70      else {       
     71        SendExperimentToHive(user, algo, details);
     72      }
    6473    }
    6574
     
    7382    }
    7483
    75     private IScenarioMapper CompileMapper(string scenarioMapper) {
     84    public static IScenarioMapper CompileMapper(string scenarioMapper) {
    7685       // http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe
    7786      using (var csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()) {
     
    105114
    106115    private IScenarioMapper GetMapper(Model.OptimizationScenario scenario) {
    107       if (!mappers.ContainsKey(scenario.Name)) {
     116      var id = scenario.Id;
     117      if (!mappers.ContainsKey(id)) {
    108118        lock (lockable) {
    109           if (mappers.ContainsKey(scenario.Name))
    110             return mappers[scenario.Name];
     119          if (mappers.ContainsKey(id))
     120            return mappers[id];
    111121         
    112           var mapperString = GetMapperFromBlobStore(scenario.Name);
     122          var mapperString = GetMapperFromBlobStore(id);
    113123          var mapper = CompileMapper(mapperString);
    114124
    115           mappers[scenario.Name] = mapper;
     125          mappers[id] = mapper;
    116126          return mapper;
    117127        } // lock       
     
    120130     } 
    121131
    122     private void MapExperiment(Model.OptimizationScenario scenario, IAlgorithm algorithm) {     
     132    private void MapExperiment(Model.OptimizationScenario scenario, out IAlgorithm algorithm) {     
    123133      IScenarioMapper mapper = GetMapper(scenario);
    124       mapper.MapScenario(scenario, algorithm);     
    125     }
    126 
    127     private void SendExperimentToHive(Model.User user, IAlgorithm exp) {
     134      mapper.MapScenario(scenario, out algorithm);     
     135    }
     136
     137    private void ConfigureHive(Model.User user) {
     138      HiveServiceLocator.Instance.Username = user.Username;
     139      HiveServiceLocator.Instance.Password = user.Password;
     140      HiveServiceLocator.Instance.EndpointConfigurationName = Configuration.HiveEndpointName;     
     141    }
     142
     143    private void SendExperimentToHive(Model.User user, IOptimizer exp, JobExecutionDetails details) {     
    128144      var job = new RefreshableJob();
    129145      job.IsAllowedPrivileged = true;     
    130       job.Job.Name = "Web Scheduled Traveling Salesman Job";
    131       job.Job.ResourceNames = "TESTGROUP";
    132       job.RefreshAutomatically = false;
     146      job.Job.Name = details.JobTitle;
     147      job.Job.ResourceNames = details.Group;     
     148      job.RefreshAutomatically = false;     
     149      if (exp.ExecutionState != ExecutionState.Prepared) {
     150        exp.Prepare();
     151      }     
    133152      job.HiveTasks.Add(new OptimizerHiveTask(exp));
    134       HiveServiceLocator.Instance.Username = user.Username;
    135       HiveServiceLocator.Instance.Password = user.Password;
    136       HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
     153      ConfigureHive(user);
    137154     
    138155      HiveClient.StartJob((ex) => {
     
    145162
    146163    public IList<Model.Job> GetJobs(User user) {
    147       HiveServiceLocator.Instance.Username = user.Username;
    148       HiveServiceLocator.Instance.Password = user.Password;
    149       HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
     164      ConfigureHive(user);
    150165      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
    151166      IList<Model.Job> jobs = new List<Model.Job>();
    152      
     167
    153168      foreach (var job in jobsLoaded) {
    154169        jobs.Add(ConvertJob(user, job));
     
    163178      if (job.CalculatingCount > 0)
    164179        state = JobState.Calculating;
    165       else if (job.JobCount == job.FinishedCount)
     180      else if (job.JobCount > 0 && job.JobCount == job.FinishedCount)
    166181        state = JobState.Finished;
    167182      else
    168183        state = JobState.Waiting;
    169       /*var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
    170      
    171       foreach (var task in jobTasks) {       
    172         switch (task.State) {
    173           case TaskState.Aborted:
    174             state = JobState.Aborted;
    175             break;
    176           case TaskState.Failed:
    177             state = JobState.Failed;
    178             break;
    179         }
    180       }
    181       if (!state.HasValue) {
    182         if (job.CalculatingCount > 0)
    183           state = JobState.Calculating;
    184         else if (waitingJobs > 0)
    185           state = JobState.Waiting;
    186         else
    187           state = JobState.Finished;       
    188       }*/
    189184      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value, DateCreated = job.DateCreated };
    190185    }
     
    192187
    193188    public Model.Job GetJob(User user, string id) {
    194       HiveServiceLocator.Instance.Username = user.Username;
    195       HiveServiceLocator.Instance.Password = user.Password;
    196       HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
     189      ConfigureHive(user);
    197190      var guid = Guid.Parse(id);
    198191      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
     
    201194
    202195    public void DeleteJob(User user, string id) {
    203       HiveServiceLocator.Instance.Username = user.Username;
    204       HiveServiceLocator.Instance.Password = user.Password;
    205       HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
     196      ConfigureHive(user);
    206197      var guid = Guid.Parse(id);
    207198      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));     
     
    209200
    210201    public IList<Model.Run> GetJobResults(User user, string id) {
    211       HiveServiceLocator.Instance.Username = user.Username;
    212       HiveServiceLocator.Instance.Password = user.Password;
    213       HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
     202      ConfigureHive(user);
    214203      var guid = Guid.Parse(id);
    215204      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
Note: See TracChangeset for help on using the changeset viewer.