Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/08/11 00:04:16 (13 years ago)
Author:
cneumuel
Message:

#1233

  • locking for childHiveJobs in OptimizerHiveJob avoid multi threaded access issues
  • added IsPrivileged to gui
  • minor changes
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs

    r6373 r6381  
    7474    }
    7575
     76    [Storable]
     77    private bool isPrivileged;
     78    public bool IsPrivileged {
     79      get { return isPrivileged; }
     80      set { isPrivileged = value; }
     81    }
     82
    7683    // [Storable] -> HiveExperiment can't be storable, so RefreshableHiveExperiment can't be stored
    7784    private ItemCollection<RefreshableHiveExperiment> hiveExperiments = new ItemCollection<RefreshableHiveExperiment>();
     
    108115      this.executionTimeOnHive = original.executionTimeOnHive;
    109116      this.useLocalPlugins = original.useLocalPlugins;
     117      this.IsPrivileged = original.IsPrivileged;
    110118      // this.hiveExperiments = cloner.Clone(original.hiveExperiments); do not clone hiveExperiments - otherwise they would be sent with every job
    111119    }
     
    187195          //  }
    188196          //} else if (coll.Parallel) {
    189           if(coll.Parallel) {
     197          if (coll.Parallel) {
    190198            // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector
    191199            IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone();
     
    272280      IScope[] scopes = new Scope[jobs.Length];
    273281      object locker = new object();
    274       IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>();
    275282      var hiveExperiment = refreshableHiveExperiment.HiveExperiment;
    276283
    277284      try {
    278         List<Guid> remainingJobIds = new List<Guid>();
    279 
    280285        // create upload-tasks
    281         var uploadTasks = new List<Task<Job>>();
    282286        for (int i = 0; i < jobs.Length; i++) {
    283           hiveExperiment.HiveJobs.Add(new EngineHiveJob(jobs[i], parentScopeClone));
     287          var engineHiveJob = new EngineHiveJob(jobs[i], parentScopeClone);
     288          engineHiveJob.Job.Priority = this.Priority;
     289          hiveExperiment.HiveJobs.Add(engineHiveJob);
    284290
    285291          // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable)
     
    288294            random.Reset(random.Next());
    289295        }
    290         HiveClient.StartExperiment((e) => {
    291           LogException(e);
    292         }, refreshableHiveExperiment);
     296        HiveClient.StartExperiment((e) => { LogException(e); }, refreshableHiveExperiment);
    293297
    294298        // do polling until experiment is finished and all jobs are downloaded
    295299        while (!refreshableHiveExperiment.AllJobsFinished()) {
    296           Thread.Sleep(500);
     300          Thread.Sleep(2000);
    297301          this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(hiveExperiments.Sum(x => x.HiveExperiment.ExecutionTime.TotalMilliseconds));
    298302          cancellationToken.ThrowIfCancellationRequested();
    299303        }
    300304        LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableHiveExperiment.ToString(), refreshableHiveExperiment.HiveExperiment.ExecutionTime));
     305
     306        var failedJobs = hiveExperiment.HiveJobs.Where(x => x.Job.State == JobState.Failed);
     307        if(failedJobs.Count() > 0) {
     308          throw new HiveEngineException("Job failed: " + failedJobs.First().Job.StateLog.Last().Exception);
     309        }
    301310
    302311        // get scopes
    303312        int j = 0;
    304313        foreach (var hiveJob in hiveExperiment.HiveJobs) {
    305           if (hiveJob.Job.State != JobState.Finished)
    306             throw new HiveEngineException("Job failed: " + hiveJob.Job.StateLog.Last().Exception);
    307 
    308314          var scope = ((IAtomicOperation)((EngineJob)hiveJob.ItemJob).InitialOperation).Scope;
    309315          scopes[j++] = scope;
     
    313319      catch (OperationCanceledException e) {
    314320        lock (locker) {
    315           if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id);
     321          DeleteHiveExperiment(hiveExperiment.Id);
    316322        }
    317323        throw e;
     
    319325      catch (Exception e) {
    320326        lock (locker) {
    321           if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id);
     327          DeleteHiveExperiment(hiveExperiment.Id);
    322328        }
    323329        LogException(e);
     
    333339        hiveExperiment.UseLocalPlugins = this.UseLocalPlugins;
    334340        hiveExperiment.ResourceNames = this.ResourceNames;
     341        hiveExperiment.IsPrivileged = this.IsPrivileged;
    335342        var refreshableHiveExperiment = new RefreshableHiveExperiment(hiveExperiment);
    336343        refreshableHiveExperiment.IsControllable = false;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Tests

    • Property svn:ignore
      •  

        old new  
        55HeuristicLab.HiveEngine-3.4.Tests.csproj.vs10x
        66Meta-GA - Meta Optimization Problem (Genetic Programming - Symbolic Regression 3.4 scaled)_small.hl
         7HeuristicLab.HiveEngine-3.4.ConsoleTests.csproj.user
         8HeuristicLab.HiveEngine-3.4.ConsoleTests.csproj.vs10x
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Tests/Program.cs

    r6373 r6381  
    4747      GeneticAlgorithm alg = new GeneticAlgorithm();
    4848      alg.Problem = new SingleObjectiveTestFunctionProblem();
    49       alg.Engine = new HiveEngine() { ResourceNames = "CHRISTOPH-PC" };
     49      alg.Engine = new HiveEngine() { ResourceNames = "HEAL" };
    5050      alg.Elites.Value = 0;
    5151      alg.PopulationSize.Value = 10;
Note: See TracChangeset for help on using the changeset viewer.