Changeset 10507 for stable/HeuristicLab.Operators
- Timestamp:
- 02/25/14 14:00:47 (11 years ago)
- Location:
- stable
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10149,10231,10261,10291-10292,10295,10298
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r10294 r10507 113 113 <Compile Include="CheckedMultiOperator.cs" /> 114 114 <Compile Include="CombinedOperator.cs" /> 115 <Compile Include="Operator.InstrumentedOperatorWrapper.cs" /> 115 116 <None Include="Plugin.cs.frame" /> 116 117 <Compile Include="ConditionalBranch.cs" /> … … 119 120 <Compile Include="AlgorithmOperator.cs" /> 120 121 <Compile Include="DataReducer.cs" /> 122 <Compile Include="InstrumentedOperator.cs" /> 121 123 <Compile Include="LocalRandomCreator.cs" /> 122 124 <Compile Include="MultiOperator.cs" /> … … 220 222 --> 221 223 <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) 223 225 set ProjectDir=$(ProjectDir) 224 226 set SolutionDir=$(SolutionDir) … … 227 229 call PreBuildEvent.cmd 228 230 </PreBuildEvent> 229 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">231 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 230 232 export ProjectDir=$(ProjectDir) 231 233 export SolutionDir=$(SolutionDir) -
stable/HeuristicLab.Operators/3.3/InstrumentedOperator.cs
r10149 r10507 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; … … 28 30 [Item("InstrumentedOperator", "A operator that can execute pre- and post actions.")] 29 31 [StorableClass] 30 public abstract class InstrumentedOperator : SingleSuccessorOperator {32 public abstract class InstrumentedOperator : SingleSuccessorOperator, IInstrumentedOperator { 31 33 private const string BeforeExecutionOperatorsParameterName = "BeforeExecutionOperators"; 32 34 private const string AfterExecutionOperatorsParameterName = "AfterExecutionOperators"; 33 35 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]; } 36 38 } 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]; } 39 41 } 40 42 41 public ItemList<SingleSuccessorOperator> BeforeExecutionOperators { 43 44 IEnumerable<IOperator> IInstrumentedOperator.BeforeExecutionOperators { get { return BeforeExecutionOperators; } } 45 public OperatorList BeforeExecutionOperators { 42 46 get { return BeforeExecutionOperatorsParameter.Value; } 43 47 } 44 public ItemList<SingleSuccessorOperator> AfterExecutionOperators { 48 IEnumerable<IOperator> IInstrumentedOperator.AfterExecutionOperators { get { return AfterExecutionOperators; } } 49 public OperatorList AfterExecutionOperators { 45 50 get { return AfterExecutionOperatorsParameter.Value; } 46 51 } … … 53 58 protected InstrumentedOperator() 54 59 : 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())); 57 62 BeforeExecutionOperatorsParameter.Hidden = true; 58 63 AfterExecutionOperatorsParameter.Hidden = true; … … 64 69 #region Backwards compatible code, remove with 3.4 65 70 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())); 67 72 BeforeExecutionOperatorsParameter.Hidden = true; 68 73 } 69 74 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())); 71 76 AfterExecutionOperatorsParameter.Hidden = true; 72 77 } … … 75 80 76 81 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(); 78 85 79 86 //build before operations 87 var opCol = new OperationCollection(); 80 88 foreach (var beforeAction in BeforeExecutionOperators) { 81 IOperation beforeActionOperation = ExecutionContext.CreateOperation(beforeAction);89 var beforeActionOperation = ExecutionContext.CreateChildOperation(beforeAction); 82 90 opCol.Add(beforeActionOperation); 83 91 } … … 88 96 89 97 public virtual IOperation InstrumentedApply() { 98 if (!AfterExecutionOperators.Any()) { 99 if (Successor != null) return ExecutionContext.CreateOperation(Successor); 100 return null; 101 } 102 90 103 var opCol = new OperationCollection(); 91 104 foreach (var afterAction in AfterExecutionOperators) { 92 IOperation afterActionOperation = ExecutionContext.CreateOperation(afterAction);105 var afterActionOperation = ExecutionContext.CreateChildOperation(afterAction); 93 106 opCol.Add(afterActionOperation); 94 107 } 108 95 109 if (Successor != null) 96 110 opCol.Add(ExecutionContext.CreateOperation(Successor)); -
stable/HeuristicLab.Operators/3.3/MultiOperator.cs
r9942 r10507 34 34 [Item("MultiOperator", "A base class for operators which apply arbitrary many other operators of a specific type.")] 35 35 [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 { 37 37 private List<IValueParameter<T>> operatorParameters; 38 38 protected IEnumerable<IValueParameter<T>> OperatorParameters { get { return operatorParameters; } } -
stable/HeuristicLab.Operators/3.3/Operator.cs
r9456 r10507 34 34 [Item("Operator", "Base class for operators.")] 35 35 [StorableClass] 36 public abstract class Operator : ParameterizedNamedItem, IOperator, IStatefulItem {36 public abstract partial class Operator : ParameterizedNamedItem, IOperator, IStatefulItem { 37 37 public static new Image StaticItemImage { 38 38 get { return HeuristicLab.Common.Resources.VSImageLibrary.Method; } -
stable/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs
r9456 r10507 132 132 /// or all selected operators have zero probabitlity.</exception> 133 133 /// <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() { 135 135 IRandom random = RandomParameter.ActualValue; 136 136 DoubleArray probabilities = ProbabilitiesParameter.ActualValue; … … 156 156 } 157 157 } 158 OperationCollection next = new OperationCollection(base. Apply());158 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 159 159 if (successor != null) { 160 160 if (TraceSelectedOperatorParameter.Value.Value) -
stable/HeuristicLab.Operators/3.3/SubScopesProcessor.cs
r9456 r10507 67 67 } 68 68 69 public override IOperation Apply() {69 public override IOperation InstrumentedApply() { 70 70 List<IScope> scopes = GetScopesOnLevel(ExecutionContext.Scope, Depth.Value).ToList(); 71 OperationCollection next = new OperationCollection(base. Apply());71 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 72 72 if (scopes.Count != Operators.Count) 73 73 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.