Changeset 10117 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers
- Timestamp:
- 11/08/13 18:39:42 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers/RunCollectionModifierHiveTask.cs
r10114 r10117 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Clients.Hive; 23 26 using HeuristicLab.Common; 27 using HeuristicLab.Optimization; 24 28 25 29 namespace HeuristicLab.Analysis.SolutionCaching { … … 30 34 ItemTask = task; 31 35 } 36 32 37 public RunCollectionModifierHiveTask(RunCollectionModifierExecutable executable) 33 38 : base() { 34 39 ItemTask = new RunCollectionModifierTask(executable); 35 40 } 41 36 42 protected RunCollectionModifierHiveTask(RunCollectionModifierHiveTask original, Cloner cloner) 37 : base(original, cloner) { } 43 : base(original, cloner) { 44 } 45 38 46 public override IDeepCloneable Clone(Cloner cloner) { 39 47 return new RunCollectionModifierHiveTask(this, cloner); 40 48 } 41 49 #endregion 50 51 public override void IntegrateChild(ItemTask task, Guid childTaskId) { 52 var optimizerTask = (RunCollectionModifierTask)task; 53 syncTasksWithOptimizers = false; // don't sync with optimizers during this method 54 55 if (this.ItemTask != null && this.ItemTask.Item != null) { 56 itemTaskLock.EnterWriteLock(); 57 try { 58 this.ItemTask.Item.RunCollection.AddRange(((RunCollectionModifierExecutable)task.Item).RunCollection); 59 } 60 finally { 61 itemTaskLock.ExitWriteLock(); 62 } 63 } 64 65 IEnumerable<HiveTask> childs = this.ChildHiveTasks.Where(j => j.Task.Id == childTaskId); 66 //TODO: in very rare cases childs is empty. This shouldn't be the case and should be further investigated. 67 if (childs.Count() > 0) { 68 RunCollectionModifierHiveTask child = childs.First() as RunCollectionModifierHiveTask; 69 if (child != null && !optimizerTask.ComputeInParallel) { 70 child.ItemTask = optimizerTask; 71 } 72 } 73 syncTasksWithOptimizers = true; 74 } 75 76 protected override void UpdateChildHiveTasks() { 77 childHiveTasksLock.EnterWriteLock(); 78 try { 79 if (Task != null && syncTasksWithOptimizers) { 80 if (!ItemTask.ComputeInParallel) { 81 if (childHiveTasks.Any()) { 82 var exec = (RunCollectionModifierExecutable)ItemTask.Item; 83 //compute in parallel was deactivated, copy runs back 84 foreach (var childHiveTask in childHiveTasks) { 85 exec.RunCollection.AddRange(((RunCollectionModifierExecutable)childHiveTask.ItemTask.Item).RunCollection); 86 } 87 } 88 childHiveTasks.Clear(); 89 } else { 90 var runs = ItemTask.Item.RunCollection; 91 foreach (var run in runs) { 92 var exec = (RunCollectionModifierExecutable)ItemTask.Item.Clone(new Cloner()); 93 //TODO: this could be more efficient, create new RCME instead of cloning 94 exec.RunCollection.Clear(); 95 exec.RunCollection.Add(run); 96 97 var rcmHiveTask = new RunCollectionModifierHiveTask(exec); 98 rcmHiveTask.Task.Priority = Task.Priority; 99 childHiveTasks.Add(rcmHiveTask); 100 } 101 ItemTask.Item.RunCollection.Clear(); 102 } 103 } 104 } 105 finally { 106 childHiveTasksLock.ExitWriteLock(); 107 } 108 } 42 109 } 43 110 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers/RunCollectionModifierTask.cs
r10114 r10117 30 30 [StorableClass] 31 31 public class RunCollectionModifierTask : ItemTask { 32 public override bool IsParallelizable {32 /*public override bool IsParallelizable { 33 33 get { return false; } 34 } 34 } */ 35 35 36 36 public new RunCollectionModifierExecutable Item {
Note: See TracChangeset
for help on using the changeset viewer.