Changeset 7325 for branches/HiveHiveEngine
- Timestamp:
- 01/13/12 14:21:43 (13 years ago)
- Location:
- branches/HiveHiveEngine
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveHiveEngine/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/ParallelIslandGeneticAlgorithmMainLoop.cs
r7323 r7325 271 271 generationsReducer.TargetParameterName.Value = new StringValue("Generations"); 272 272 generationsReducer.ReductionOperation.Value = new ReductionType(ReductionTypes.Min); 273 generationsReducer.TargetOperation.Value = new TargetOperationType(TargetOperationTypes.Sum); 273 274 274 275 evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions"; … … 276 277 evaluatedSolutionsReducer.TargetParameterName.Value = new StringValue(EvaluatedSolutionsParameter.Name); 277 278 evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionType(ReductionTypes.Sum); 279 evaluatedSolutionsReducer.TargetOperation.Value = new TargetOperationType(TargetOperationTypes.Sum); 278 280 279 281 emigrantsSelector.Name = "Emigrants Selector (placeholder)"; -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r7323 r7325 118 118 <Compile Include="Assigner.cs" /> 119 119 <Compile Include="AlgorithmOperator.cs" /> 120 <Compile Include="TargetOperationType.cs" /> 121 <Compile Include="TargetOperationTypes.cs" /> 120 122 <Compile Include="IntDataReducer.cs" /> 121 123 <Compile Include="ReductionType.cs" /> -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/IntDataReducer.cs
r7323 r7325 32 32 [StorableClass] 33 33 public sealed class IntDataReducer : SingleSuccessorOperator { 34 #region Parameter Properties 34 35 public ScopeTreeLookupParameter<IntValue> ParameterToReduce { 35 36 get { return (ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; } … … 44 45 get { return (ValueParameter<ReductionType>)Parameters["ReductionOperation"]; } 45 46 } 47 public ValueParameter<TargetOperationType> TargetOperation { 48 get { return (ValueParameter<TargetOperationType>)Parameters["TargetOperation"]; } 49 } 50 #endregion 46 51 47 52 [StorableConstructor] … … 52 57 public IntDataReducer() 53 58 : base() { 54 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("ParameterToReduce", "The actual parameter defined by TargetParameterName.")); 55 Parameters.Add(new ValueLookupParameter<StringValue>("TargetParameterName", "Parameter name to add the value to.", new StringValue(string.Empty))); 59 #region Create parameters 60 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("ParameterToReduce", "The parameter on which the reduction operation should be applied.")); 61 Parameters.Add(new ValueLookupParameter<StringValue>("TargetParameterName", "Parameter to store the result in.", new StringValue(string.Empty))); 56 62 Parameters.Add(new LookupParameter<IntValue>("TargetParameter", "The actual parameter defined by TargetParameterName.")); 57 63 Parameters.Add(new ValueParameter<ReductionType>("ReductionOperation", "The reduction operation to perform.")); 64 Parameters.Add(new ValueParameter<TargetOperationType>("TargetOperation", "The target operation to perform.")); 65 #endregion 58 66 } 59 67 … … 69 77 if (TargetParameter.ActualValue == null) TargetParameter.ActualValue = new IntValue(); 70 78 71 int result ;79 int result = 1; 72 80 switch (ReductionOperation.Value.Value) { 73 81 case ReductionTypes.Sum: … … 75 83 break; 76 84 case ReductionTypes.Prod: 77 result = 1;78 85 intValues.ForEach(x => result *= x.Value); 79 86 break; … … 87 94 result = intValues.Max(x => x.Value); 88 95 break; 89 default:90 throw new ArgumentException("Unknown ReductionType: " + ReductionOperation.Value.Value);91 96 } 92 //TODO: there should be at least a Set, Add and Mul operation 93 TargetParameter.ActualValue.Value += result; 97 98 switch (TargetOperation.Value.Value) { 99 case TargetOperationTypes.Set: 100 TargetParameter.ActualValue.Value = result; 101 break; 102 case TargetOperationTypes.Sum: 103 TargetParameter.ActualValue.Value += result; 104 break; 105 case TargetOperationTypes.Prod: 106 if (TargetParameter.ActualValue.Value == 0) TargetParameter.ActualValue.Value = 1; 107 TargetParameter.ActualValue.Value *= result; 108 break; 109 } 94 110 } 95 111 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.