Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/26/14 11:06:38 (9 years ago)
Author:
pfleck
Message:

#2269 Implemented LayerUpdator.

  • Added First/LastSubScopeProcessor.
  • Added two Calculators because ExpressionCalculator does not support required features yet.
  • Added some wiring.
  • Small bugfixes and refactorings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs

    r11585 r11586  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3233  [Item("EldersEmigrator", "Moves Individuals which are too old for its current layer up to the next layer.")]
    3334  [StorableClass]
    34   public class EldersEmigrator : AlgorithmOperator {
     35  public sealed class EldersEmigrator : AlgorithmOperator {
     36
     37    public IValueLookupParameter<BoolValue> MaximizationParameter {
     38      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     39    }
     40    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     41      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     42    }
     43
     44    public SolutionsCreator SolutionsCreator {
     45      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
     46    }
    3547
    3648    [StorableConstructor]
     
    4456    public EldersEmigrator()
    4557      : base() {
     58      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     59      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
     60
    4661      var selectorProsessor = new UniformSubScopesProcessor();
    4762      var eldersSelector = new EldersSelector();
     
    5065      var mergingReducer = new MergingReducer();
    5166      var subScopesCounter = new SubScopesCounter();
    52       var countCalculator = new ExpressionCalculator() { Name = "Count = Min(NumSubScopes, PopulationSize)" };
     67      // TODO: if expression calculator supports int, use expression calculator
     68      var countCalculator = new MergingReducerCalculator() { Name = "NumSubScopes = Min(NumSubScopes, PopulationSize)" };
     69      //var countCalculator = new ExpressionCalculator() { Name = "NumSubScopes = Min(NumSubScopes, PopulationSize)" };
    5370      var bestSelector = new BestSelector();
    5471      var rightReducer = new RightReducer();
     
    7390      subScopesCounter.Successor = countCalculator;
    7491
    75       countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize"));
    76       countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("NumSubScopes"));
    77       countCalculator.ExpressionParameter.Value = new StringValue("NumSubScopes PopulationSize NumSubScopes < PopulationSize if");
    78       countCalculator.ExpressionResultParameter.ActualName = "Count";
     92      //countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize"));
     93      //countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("NumSubScopes"));
     94      //countCalculator.ExpressionParameter.Value = new StringValue("NumSubScopes PopulationSize NumSubScopes PopulationSize < if");
     95      //countCalculator.ExpressionResultParameter.ActualName = "NumSubScopes";
    7996      countCalculator.Successor = bestSelector;
    8097
    81       bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "Count";
     98      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "NumSubScopes";
     99      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
     100      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
    82101      bestSelector.Successor = rightReducer;
    83102
Note: See TracChangeset for help on using the changeset viewer.