Changeset 7322 for branches/HiveHiveEngine/HeuristicLab.Operators
- Timestamp:
- 01/12/12 19:31:53 (12 years ago)
- Location:
- branches/HiveHiveEngine/HeuristicLab.Operators/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/AllSubScopesIntReducer.cs
r7288 r7322 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 36 35 public sealed class AllSubScopesIntReducer : SingleSuccessorOperator { 37 36 38 public ValueLookupParameter<StringValue> ParameterToReduce {39 get { return ( ValueLookupParameter<StringValue>)Parameters["ParameterToReduce"]; }37 public ScopeTreeLookupParameter<IntValue> ParameterToReduce { 38 get { return (ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; } 40 39 } 41 40 … … 55 54 public AllSubScopesIntReducer() 56 55 : base() { 57 Parameters.Add(new ValueLookupParameter<StringValue>("ParameterToReduce", "Parameter to look for in the sub scopes and collect the values from", new StringValue(string.Empty)));56 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("ParameterToReduce", "The actual parameter defined by TargetParameterName")); 58 57 Parameters.Add(new ValueLookupParameter<StringValue>("TargetParameterName", "Parameter name to add the value to", new StringValue(string.Empty))); 59 58 Parameters.Add(new LookupParameter<IntValue>("TargetParameter", "The actual parameter defined by TargetParameterName")); … … 65 64 66 65 public override IOperation Apply() { 67 //at the moment we are always operating on level 0 68 ScopeList sl = ExecutionContext.Scope.SubScopes; 69 List<IntValue> intValues = new List<IntValue>(); 66 var intValues = ParameterToReduce.ActualValue; 70 67 71 foreach (var scope in sl) { 72 var variable = scope.Variables.Where(x => x.Name == ParameterToReduce.Value.ToString()); 73 if (variable.Count() == 1) { 74 intValues.Add((IntValue)variable.First().Value); 75 } 76 } 77 78 if (intValues.Count > 0) { 68 if (intValues.Count() > 0) { 79 69 int sum = intValues.Sum(x => x.Value); 80 70 -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r7288 r7322 119 119 <Compile Include="AlgorithmOperator.cs" /> 120 120 <Compile Include="AllSubScopesIntReducer.cs" /> 121 <Compile Include="ReductionTypes.cs" /> 121 122 <Compile Include="SubScopesIntReducer.cs" /> 122 123 <Compile Include="MultiOperator.cs" /> -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/SubScopesIntReducer.cs
r7288 r7322 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Common; … … 37 36 public sealed class SubScopesIntReducer : SingleSuccessorOperator { 38 37 39 public ValueLookupParameter<StringValue> ParameterToReduce {40 get { return ( ValueLookupParameter<StringValue>)Parameters["ParameterToReduce"]; }38 public ScopeTreeLookupParameter<IntValue> ParameterToReduce { 39 get { return (ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; } 41 40 } 42 41 … … 56 55 public SubScopesIntReducer() 57 56 : base() { 58 Parameters.Add(new ValueLookupParameter<StringValue>("ParameterToReduce", "Parameter to look for in the sub scopes and collect the values from", new StringValue(string.Empty)));57 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("ParameterToReduce", "The actual parameter defined by TargetParameterName")); 59 58 Parameters.Add(new ValueLookupParameter<StringValue>("TargetParameterName", "Parameter name to add the value to", new StringValue(string.Empty))); 60 59 Parameters.Add(new LookupParameter<IntValue>("TargetParameter", "The actual parameter defined by TargetParameterName")); … … 66 65 67 66 public override IOperation Apply() { 68 //at the moment we are always operating on level 0 69 ScopeList sl = ExecutionContext.Scope.SubScopes; 70 List<IntValue> intValues = new List<IntValue>(); 67 var intValues = ParameterToReduce.ActualValue; 71 68 72 foreach (var scope in sl) { 73 var variable = scope.Variables.Where(x => x.Name == ParameterToReduce.Value.ToString()); 74 if (variable.Count() == 1) { 75 intValues.Add((IntValue)variable.First().Value); 76 } 77 } 78 79 if (intValues.Count > 0) { 69 if (intValues.Count() > 0) { 80 70 int oneValue = intValues.First().Value; 81 71 if (!intValues.All(x => x.Value == oneValue)) {
Note: See TracChangeset
for help on using the changeset viewer.