- Timestamp:
- 06/08/11 00:04:16 (13 years ago)
- 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 74 74 } 75 75 76 [Storable] 77 private bool isPrivileged; 78 public bool IsPrivileged { 79 get { return isPrivileged; } 80 set { isPrivileged = value; } 81 } 82 76 83 // [Storable] -> HiveExperiment can't be storable, so RefreshableHiveExperiment can't be stored 77 84 private ItemCollection<RefreshableHiveExperiment> hiveExperiments = new ItemCollection<RefreshableHiveExperiment>(); … … 108 115 this.executionTimeOnHive = original.executionTimeOnHive; 109 116 this.useLocalPlugins = original.useLocalPlugins; 117 this.IsPrivileged = original.IsPrivileged; 110 118 // this.hiveExperiments = cloner.Clone(original.hiveExperiments); do not clone hiveExperiments - otherwise they would be sent with every job 111 119 } … … 187 195 // } 188 196 //} else if (coll.Parallel) { 189 if (coll.Parallel) {197 if (coll.Parallel) { 190 198 // 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 191 199 IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone(); … … 272 280 IScope[] scopes = new Scope[jobs.Length]; 273 281 object locker = new object(); 274 IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>();275 282 var hiveExperiment = refreshableHiveExperiment.HiveExperiment; 276 283 277 284 try { 278 List<Guid> remainingJobIds = new List<Guid>();279 280 285 // create upload-tasks 281 var uploadTasks = new List<Task<Job>>();282 286 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); 284 290 285 291 // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable) … … 288 294 random.Reset(random.Next()); 289 295 } 290 HiveClient.StartExperiment((e) => { 291 LogException(e); 292 }, refreshableHiveExperiment); 296 HiveClient.StartExperiment((e) => { LogException(e); }, refreshableHiveExperiment); 293 297 294 298 // do polling until experiment is finished and all jobs are downloaded 295 299 while (!refreshableHiveExperiment.AllJobsFinished()) { 296 Thread.Sleep( 500);300 Thread.Sleep(2000); 297 301 this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(hiveExperiments.Sum(x => x.HiveExperiment.ExecutionTime.TotalMilliseconds)); 298 302 cancellationToken.ThrowIfCancellationRequested(); 299 303 } 300 304 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 } 301 310 302 311 // get scopes 303 312 int j = 0; 304 313 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 308 314 var scope = ((IAtomicOperation)((EngineJob)hiveJob.ItemJob).InitialOperation).Scope; 309 315 scopes[j++] = scope; … … 313 319 catch (OperationCanceledException e) { 314 320 lock (locker) { 315 if (jobIndices != null)DeleteHiveExperiment(hiveExperiment.Id);321 DeleteHiveExperiment(hiveExperiment.Id); 316 322 } 317 323 throw e; … … 319 325 catch (Exception e) { 320 326 lock (locker) { 321 if (jobIndices != null)DeleteHiveExperiment(hiveExperiment.Id);327 DeleteHiveExperiment(hiveExperiment.Id); 322 328 } 323 329 LogException(e); … … 333 339 hiveExperiment.UseLocalPlugins = this.UseLocalPlugins; 334 340 hiveExperiment.ResourceNames = this.ResourceNames; 341 hiveExperiment.IsPrivileged = this.IsPrivileged; 335 342 var refreshableHiveExperiment = new RefreshableHiveExperiment(hiveExperiment); 336 343 refreshableHiveExperiment.IsControllable = false; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Tests
- Property svn:ignore
-
old new 5 5 HeuristicLab.HiveEngine-3.4.Tests.csproj.vs10x 6 6 Meta-GA - Meta Optimization Problem (Genetic Programming - Symbolic Regression 3.4 scaled)_small.hl 7 HeuristicLab.HiveEngine-3.4.ConsoleTests.csproj.user 8 HeuristicLab.HiveEngine-3.4.ConsoleTests.csproj.vs10x
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Tests/Program.cs
r6373 r6381 47 47 GeneticAlgorithm alg = new GeneticAlgorithm(); 48 48 alg.Problem = new SingleObjectiveTestFunctionProblem(); 49 alg.Engine = new HiveEngine() { ResourceNames = " CHRISTOPH-PC" };49 alg.Engine = new HiveEngine() { ResourceNames = "HEAL" }; 50 50 alg.Elites.Value = 0; 51 51 alg.PopulationSize.Value = 10;
Note: See TracChangeset
for help on using the changeset viewer.