Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/26/10 03:51:30 (13 years ago)
Author:
swagner
Message:

Removed property ExecutionContext in Operator (#1333)

Location:
branches/ParallelEngine/HeuristicLab.Operators/3.3
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/AlgorithmOperator.cs

    r4722 r5177  
    5555    }
    5656
    57     public override IOperation Apply() {
    58       OperationCollection next = new OperationCollection(base.Apply());
     57    public override IOperation Apply(IExecutionContext context) {
     58      OperationCollection next = new OperationCollection(base.Apply(context));
    5959      if (operatorGraph.InitialOperator != null)
    60         next.Insert(0, ExecutionContext.CreateChildOperation(operatorGraph.InitialOperator));
     60        next.Insert(0, context.CreateChildOperation(operatorGraph.InitialOperator));
    6161      return next;
    6262    }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/Assigner.cs

    r4722 r5177  
    5454    }
    5555
    56     public override IOperation Apply() {
     56    public override IOperation Apply(IExecutionContext context) {
    5757      LeftSideParameter.ActualValue = (IItem)RightSideParameter.ActualValue.Clone();
    58       return base.Apply();
     58      return base.Apply(context);
    5959    }
    6060  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/Comparator.cs

    r4722 r5177  
    6868    }
    6969
    70     public override IOperation Apply() {
     70    public override IOperation Apply(IExecutionContext context) {
    7171      IItem left = LeftSideParameter.ActualValue;
    7272      IItem right = RightSideParameter.ActualValue;
     
    9191      }
    9292      ResultParameter.ActualValue = new BoolValue(b);
    93       return base.Apply();
     93      return base.Apply(context);
    9494    }
    9595  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/ConditionalBranch.cs

    r4722 r5177  
    6767    }
    6868
    69     public override IOperation Apply() {
    70       OperationCollection next = new OperationCollection(base.Apply());
     69    public override IOperation Apply(IExecutionContext context) {
     70      OperationCollection next = new OperationCollection(base.Apply(context));
    7171      if (ConditionParameter.ActualValue != null && ConditionParameter.ActualValue.Value) {
    72         if (TrueBranch != null) next.Insert(0, ExecutionContext.CreateOperation(TrueBranch));
     72        if (TrueBranch != null) next.Insert(0, context.CreateOperation(TrueBranch));
    7373      } else {
    74         if (FalseBranch != null) next.Insert(0, ExecutionContext.CreateOperation(FalseBranch));
     74        if (FalseBranch != null) next.Insert(0, context.CreateOperation(FalseBranch));
    7575      }
    7676      return next;
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/DoubleCounter.cs

    r4722 r5177  
    5959    }
    6060
    61     public override IOperation Apply() {
     61    public override IOperation Apply(IExecutionContext context) {
    6262      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new DoubleValue();
    6363      ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
    64       return base.Apply();
     64      return base.Apply(context);
    6565    }
    6666  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/IntCounter.cs

    r4722 r5177  
    5959    }
    6060
    61     public override IOperation Apply() {
     61    public override IOperation Apply(IExecutionContext context) {
    6262      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntValue();
    6363      ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
    64       return base.Apply();
     64      return base.Apply(context);
    6565    }
    6666  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/Operator.cs

    r4722 r5177  
    2828namespace HeuristicLab.Operators {
    2929  /// <summary>
    30   /// The base class for all operators.
     30  /// Base class for operators.
    3131  /// </summary>
    3232  [Item("Operator", "Base class for operators.")]
     
    4343    }
    4444
    45     [Storable]
    46     private IExecutionContext executionContext;
    47     protected IExecutionContext ExecutionContext {
    48       get { return executionContext; }
    49       private set {
    50         if (value != executionContext) {
    51           executionContext = value;
    52           OnExecutionContextChanged();
    53         }
    54       }
    55     }
    56 
    57     /// <summary>
    58     /// Flag whether the current instance has been canceled.
    59     /// </summary>
    6045    private bool canceled;
    61     /// <inheritdoc/>
    6246    protected bool Canceled {
    6347      get { return canceled; }
     
    7256    [Storable]
    7357    private bool breakpoint;
    74     /// <inheritdoc/>
    75     /// <remarks>Calls <see cref="OnBreakpointChanged"/> in the setter.</remarks>
    7658    public bool Breakpoint {
    7759      get { return breakpoint; }
     
    9173      this.canceled = original.canceled;
    9274      this.breakpoint = original.breakpoint;
    93       this.executionContext = cloner.Clone<IExecutionContext>(original.executionContext);
    9475    }
    95     /// <summary>
    96     /// Initializes a new instance of <see cref="OperatorBase"/> setting the breakpoint flag and
    97     /// the canceled flag to <c>false</c> and the name of the operator to the type name.
    98     /// </summary>
    9976    protected Operator()
    10077      : base() {
     
    123100    }
    124101
    125     /// <inheritdoc/>
    126102    public virtual IOperation Execute(IExecutionContext context) {
    127103      try {
    128104        Canceled = false;
    129         ExecutionContext = context;
    130105        foreach (IParameter param in Parameters)
    131106          param.ExecutionContext = context;
    132         IOperation next = Apply();
     107        IOperation next = Apply(context);
    133108        OnExecuted();
    134109        return next;
     
    137112        foreach (IParameter param in Parameters)
    138113          param.ExecutionContext = null;
    139         ExecutionContext = null;
    140114      }
    141115    }
    142     /// <inheritdoc/>
    143     /// <remarks>Sets property <see cref="Canceled"/> to <c>true</c>.</remarks>
    144116    public void Abort() {
    145117      Canceled = true;
    146118    }
    147     /// <summary>
    148     /// Performs the current operator on the specified <paramref name="scope"/>.
    149     /// </summary>
    150     /// <param name="scope">The scope where to execute the operator</param>
    151     /// <returns><c>null</c>.</returns>
    152     public abstract IOperation Apply();
     119    public abstract IOperation Apply(IExecutionContext context);
    153120
    154     protected virtual void OnExecutionContextChanged() { }
    155121    protected virtual void OnCanceledChanged() { }
    156     /// <inheritdoc/>
    157122    public event EventHandler BreakpointChanged;
    158     /// <summary>
    159     /// Fires a new <c>BreakpointChanged</c> event.
    160     /// </summary>
    161123    protected virtual void OnBreakpointChanged() {
    162124      if (BreakpointChanged != null) {
     
    164126      }
    165127    }
    166     /// <inheritdoc/>
    167128    public event EventHandler Executed;
    168     /// <summary>
    169     /// Fires a new <c>Executed</c> event.
    170     /// </summary>
    171129    protected virtual void OnExecuted() {
    172130      if (Executed != null) {
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/Placeholder.cs

    r4722 r5177  
    5050    }
    5151
    52     public override IOperation Apply() {
    53       OperationCollection next = new OperationCollection(base.Apply());
     52    public override IOperation Apply(IExecutionContext context) {
     53      OperationCollection next = new OperationCollection(base.Apply(context));
    5454      IOperator op = OperatorParameter.ActualValue;
    5555      if (op != null)
    56         next.Insert(0, ExecutionContext.CreateOperation(op));
     56        next.Insert(0, context.CreateOperation(op));
    5757      return next;
    5858    }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/ScopeCleaner.cs

    r4722 r5177  
    5353    }
    5454
    55     public override IOperation Apply() {
     55    public override IOperation Apply(IExecutionContext context) {
    5656      CurrentScope.Variables.Clear();
    5757      CurrentScope.SubScopes.Clear();
    58       return base.Apply();
     58      return base.Apply(context);
    5959    }
    6060  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs

    r4722 r5177  
    5050    }
    5151   
    52     public override IOperation Apply() {
     52    public override IOperation Apply(IExecutionContext context) {
    5353      if (Successor != null)
    54         return ExecutionContext.CreateOperation(Successor);
     54        return context.CreateOperation(Successor);
    5555      else
    5656        return null;
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/StochasticBranch.cs

    r4722 r5177  
    7171    }
    7272
    73     public override IOperation Apply() {
    74       OperationCollection next = new OperationCollection(base.Apply());
     73    public override IOperation Apply(IExecutionContext context) {
     74      OperationCollection next = new OperationCollection(base.Apply(context));
    7575      if (RandomParameter.ActualValue.NextDouble() < ProbabilityParameter.ActualValue.Value) {
    76         if (FirstBranch != null) next.Insert(0, ExecutionContext.CreateOperation(FirstBranch));
     76        if (FirstBranch != null) next.Insert(0, context.CreateOperation(FirstBranch));
    7777      } else {
    78         if (SecondBranch != null) next.Insert(0, ExecutionContext.CreateOperation(SecondBranch));
     78        if (SecondBranch != null) next.Insert(0, context.CreateOperation(SecondBranch));
    7979      }
    8080      return next;
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r4722 r5177  
    109109    /// or all selected operators have zero probabitlity.</exception>
    110110    /// <returns>A new operation with the operator that was selected followed by the current operator's successor.</returns>
    111     public override IOperation Apply() {
     111    public override IOperation Apply(IExecutionContext context) {
    112112      IRandom random = RandomParameter.ActualValue;
    113113      DoubleArray probabilities = ProbabilitiesParameter.ActualValue;
     
    131131        }
    132132      }
    133       OperationCollection next = new OperationCollection(base.Apply());
     133      OperationCollection next = new OperationCollection(base.Apply(context));
    134134      if (successor != null) {
    135135        if (CreateChildOperation)
    136           next.Insert(0, ExecutionContext.CreateChildOperation(successor));
    137         else next.Insert(0, ExecutionContext.CreateOperation(successor));
     136          next.Insert(0, context.CreateChildOperation(successor));
     137        else next.Insert(0, context.CreateOperation(successor));
    138138      }
    139139      return next;
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SubScopesCreator.cs

    r4722 r5177  
    5858    }
    5959
    60     public override IOperation Apply() {
     60    public override IOperation Apply(IExecutionContext context) {
    6161      int n = NumberOfSubScopesParameter.ActualValue.Value;
    6262      for (int i = 0; i < n; i++)
    6363        CurrentScope.SubScopes.Add(new Scope(i.ToString()));
    64       return base.Apply();
     64      return base.Apply(context);
    6565    }
    6666  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SubScopesMixer.cs

    r4722 r5177  
    7777    /// <param name="scope">The scope whose sub scopes should be mixed.</param>
    7878    /// <returns><c>null</c>.</returns>
    79     public override IOperation Apply() {
     79    public override IOperation Apply(IExecutionContext context) {
    8080      int partitions = Partitions.Value;
    81       IScope scope = ExecutionContext.Scope;
     81      IScope scope = context.Scope;
    8282      int count = scope.SubScopes.Count;
    8383      if ((count % partitions) != 0)
     
    9696      scope.SubScopes.AddRange(reorderedSubScopes);
    9797
    98       return base.Apply();
     98      return base.Apply(context);
    9999    }
    100100  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SubScopesProcessor.cs

    r4722 r5177  
    6767    }
    6868
    69     public override IOperation Apply() {
    70       List<IScope> scopes = GetScopesOnLevel(ExecutionContext.Scope, Depth.Value).ToList();
    71       OperationCollection next = new OperationCollection(base.Apply());
     69    public override IOperation Apply(IExecutionContext context) {
     70      List<IScope> scopes = GetScopesOnLevel(context.Scope, Depth.Value).ToList();
     71      OperationCollection next = new OperationCollection(base.Apply(context));
    7272      if (scopes.Count != Operators.Count)
    7373        throw new ArgumentException("The number of operators doesn't match the number of sub-scopes at depth " + Depth.Value);
     
    7575      inner.Parallel = Parallel == null ? false : Parallel.Value;
    7676      for (int i = 0; i < scopes.Count(); i++) {
    77         inner.Add(ExecutionContext.CreateOperation(Operators[i], scopes[i]));
     77        inner.Add(context.CreateOperation(Operators[i], scopes[i]));
    7878      }
    7979      next.Insert(0, inner);
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SubScopesRemover.cs

    r4722 r5177  
    6767    }
    6868
    69     public override IOperation Apply() {
     69    public override IOperation Apply(IExecutionContext context) {
    7070      if (RemoveAllSubScopes)
    7171        CurrentScope.SubScopes.Clear();
     
    7373        CurrentScope.SubScopes.RemoveAt(SubScopeIndexParameter.ActualValue.Value);
    7474      }
    75       return base.Apply();
     75      return base.Apply(context);
    7676    }
    7777  }
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/SubScopesSorter.cs

    r4722 r5177  
    6565    }
    6666
    67     public override IOperation Apply() {
     67    public override IOperation Apply(IExecutionContext context) {
    6868      descending = DescendingParameter.ActualValue.Value;
    6969      actualName = ValueParameter.TranslatedName;
    7070      CurrentScope.SubScopes.Sort(SortScopes);
    71       return base.Apply();
     71      return base.Apply(context);
    7272    }
    7373
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/UniformSubScopesProcessor.cs

    r4722 r5177  
    7474    }
    7575
    76     public override IOperation Apply() {
    77       OperationCollection next = new OperationCollection(base.Apply());
     76    public override IOperation Apply(IExecutionContext context) {
     77      OperationCollection next = new OperationCollection(base.Apply(context));
    7878      if (Operator != null) {
    79         List<IScope> scopes = GetScopesOnLevel(ExecutionContext.Scope, Depth.Value).ToList();
     79        List<IScope> scopes = GetScopesOnLevel(context.Scope, Depth.Value).ToList();
    8080        OperationCollection inner = new OperationCollection();
    8181        inner.Parallel = Parallel == null ? false : Parallel.Value;
    8282        for (int i = 0; i < scopes.Count; i++) {
    83           inner.Add(ExecutionContext.CreateOperation(Operator, scopes[i]));
     83          inner.Add(context.CreateOperation(Operator, scopes[i]));
    8484        }
    8585        next.Insert(0, inner);
  • branches/ParallelEngine/HeuristicLab.Operators/3.3/VariableCreator.cs

    r4722 r5177  
    5353    }
    5454
    55     public override IOperation Apply() {
     55    public override IOperation Apply(IExecutionContext context) {
    5656      IVariable var;
    5757      foreach (IParameter param in CollectedValues) {
     
    6666          CurrentScope.Variables.Add(new Variable(name, param.Description, value == null ? null : (IItem)value.Clone()));
    6767      }
    68       return base.Apply();
     68      return base.Apply(context);
    6969    }
    7070  }
Note: See TracChangeset for help on using the changeset viewer.