Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 14:48:13 (11 years ago)
Author:
pfleck
Message:
  • merged trunk
Location:
branches/DataPreprocessing
Files:
1 deleted
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Operators/3.3/DataReducer.cs

    r9456 r10538  
    6969    public override IOperation Apply() {
    7070      var values = ParameterToReduce.ActualValue;
    71       if (values.Count() > 0) {
    72         if (values.All(x => typeof(IntValue).IsAssignableFrom(x.GetType()))) {
    73           CalculateResult(values.OfType<IntValue>().Select(x => x.Value), values.First().GetType());
    74         } else if (values.All(x => typeof(DoubleValue).IsAssignableFrom(x.GetType()))) {
    75           CalculateResult(values.OfType<DoubleValue>().Select(x => x.Value), values.First().GetType());
    76         } else if (values.All(x => typeof(TimeSpanValue).IsAssignableFrom(x.GetType()))) {
    77           CalculateResult(values.OfType<TimeSpanValue>().Select(x => x.Value), values.First().GetType());
    78         } else {
    79           throw new ArgumentException(string.Format("Type {0} is not supported by the DataReducer.", values.First().GetType()));
    80         }
    81       }
     71      if (!values.Any()) return base.Apply();
     72
     73      if (values.All(x => x is IntValue)) {
     74        CalculateResult(values.OfType<IntValue>().Select(x => x.Value), values.First().GetType());
     75      } else if (values.All(x => x is DoubleValue)) {
     76        CalculateResult(values.OfType<DoubleValue>().Select(x => x.Value), values.First().GetType());
     77      } else if (values.All(x => x is TimeSpanValue)) {
     78        CalculateResult(values.OfType<TimeSpanValue>().Select(x => x.Value), values.First().GetType());
     79      } else if (values.All(x => x is BoolValue)) {
     80        CalculateResult(values.OfType<BoolValue>().Select(x => x.Value), values.First().GetType());
     81      } else {
     82        throw new ArgumentException(string.Format("Type {0} is not supported by the DataReducer.", values.First().GetType()));
     83      }
     84
    8285      return base.Apply();
    8386    }
     
    246249        case ReductionOperations.Assign:
    247250          target = InitializeTarget<TimeSpanValue, TimeSpan>(targetType, new TimeSpan());
     251          target.Value = result;
     252          break;
     253        default:
     254          throw new InvalidOperationException(string.Format("Operation {0} is not supported as TargetOperation for type: {1}.", TargetOperation.Value.Value, targetType));
     255      }
     256    }
     257    #endregion
     258    #region bool reduction
     259    private void CalculateResult(IEnumerable<bool> values, Type targetType) {
     260      bool result;
     261      switch (ReductionOperation.Value.Value) {
     262        case ReductionOperations.All:
     263          result = values.All(x => x);
     264          break;
     265        case ReductionOperations.Any:
     266          result = values.Any(x => x);
     267          break;
     268        default:
     269          throw new InvalidOperationException(string.Format("Operation {0} is not supported as ReductionOperation for type: {1}.", ReductionOperation.Value.Value, targetType));
     270      }
     271
     272      BoolValue target;
     273      switch (TargetOperation.Value.Value) {
     274        case ReductionOperations.Assign:
     275          target = InitializeTarget<BoolValue, bool>(targetType, true);
    248276          target.Value = result;
    249277          break;
  • branches/DataPreprocessing/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r8600 r10538  
    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" />
     
    126128    <Compile Include="Plugin.cs" />
    127129    <Compile Include="ReductionOperation.cs" />
    128     <Compile Include="ReductionOperations.cs" />
    129130    <Compile Include="ScopeCleaner.cs" />
    130131    <Compile Include="StochasticBranch.cs" />
     
    221222  -->
    222223  <PropertyGroup>
    223    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     224    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    224225set ProjectDir=$(ProjectDir)
    225226set SolutionDir=$(SolutionDir)
     
    228229call PreBuildEvent.cmd
    229230</PreBuildEvent>
    230 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     231    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    231232export ProjectDir=$(ProjectDir)
    232233export SolutionDir=$(SolutionDir)
  • branches/DataPreprocessing/HeuristicLab.Operators/3.3/MultiOperator.cs

    r9838 r10538  
    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/DataPreprocessing/HeuristicLab.Operators/3.3/Operator.cs

    r9456 r10538  
    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; }
  • branches/DataPreprocessing/HeuristicLab.Operators/3.3/ReductionOperation.cs

    r9456 r10538  
    2727
    2828namespace HeuristicLab.Operators {
     29  public enum ReductionOperations {
     30    Sum,
     31    Product,
     32    Count,
     33    Min,
     34    Max,
     35    Avg,
     36    Assign,
     37    All,
     38    Any
     39  }
     40
    2941  [Item("ReductionOperation", "Represents a certain type of reduction operation.")]
    3042  [StorableClass]
  • branches/DataPreprocessing/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r9456 r10538  
    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/DataPreprocessing/HeuristicLab.Operators/3.3/SubScopesProcessor.cs

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