Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/14 14:29:01 (10 years ago)
Author:
gkronber
Message:

#2124 merged all changes from trunk to prepare for trunk-reintegration

Location:
branches/SpectralKernelForGaussianProcesses
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/SpectralKernelForGaussianProcesses

  • branches/SpectralKernelForGaussianProcesses/HeuristicLab.Operators/3.3/InstrumentedOperator.cs

    r10149 r10479  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    2830  [Item("InstrumentedOperator", "A operator that can execute pre- and post actions.")]
    2931  [StorableClass]
    30   public abstract class InstrumentedOperator : SingleSuccessorOperator {
     32  public abstract class InstrumentedOperator : SingleSuccessorOperator, IInstrumentedOperator {
    3133    private const string BeforeExecutionOperatorsParameterName = "BeforeExecutionOperators";
    3234    private const string AfterExecutionOperatorsParameterName = "AfterExecutionOperators";
    3335
    34     private IFixedValueParameter<ItemList<SingleSuccessorOperator>> BeforeExecutionOperatorsParameter {
    35       get { return (IFixedValueParameter<ItemList<SingleSuccessorOperator>>)Parameters[BeforeExecutionOperatorsParameterName]; }
     36    private IFixedValueParameter<OperatorList> BeforeExecutionOperatorsParameter {
     37      get { return (IFixedValueParameter<OperatorList>)Parameters[BeforeExecutionOperatorsParameterName]; }
    3638    }
    37     private IFixedValueParameter<ItemList<SingleSuccessorOperator>> AfterExecutionOperatorsParameter {
    38       get { return (IFixedValueParameter<ItemList<SingleSuccessorOperator>>)Parameters[AfterExecutionOperatorsParameterName]; }
     39    private IFixedValueParameter<OperatorList> AfterExecutionOperatorsParameter {
     40      get { return (IFixedValueParameter<OperatorList>)Parameters[AfterExecutionOperatorsParameterName]; }
    3941    }
    4042
    41     public ItemList<SingleSuccessorOperator> BeforeExecutionOperators {
     43
     44    IEnumerable<IOperator> IInstrumentedOperator.BeforeExecutionOperators { get { return BeforeExecutionOperators; } }
     45    public OperatorList BeforeExecutionOperators {
    4246      get { return BeforeExecutionOperatorsParameter.Value; }
    4347    }
    44     public ItemList<SingleSuccessorOperator> AfterExecutionOperators {
     48    IEnumerable<IOperator> IInstrumentedOperator.AfterExecutionOperators { get { return AfterExecutionOperators; } }
     49    public OperatorList AfterExecutionOperators {
    4550      get { return AfterExecutionOperatorsParameter.Value; }
    4651    }
     
    5358    protected InstrumentedOperator()
    5459      : base() {
    55       Parameters.Add(new FixedValueParameter<ItemList<SingleSuccessorOperator>>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new ItemList<SingleSuccessorOperator>()));
    56       Parameters.Add(new FixedValueParameter<ItemList<SingleSuccessorOperator>>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new ItemList<SingleSuccessorOperator>()));
     60      Parameters.Add(new FixedValueParameter<OperatorList>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new OperatorList()));
     61      Parameters.Add(new FixedValueParameter<OperatorList>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new OperatorList()));
    5762      BeforeExecutionOperatorsParameter.Hidden = true;
    5863      AfterExecutionOperatorsParameter.Hidden = true;
     
    6469      #region Backwards compatible code, remove with 3.4
    6570      if (!Parameters.ContainsKey(BeforeExecutionOperatorsParameterName)) {
    66         Parameters.Add(new FixedValueParameter<ItemList<SingleSuccessorOperator>>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new ItemList<SingleSuccessorOperator>()));
     71        Parameters.Add(new FixedValueParameter<OperatorList>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new OperatorList()));
    6772        BeforeExecutionOperatorsParameter.Hidden = true;
    6873      }
    6974      if (!Parameters.ContainsKey(AfterExecutionOperatorsParameterName)) {
    70         Parameters.Add(new FixedValueParameter<ItemList<SingleSuccessorOperator>>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new ItemList<SingleSuccessorOperator>()));
     75        Parameters.Add(new FixedValueParameter<OperatorList>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new OperatorList()));
    7176        AfterExecutionOperatorsParameter.Hidden = true;
    7277      }
     
    7580
    7681    public sealed override IOperation Apply() {
    77       var opCol = new OperationCollection();
     82      //to speed up the execution call instrumented apply directly if no before operators exists
     83      if (!BeforeExecutionOperators.Any())
     84        return InstrumentedApply();
    7885
    7986      //build before operations
     87      var opCol = new OperationCollection();
    8088      foreach (var beforeAction in BeforeExecutionOperators) {
    81         IOperation beforeActionOperation = ExecutionContext.CreateOperation(beforeAction);
     89        var beforeActionOperation = ExecutionContext.CreateChildOperation(beforeAction);
    8290        opCol.Add(beforeActionOperation);
    8391      }
     
    8896
    8997    public virtual IOperation InstrumentedApply() {
     98      if (!AfterExecutionOperators.Any()) {
     99        if (Successor != null) return ExecutionContext.CreateOperation(Successor);
     100        return null;
     101      }
     102
    90103      var opCol = new OperationCollection();
    91104      foreach (var afterAction in AfterExecutionOperators) {
    92         IOperation afterActionOperation = ExecutionContext.CreateOperation(afterAction);
     105        var afterActionOperation = ExecutionContext.CreateChildOperation(afterAction);
    93106        opCol.Add(afterActionOperation);
    94107      }
     108
    95109      if (Successor != null)
    96110        opCol.Add(ExecutionContext.CreateOperation(Successor));
  • branches/SpectralKernelForGaussianProcesses/HeuristicLab.Operators/3.3/MultiOperator.cs

    r9838 r10479  
    3434  [Item("MultiOperator", "A base class for operators which apply arbitrary many other operators of a specific type.")]
    3535  [StorableClass]
    36   public abstract class MultiOperator<T> : SingleSuccessorOperator, IMultiOperator<T> where T : class, IOperator {
     36  public abstract class MultiOperator<T> : InstrumentedOperator, IMultiOperator<T> where T : class, IOperator {
    3737    private List<IValueParameter<T>> operatorParameters;
    3838    protected IEnumerable<IValueParameter<T>> OperatorParameters { get { return operatorParameters; } }
  • branches/SpectralKernelForGaussianProcesses/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r9456 r10479  
    132132    /// or all selected operators have zero probabitlity.</exception>
    133133    /// <returns>A new operation with the operator that was selected followed by the current operator's successor.</returns>
    134     public override IOperation Apply() {
     134    public override IOperation InstrumentedApply() {
    135135      IRandom random = RandomParameter.ActualValue;
    136136      DoubleArray probabilities = ProbabilitiesParameter.ActualValue;
     
    156156        }
    157157      }
    158       OperationCollection next = new OperationCollection(base.Apply());
     158      OperationCollection next = new OperationCollection(base.InstrumentedApply());
    159159      if (successor != null) {
    160160        if (TraceSelectedOperatorParameter.Value.Value)
  • branches/SpectralKernelForGaussianProcesses/HeuristicLab.Operators/3.3/SubScopesProcessor.cs

    r9456 r10479  
    6767    }
    6868
    69     public override IOperation Apply() {
     69    public override IOperation InstrumentedApply() {
    7070      List<IScope> scopes = GetScopesOnLevel(ExecutionContext.Scope, Depth.Value).ToList();
    71       OperationCollection next = new OperationCollection(base.Apply());
     71      OperationCollection next = new OperationCollection(base.InstrumentedApply());
    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);
Note: See TracChangeset for help on using the changeset viewer.