Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12045


Ignore:
Timestamp:
02/20/15 11:52:08 (9 years ago)
Author:
pfleck
Message:

#2269 Added a parameter in the MatingPoolCreator which controls the percentage of individuals used from the layers below.

Location:
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3
Files:
3 edited

Legend:

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

    r12040 r12045  
    9090      get { return (IValueParameter<IntValue>)Parameters["MatingPoolRange"]; }
    9191    }
     92    private IValueParameter<PercentValue> MatingPoolSelectionPercentageParameter {
     93      get { return (IValueLookupParameter<PercentValue>)Parameters["MatingPoolSelectionPercentage"]; }
     94    }
    9295    public IConstrainedValueParameter<ISelector> SelectorParameter {
    9396      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
     
    159162      get { return MatingPoolRangeParameter.Value; }
    160163      set { MatingPoolRangeParameter.Value = value; }
     164    }
     165    public PercentValue MatingPoolSelectionPercentage {
     166      get { return MatingPoolSelectionPercentageParameter.Value; }
     167      set { MatingPoolSelectionPercentageParameter.Value = value; }
    161168    }
    162169    public ISelector Selector {
     
    230237      Parameters.Add(new ValueParameter<ReductionOperation>("AgeInheritance", "The operator for determining the age of an offspring based the parents' age.", new ReductionOperation(ReductionOperations.Max)) { Hidden = true });
    231238      Parameters.Add(new ValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true });
     239      Parameters.Add(new ValueParameter<PercentValue>("MatingPoolSelectionPercentage", "Percentage of the previous layers used for creating a mating pool.", new PercentValue(1.0, restrictToUnitInterval: true)) { Hidden = true });
    232240      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    233241      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
     
    421429    }
    422430    private void ParameterizeMainLoop() {
     431      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     432      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    423433      MainLoop.MainOperator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    424434      MainLoop.MainOperator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    429439    }
    430440    private void ParameterizeSelectors() {
    431 
    432441      foreach (var selector in SelectorParameter.ValidValues) {
    433442        selector.CopySelected = new BoolValue(true);
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs

    r12035 r12045  
    3838  public sealed class AlpsGeneticAlgorithmMainLoop : AlgorithmOperator {
    3939    #region Parameter Properties
     40    public ValueLookupParameter<BoolValue> MaximizationParameter {
     41      get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     42    }
     43    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
     44      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     45    }
    4046    public ILookupParameter<IntValue> MaximumGenerationsParameter {
    4147      get { return (ILookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
     
    6975    public AlpsGeneticAlgorithmMainLoop()
    7076      : base() {
     77      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     78      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
    7179      Parameters.Add(new LookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that the algorithm should process."));
    7280      Parameters.Add(new LookupParameter<IOperator>("Analyzer", "The operator used to the analyze all individuals."));
     
    7987      var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
    8088      var resultsCollector = new ResultsCollector();
     89      var matingPoolPreProcessor = new UniformSubScopesProcessor() { Name = "MatingPoolPreProcessor" };
     90      var matingPoolPreSorter = new SubScopesSorter() { Name = "MatingPoolPreSorter" };
    8191      var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" };
    8292      var matingPoolProcessor = new LayerUniformSubScopesProcessor();
     
    116126      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("OpenLayers"));
    117127      resultsCollector.CopyValue = new BoolValue(false);
    118       resultsCollector.Successor = matingPoolCreator;
     128      resultsCollector.Successor = matingPoolPreProcessor;
     129
     130      matingPoolPreProcessor.Operator = matingPoolPreSorter;
     131      matingPoolPreProcessor.Successor = matingPoolCreator;
     132
     133      matingPoolPreSorter.ValueParameter.ActualName = QualityParameter.Name;
     134      matingPoolPreSorter.DescendingParameter.ActualName = MaximizationParameter.Name;
    119135
    120136      matingPoolCreator.Successor = matingPoolProcessor;
     
    157173
    158174      terminateBranch.ConditionParameter.ActualName = "TerminateGenerations";
    159       terminateBranch.FalseBranch = matingPoolCreator;
     175      terminateBranch.FalseBranch = matingPoolPreProcessor;
    160176    }
    161177
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/MatingPoolCreator.cs

    r12040 r12045  
    2121
    2222using System;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3334  public sealed class MatingPoolCreator : SingleSuccessorOperator {
    3435
    35     private ILookupParameter<IntValue> MatingPoolRangeParameter {
     36    public ILookupParameter<IntValue> MatingPoolRangeParameter {
    3637      get { return (ILookupParameter<IntValue>)Parameters["MatingPoolRange"]; }
     38    }
     39    public ILookupParameter<PercentValue> MatingPoolSelectionPercentageParameter {
     40      get { return (ILookupParameter<PercentValue>)Parameters["MatingPoolSelectionPercentage"]; }
    3741    }
    3842
     
    4852      : base() {
    4953      Parameters.Add(new LookupParameter<IntValue>("MatingPoolRange"));
     54      Parameters.Add(new LookupParameter<PercentValue>("MatingPoolSelectionPercentage"));
    5055    }
    5156
     
    5358      var layers = ExecutionContext.Scope.SubScopes;
    5459      int range = MatingPoolRangeParameter.ActualValue.Value;
     60      double percentage = MatingPoolSelectionPercentageParameter.ActualValue.Value;
    5561
    5662      for (int layer = layers.Count - 1; layer > 0; layer--) {
     
    5864        for (int n = 1; (n <= range) && (layer - n >= 0); n++) {
    5965          var prevLayerScope = layers[layer - n];
    60           foreach (var individual in prevLayerScope.SubScopes) {
     66          var individuals = prevLayerScope.SubScopes;
     67          foreach (var individual in individuals.Take((int)(individuals.Count * percentage))) {
    6168            layerScope.SubScopes.Add((IScope)individual.Clone(new Cloner()));
    6269          }
Note: See TracChangeset for help on using the changeset viewer.