- Timestamp:
- 11/27/14 11:23:37 (9 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Breadcrumbs/HeuristicLab.Operators/3.3/DataReducer.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 69 69 public override IOperation Apply() { 70 70 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 82 85 return base.Apply(); 83 86 } … … 246 249 case ReductionOperations.Assign: 247 250 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); 248 276 target.Value = result; 249 277 break;
Note: See TracChangeset
for help on using the changeset viewer.