Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/12 15:08:47 (13 years ago)
Author:
ascheibe
Message:

#1745 removed target operations, use reduction operations instead

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  
    297297      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
    298298
    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";
    300303        EmigrantsSelectorParameter.ValidValues.Add(selector);
     304      }
    301305
    302306      foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name))
  • branches/HiveHiveEngine/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/ParallelIslandGeneticAlgorithmMainLoop.cs

    r7329 r7391  
    270270      generationsReducer.Name = "Increment Generations";
    271271      generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName;
    272       generationsReducer.TargetParameterName.Value = new StringValue("Generations");
    273       generationsReducer.ReductionOperation.Value = new ReductionType(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);
    275275
    276276      evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions";
    277277      evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
    278       evaluatedSolutionsReducer.TargetParameterName.Value = new StringValue(EvaluatedSolutionsParameter.Name);
    279       evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionType(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);
    281281
    282282      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
  • branches/HiveHiveEngine/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r7329 r7391  
    119119    <Compile Include="AlgorithmOperator.cs" />
    120120    <Compile Include="SubScopesRandomCreator.cs" />
    121     <Compile Include="TargetOperationType.cs" />
    122     <Compile Include="TargetOperationTypes.cs" />
    123121    <Compile Include="IntDataReducer.cs" />
    124     <Compile Include="ReductionType.cs" />
    125     <Compile Include="ReductionTypes.cs" />
     122    <Compile Include="ReductionOperation.cs" />
     123    <Compile Include="ReductionOperations.cs" />
    126124    <Compile Include="MultiOperator.cs" />
    127125    <Compile Include="Operator.cs" />
  • branches/HiveHiveEngine/HeuristicLab.Operators/3.3/IntDataReducer.cs

    r7325 r7391  
    3636      get { return (ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; }
    3737    }
    38     public ValueLookupParameter<StringValue> TargetParameterName {
    39       get { return (ValueLookupParameter<StringValue>)Parameters["TargetParameterName"]; }
    40     }
    41     private LookupParameter<IntValue> TargetParameter {
     38    public LookupParameter<IntValue> TargetParameter {
    4239      get { return (LookupParameter<IntValue>)Parameters["TargetParameter"]; }
    4340    }
    44     public ValueParameter<ReductionType> ReductionOperation {
    45       get { return (ValueParameter<ReductionType>)Parameters["ReductionOperation"]; }
     41    public ValueParameter<ReductionOperation> ReductionOperation {
     42      get { return (ValueParameter<ReductionOperation>)Parameters["ReductionOperation"]; }
    4643    }
    47     public ValueParameter<TargetOperationType> TargetOperation {
    48       get { return (ValueParameter<TargetOperationType>)Parameters["TargetOperation"]; }
     44    public ValueParameter<ReductionOperation> TargetOperation {
     45      get { return (ValueParameter<ReductionOperation>)Parameters["TargetOperation"]; }
    4946    }
    5047    #endregion
     
    5956      #region Create parameters
    6057      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."));
    6561      #endregion
    6662    }
     
    7470
    7571      if (intValues.Count() > 0) {
    76         TargetParameter.ActualName = TargetParameterName.ActualValue.Value;
    7772        if (TargetParameter.ActualValue == null) TargetParameter.ActualValue = new IntValue();
    7873
    7974        int result = 1;
    8075        switch (ReductionOperation.Value.Value) {
    81           case ReductionTypes.Sum:
     76          case ReductionOperations.Sum:
    8277            result = intValues.Sum(x => x.Value);
    8378            break;
    84           case ReductionTypes.Prod:
     79          case ReductionOperations.Prod:
    8580            intValues.ForEach(x => result *= x.Value);
    8681            break;
    87           case ReductionTypes.Avg:
     82          case ReductionOperations.Avg:
    8883            result = (int)Math.Round(intValues.Average(x => x.Value));
    8984            break;
    90           case ReductionTypes.Min:
     85          case ReductionOperations.Min:
    9186            result = intValues.Min(x => x.Value);
    9287            break;
    93           case ReductionTypes.Max:
     88          case ReductionOperations.Max:
    9489            result = intValues.Max(x => x.Value);
    9590            break;
     91          default:
     92            throw new InvalidOperationException("Operation " + ReductionOperation.Value.Value + " is not supported as ReductionOperation.");
    9693        }
    9794
    9895        switch (TargetOperation.Value.Value) {
    99           case TargetOperationTypes.Set:
     96          case ReductionOperations.Assign:
    10097            TargetParameter.ActualValue.Value = result;
    10198            break;
    102           case TargetOperationTypes.Sum:
     99          case ReductionOperations.Sum:
    103100            TargetParameter.ActualValue.Value += result;
    104101            break;
    105           case TargetOperationTypes.Prod:
     102          case ReductionOperations.Prod:
    106103            if (TargetParameter.ActualValue.Value == 0) TargetParameter.ActualValue.Value = 1;
    107104            TargetParameter.ActualValue.Value *= result;
    108105            break;
     106          default:
     107            throw new InvalidOperationException("Operation " + TargetOperation.Value.Value + " is not supported as TargetOperation.");
    109108        }
    110109      }
Note: See TracChangeset for help on using the changeset viewer.