Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/25/14 14:00:47 (11 years ago)
Author:
mkommend
Message:

#2119: Merged r10149, r10231, r10261, r10291, r10292, r10295 and r10298 into stable.

Location:
stable
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r10294 r10507  
    113113    <Compile Include="CheckedMultiOperator.cs" />
    114114    <Compile Include="CombinedOperator.cs" />
     115    <Compile Include="Operator.InstrumentedOperatorWrapper.cs" />
    115116    <None Include="Plugin.cs.frame" />
    116117    <Compile Include="ConditionalBranch.cs" />
     
    119120    <Compile Include="AlgorithmOperator.cs" />
    120121    <Compile Include="DataReducer.cs" />
     122    <Compile Include="InstrumentedOperator.cs" />
    121123    <Compile Include="LocalRandomCreator.cs" />
    122124    <Compile Include="MultiOperator.cs" />
     
    220222  -->
    221223  <PropertyGroup>
    222    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     224    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    223225set ProjectDir=$(ProjectDir)
    224226set SolutionDir=$(SolutionDir)
     
    227229call PreBuildEvent.cmd
    228230</PreBuildEvent>
    229 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     231    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    230232export ProjectDir=$(ProjectDir)
    231233export SolutionDir=$(SolutionDir)
  • stable/HeuristicLab.Operators/3.3/InstrumentedOperator.cs

    r10149 r10507  
    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));
  • stable/HeuristicLab.Operators/3.3/MultiOperator.cs

    r9942 r10507  
    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; } }
  • stable/HeuristicLab.Operators/3.3/Operator.cs

    r9456 r10507  
    3434  [Item("Operator", "Base class for operators.")]
    3535  [StorableClass]
    36   public abstract class Operator : ParameterizedNamedItem, IOperator, IStatefulItem {
     36  public abstract partial class Operator : ParameterizedNamedItem, IOperator, IStatefulItem {
    3737    public static new Image StaticItemImage {
    3838      get { return HeuristicLab.Common.Resources.VSImageLibrary.Method; }
  • stable/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r9456 r10507  
    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)
  • stable/HeuristicLab.Operators/3.3/SubScopesProcessor.cs

    r9456 r10507  
    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.