Changeset 7391
- Timestamp:
- 01/22/12 15:08:47 (13 years ago)
- Location:
- branches/HiveHiveEngine
- Files:
-
- 2 added
- 4 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveHiveEngine/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
r7259 r7391 297 297 if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector; 298 298 299 foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) 299 foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) { 300 var stochasticOperator = selector as IStochasticOperator; 301 if (stochasticOperator != null) 302 stochasticOperator.RandomParameter.ActualName = "Global Random"; 300 303 EmigrantsSelectorParameter.ValidValues.Add(selector); 304 } 301 305 302 306 foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) -
branches/HiveHiveEngine/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/ParallelIslandGeneticAlgorithmMainLoop.cs
r7329 r7391 270 270 generationsReducer.Name = "Increment Generations"; 271 271 generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName; 272 generationsReducer.TargetParameter Name.Value = new StringValue("Generations");273 generationsReducer.ReductionOperation.Value = new Reduction Type(ReductionTypes.Min);274 generationsReducer.TargetOperation.Value = new TargetOperationType(TargetOperationTypes.Sum);272 generationsReducer.TargetParameter.ActualName = "Generations"; 273 generationsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Min); 274 generationsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum); 275 275 276 276 evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions"; 277 277 evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name; 278 evaluatedSolutionsReducer.TargetParameter Name.Value = new StringValue(EvaluatedSolutionsParameter.Name);279 evaluatedSolutionsReducer.ReductionOperation.Value = new Reduction Type(ReductionTypes.Sum);280 evaluatedSolutionsReducer.TargetOperation.Value = new TargetOperationType(TargetOperationTypes.Sum);278 evaluatedSolutionsReducer.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name; 279 evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 280 evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum); 281 281 282 282 emigrantsSelector.Name = "Emigrants Selector (placeholder)"; -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r7329 r7391 119 119 <Compile Include="AlgorithmOperator.cs" /> 120 120 <Compile Include="SubScopesRandomCreator.cs" /> 121 <Compile Include="TargetOperationType.cs" />122 <Compile Include="TargetOperationTypes.cs" />123 121 <Compile Include="IntDataReducer.cs" /> 124 <Compile Include="Reduction Type.cs" />125 <Compile Include="Reduction Types.cs" />122 <Compile Include="ReductionOperation.cs" /> 123 <Compile Include="ReductionOperations.cs" /> 126 124 <Compile Include="MultiOperator.cs" /> 127 125 <Compile Include="Operator.cs" /> -
branches/HiveHiveEngine/HeuristicLab.Operators/3.3/IntDataReducer.cs
r7325 r7391 36 36 get { return (ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; } 37 37 } 38 public ValueLookupParameter<StringValue> TargetParameterName { 39 get { return (ValueLookupParameter<StringValue>)Parameters["TargetParameterName"]; } 40 } 41 private LookupParameter<IntValue> TargetParameter { 38 public LookupParameter<IntValue> TargetParameter { 42 39 get { return (LookupParameter<IntValue>)Parameters["TargetParameter"]; } 43 40 } 44 public ValueParameter<Reduction Type> ReductionOperation {45 get { return (ValueParameter<Reduction Type>)Parameters["ReductionOperation"]; }41 public ValueParameter<ReductionOperation> ReductionOperation { 42 get { return (ValueParameter<ReductionOperation>)Parameters["ReductionOperation"]; } 46 43 } 47 public ValueParameter< TargetOperationType> TargetOperation {48 get { return (ValueParameter< TargetOperationType>)Parameters["TargetOperation"]; }44 public ValueParameter<ReductionOperation> TargetOperation { 45 get { return (ValueParameter<ReductionOperation>)Parameters["TargetOperation"]; } 49 46 } 50 47 #endregion … … 59 56 #region Create parameters 60 57 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))); 62 Parameters.Add(new LookupParameter<IntValue>("TargetParameter", "The actual parameter defined by TargetParameterName.")); 63 Parameters.Add(new ValueParameter<ReductionType>("ReductionOperation", "The reduction operation to perform.")); 64 Parameters.Add(new ValueParameter<TargetOperationType>("TargetOperation", "The target operation to perform.")); 58 Parameters.Add(new LookupParameter<IntValue>("TargetParameter", "The target variable in which the reduced value should be stored.")); 59 Parameters.Add(new ValueParameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameter to reduce.")); 60 Parameters.Add(new ValueParameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable.")); 65 61 #endregion 66 62 } … … 74 70 75 71 if (intValues.Count() > 0) { 76 TargetParameter.ActualName = TargetParameterName.ActualValue.Value;77 72 if (TargetParameter.ActualValue == null) TargetParameter.ActualValue = new IntValue(); 78 73 79 74 int result = 1; 80 75 switch (ReductionOperation.Value.Value) { 81 case Reduction Types.Sum:76 case ReductionOperations.Sum: 82 77 result = intValues.Sum(x => x.Value); 83 78 break; 84 case Reduction Types.Prod:79 case ReductionOperations.Prod: 85 80 intValues.ForEach(x => result *= x.Value); 86 81 break; 87 case Reduction Types.Avg:82 case ReductionOperations.Avg: 88 83 result = (int)Math.Round(intValues.Average(x => x.Value)); 89 84 break; 90 case Reduction Types.Min:85 case ReductionOperations.Min: 91 86 result = intValues.Min(x => x.Value); 92 87 break; 93 case Reduction Types.Max:88 case ReductionOperations.Max: 94 89 result = intValues.Max(x => x.Value); 95 90 break; 91 default: 92 throw new InvalidOperationException("Operation " + ReductionOperation.Value.Value + " is not supported as ReductionOperation."); 96 93 } 97 94 98 95 switch (TargetOperation.Value.Value) { 99 case TargetOperationTypes.Set:96 case ReductionOperations.Assign: 100 97 TargetParameter.ActualValue.Value = result; 101 98 break; 102 case TargetOperationTypes.Sum:99 case ReductionOperations.Sum: 103 100 TargetParameter.ActualValue.Value += result; 104 101 break; 105 case TargetOperationTypes.Prod:102 case ReductionOperations.Prod: 106 103 if (TargetParameter.ActualValue.Value == 0) TargetParameter.ActualValue.Value = 1; 107 104 TargetParameter.ActualValue.Value *= result; 108 105 break; 106 default: 107 throw new InvalidOperationException("Operation " + TargetOperation.Value.Value + " is not supported as TargetOperation."); 109 108 } 110 109 }
Note: See TracChangeset
for help on using the changeset viewer.