Changeset 11678 for branches/ALPS/HeuristicLab.Operators
- Timestamp:
- 12/10/14 12:42:59 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Operators/3.3/DataReducer.cs
r11171 r11678 40 40 get { return (LookupParameter<IItem>)Parameters["TargetParameter"]; } 41 41 } 42 public Value Parameter<ReductionOperation> ReductionOperation {43 get { return (Value Parameter<ReductionOperation>)Parameters["ReductionOperation"]; }44 } 45 public Value Parameter<ReductionOperation> TargetOperation {46 get { return (Value Parameter<ReductionOperation>)Parameters["TargetOperation"]; }42 public ValueLookupParameter<ReductionOperation> ReductionOperation { 43 get { return (ValueLookupParameter<ReductionOperation>)Parameters["ReductionOperation"]; } 44 } 45 public ValueLookupParameter<ReductionOperation> TargetOperation { 46 get { return (ValueLookupParameter<ReductionOperation>)Parameters["TargetOperation"]; } 47 47 } 48 48 #endregion … … 58 58 Parameters.Add(new ScopeTreeLookupParameter<IItem>("ParameterToReduce", "The parameter on which the reduction operation should be applied.")); 59 59 Parameters.Add(new LookupParameter<IItem>("TargetParameter", "The target variable in which the reduced value should be stored.")); 60 Parameters.Add(new Value Parameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce."));61 Parameters.Add(new Value Parameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable."));60 Parameters.Add(new ValueLookupParameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce.", new ReductionOperation())); 61 Parameters.Add(new ValueLookupParameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable.", new ReductionOperation())); 62 62 #endregion 63 63 } … … 65 65 public override IDeepCloneable Clone(Cloner cloner) { 66 66 return new DataReducer(this, cloner); 67 } 68 69 [StorableHook(HookType.AfterDeserialization)] 70 private void AfterDeserialization() { 71 // BackwardsCompatibility3.3 72 var oldReductionOperation = Parameters["ReductionOperation"] as ValueParameter<ReductionOperation>; 73 if (oldReductionOperation != null) { 74 Parameters.Remove("ReductionOperation"); 75 Parameters.Add(new ValueLookupParameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce.", oldReductionOperation.Value)); 76 } 77 var oldTargetOperation = Parameters["TargetOperation"] as ValueParameter<ReductionOperation>; 78 if (oldTargetOperation != null) { 79 Parameters.Remove("TargetOperation"); 80 Parameters.Add(new ValueLookupParameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable.", oldTargetOperation.Value)); 81 } 67 82 } 68 83 … … 89 104 private void CalculateResult(IEnumerable<int> values, Type targetType) { 90 105 int result; 91 switch (ReductionOperation. Value.Value) {106 switch (ReductionOperation.ActualValue.Value) { 92 107 case ReductionOperations.Sum: 93 108 result = values.Sum(); … … 116 131 117 132 IntValue target; 118 switch (TargetOperation. Value.Value) {133 switch (TargetOperation.ActualValue.Value) { 119 134 case ReductionOperations.Sum: 120 135 target = InitializeTarget<IntValue, int>(targetType, 0); … … 149 164 private void CalculateResult(IEnumerable<double> values, Type targetType) { 150 165 double result; 151 switch (ReductionOperation. Value.Value) {166 switch (ReductionOperation.ActualValue.Value) { 152 167 case ReductionOperations.Sum: 153 168 result = values.Sum(); … … 176 191 177 192 DoubleValue target; 178 switch (TargetOperation. Value.Value) {193 switch (TargetOperation.ActualValue.Value) { 179 194 case ReductionOperations.Sum: 180 195 target = InitializeTarget<DoubleValue, double>(targetType, 0.0); … … 209 224 private void CalculateResult(IEnumerable<TimeSpan> values, Type targetType) { 210 225 TimeSpan result; 211 switch (ReductionOperation. Value.Value) {226 switch (ReductionOperation.ActualValue.Value) { 212 227 case ReductionOperations.Sum: 213 228 result = values.Aggregate(new TimeSpan(), (x, y) => x + y); … … 230 245 231 246 TimeSpanValue target; 232 switch (TargetOperation. Value.Value) {247 switch (TargetOperation.ActualValue.Value) { 233 248 case ReductionOperations.Sum: 234 249 target = InitializeTarget<TimeSpanValue, TimeSpan>(targetType, new TimeSpan()); … … 259 274 private void CalculateResult(IEnumerable<bool> values, Type targetType) { 260 275 bool result; 261 switch (ReductionOperation. Value.Value) {276 switch (ReductionOperation.ActualValue.Value) { 262 277 case ReductionOperations.All: 263 278 result = values.All(x => x); … … 271 286 272 287 BoolValue target; 273 switch (TargetOperation. Value.Value) {288 switch (TargetOperation.ActualValue.Value) { 274 289 case ReductionOperations.Assign: 275 290 target = InitializeTarget<BoolValue, bool>(targetType, true);
Note: See TracChangeset
for help on using the changeset viewer.