- Timestamp:
- 10/21/15 17:42:18 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/WeightingReducer.cs
r12997 r13046 34 34 public sealed class WeightingReducer : SingleSuccessorOperator { 35 35 36 public ScopeTreeLookupParameter<IntValue> ParameterToReduce {37 get { return ( ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; }36 public IScopeTreeLookupParameter<DoubleValue> ParameterToReduce { 37 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["ParameterToReduce"]; } 38 38 } 39 public LookupParameter<IntValue> TargetParameter {40 get { return ( LookupParameter<IntValue>)Parameters["TargetParameter"]; }39 public ILookupParameter<DoubleValue> TargetParameter { 40 get { return (ILookupParameter<DoubleValue>)Parameters["TargetParameter"]; } 41 41 } 42 42 public IValueLookupParameter<DoubleValue> WeightParameter { … … 54 54 public WeightingReducer() 55 55 : base() { 56 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("ParameterToReduce", "The parameter on which the weighting should be applied."));57 Parameters.Add(new LookupParameter< IntValue>("TargetParameter", "The target variable in which the weighted value should be stored."));56 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ParameterToReduce", "The parameter on which the weighting should be applied.")); 57 Parameters.Add(new LookupParameter<DoubleValue>("TargetParameter", "The target variable in which the weighted value should be stored.")); 58 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("Weight", "Weight of the two values (0.0 for the smaller, 1.0 for the larger).")); 59 59 } … … 64 64 throw new InvalidOperationException("Weighting between values can only done for two values."); 65 65 66 varweight = WeightParameter.ActualValue.Value;66 double weight = WeightParameter.ActualValue.Value; 67 67 68 varmax = values.Max(v => v.Value);69 varmin = values.Min(v => v.Value);68 double max = values.Max(v => v.Value); 69 double min = values.Min(v => v.Value); 70 70 71 int result = (int)(max * weight + min * (1 - weight));71 double result = max * weight + min * (1 - weight); 72 72 73 73 if (TargetParameter.ActualValue == null) 74 TargetParameter.ActualValue = new IntValue(result);74 TargetParameter.ActualValue = new DoubleValue(result); 75 75 else TargetParameter.ActualValue.Value = result; 76 76
Note: See TracChangeset
for help on using the changeset viewer.