Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/Jobs/ExperimentJob.cs @ 4368

Last change on this file since 4368 was 4368, checked in by cneumuel, 14 years ago
  • created HiveClient which shows an overview over all submitted HiveExperiments
  • its possible to download all submitted HiveExperiments including results
  • Experiments are now sent as a whole to the Hive and the Hive-Slaves take care of creating child-jobs (if necessary). The parent job is then paused and will be reactivated when all child-jobs are finished
  • WcfService-Clients are now consistently managed by WcfServicePool which allows to use IDisposable-Pattern and always keeps exactly one proxy-object until all callers disposed them.
  • created ProgressView which is able to lock a View and display progress of an action. It also allows to simulate progress if no progress-information is available so that users don't get too nervous while waiting.
File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Hive.JobBase;
6using HeuristicLab.Optimization;
7using HeuristicLab.Core;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HeuristicLab.Hive.Contracts.BusinessObjects;
10using HeuristicLab.Hive.Contracts.Interfaces;
11using HeuristicLab.Hive.Experiment.Properties;
12
13namespace HeuristicLab.Hive.Experiment.Jobs {
14  [StorableClass]
15  public class ExperimentJob : OptimizerJob {
16    [Storable]
17    private ExecutionState executionState = ExecutionState.Stopped;
18
19    public ExperimentJob() {
20      this.ComputeInParallel = true;
21    }
22
23    public ExperimentJob(IOptimizer optimizer) : base(optimizer) {
24      this.ComputeInParallel = true;
25    }
26
27    public override ExecutionState ExecutionState {
28      get {
29        return ComputeInParallel ? executionState : base.ExecutionState;
30      }
31    }
32
33    public override void Start() {
34      if (ComputeInParallel) {
35        executionState = Core.ExecutionState.Started;
36        foreach (IJob child in this.ChildJobs) {
37          OnNewChildJob(child);
38        }
39        executionState = Core.ExecutionState.Paused;
40        OnWaitForChildJobs();
41      } else {
42        base.Start();
43      }
44    }
45
46    public override void Resume(IEnumerable<IJob> childJobs) {
47      executionState = Core.ExecutionState.Started;
48      this.childJobs = new List<IJob>(childJobs);
49      UpdateRuns();
50      executionState = Core.ExecutionState.Stopped;
51      OnJobStopped();
52    }
53
54    private void UpdateRuns() {
55      foreach (OptimizerJob optimizerJob in childJobs.Cast<OptimizerJob>()) {
56        this.optimizer.Runs.AddRange(optimizerJob.Optimizer.Runs);
57      }
58    }
59
60    public void AddChildJob(IJob job) {
61      this.childJobs.Add(job);
62    }
63
64    public override bool IsParallelizable {
65      get { return true; }
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.