Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/12/13 13:03:29 (11 years ago)
Author:
ascheibe
Message:

#1886 cleaned up Hive RunCollection Modifier Task classes

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/RunCollectionModifierExecutable.cs

    r10121 r10128  
    113113      return new RunCollectionModifierExecutable(this, cloner);
    114114    }
     115
     116    //special cloning which ignores the RunCollection and the execution stack
     117    public RunCollectionModifierExecutable CloneWithoutRuns() {
     118      var clone = new RunCollectionModifierExecutable();
     119      clone.executionTime = executionTime;
     120      clone.executionState = executionState;
     121      clone.log = (ILog)log.Clone(new Cloner());
     122      clone.RunCollectionModifiersParameter.Value = (ItemList<IRunCollectionModifier>)RunCollectionModifiers.Clone(new Cloner());
     123      return clone;
     124    }
    115125    #endregion
    116126
     
    198208          executionStack.Push(next);
    199209          if (ex is OperationCanceledException) throw ex;
    200           else throw new Exception("IRunCollectionModifier " + next + "threw an exception.", ex);
     210          else throw new Exception("IRunCollectionModifier " + next + " threw an exception.", ex);
    201211        }
    202212        finally {
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers/RunCollectionModifierHiveTask.cs

    r10121 r10128  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Clients.Hive;
    2625using HeuristicLab.Common;
    27 using HeuristicLab.Optimization;
    2826
    2927namespace HeuristicLab.Analysis.SolutionCaching {
     
    5048
    5149    public override void IntegrateChild(ItemTask task, Guid childTaskId) {
    52       var optimizerTask = (RunCollectionModifierTask)task;
    53       syncTasksWithOptimizers = false; // don't sync with optimizers during this method
     50      var rcmTask = (RunCollectionModifierTask)task;
     51      syncTasksWithOptimizers = false;
    5452
    55       if (this.ItemTask != null && this.ItemTask.Item != null) {
     53      if (ItemTask != null && ItemTask.Item != null) {
    5654        itemTaskLock.EnterWriteLock();
    5755        try {
    58           this.ItemTask.Item.RunCollection.AddRange(((RunCollectionModifierExecutable)task.Item).RunCollection);
     56          ItemTask.Item.RunCollection.AddRange(rcmTask.Item.RunCollection);
    5957        }
    6058        finally {
     
    6361      }
    6462
    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         }
     63      RunCollectionModifierHiveTask child = ChildHiveTasks.Single(j => j.Task.Id == childTaskId) as RunCollectionModifierHiveTask;
     64      if (!rcmTask.ComputeInParallel) {
     65        child.ItemTask = rcmTask;
    7266      }
    7367      syncTasksWithOptimizers = true;
     
    8175            if (childHiveTasks.Any()) {
    8276              var exec = (RunCollectionModifierExecutable)ItemTask.Item;
    83               //compute in parallel was deactivated, copy runs back
     77              //compute in parallel was deactivated, copy runs back to parent
    8478              foreach (var childHiveTask in childHiveTasks) {
    8579                exec.RunCollection.AddRange(((RunCollectionModifierExecutable)childHiveTask.ItemTask.Item).RunCollection);
    8680              }
     81              childHiveTasks.Clear();
    8782            }
    88             childHiveTasks.Clear();
    8983          } else {
    9084            var runs = ItemTask.Item.RunCollection;
    9185            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();
     86              var exec = ItemTask.Item.CloneWithoutRuns();
    9587              exec.RunCollection.Add(run);
     88              exec.Prepare();
    9689
    9790              var rcmHiveTask = new RunCollectionModifierHiveTask(exec);
Note: See TracChangeset for help on using the changeset viewer.