Changeset 13402


Ignore:
Timestamp:
11/25/15 17:50:52 (4 years ago)
Author:
pfleck
Message:

#2527 Implemented ALPS-OSGA on the base of the AlpsGeneticAlgorithm and and the OffspringSelectionGeneticAlgorithmMainOperator.

Location:
trunk/sources/HeuristicLab.Algorithms.ALPS/3.3
Files:
1 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithm.cs

    r13326 r13402  
    3838
    3939namespace HeuristicLab.Algorithms.ALPS {
    40   [Item("ALPS Genetic Algorithm", "A genetic algorithm within an age-layered population structure as described in Gregory S. Hornby. 2006. ALPS: the age-layered population structure for reducing the problem of premature convergence. In Proceedings of the 8th annual conference on Genetic and evolutionary computation (GECCO '06). 815-822.")]
    41   [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 160)]
     40  [Item("ALPS OffspringSelection Genetic Algorithm", "An offspring selection genetic algorithm within an age-layered population structure.")]
     41  [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 162)]
    4242  [StorableClass]
    43   public sealed class AlpsGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
     43  public sealed class AlpsOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    4444    public string Filename { get; set; }
    4545
     
    5555
    5656    #region Parameter Properties
    57     private IValueParameter<IntValue> SeedParameter {
    58       get { return (IValueParameter<IntValue>)Parameters["Seed"]; }
    59     }
    60     private IValueParameter<BoolValue> SetSeedRandomlyParameter {
    61       get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
     57    private IFixedValueParameter<IntValue> SeedParameter {
     58      get { return (IFixedValueParameter<IntValue>)Parameters["Seed"]; }
     59    }
     60    private IFixedValueParameter<BoolValue> SetSeedRandomlyParameter {
     61      get { return (IFixedValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    6262    }
    6363
     
    6969    }
    7070
    71     private IValueParameter<IntValue> NumberOfLayersParameter {
    72       get { return (IValueParameter<IntValue>)Parameters["NumberOfLayers"]; }
    73     }
    74     private IValueParameter<IntValue> PopulationSizeParameter {
    75       get { return (IValueParameter<IntValue>)Parameters["PopulationSize"]; }
     71    private IFixedValueParameter<IntValue> NumberOfLayersParameter {
     72      get { return (IFixedValueParameter<IntValue>)Parameters["NumberOfLayers"]; }
     73    }
     74    private IFixedValueParameter<IntValue> PopulationSizeParameter {
     75      get { return (IFixedValueParameter<IntValue>)Parameters["PopulationSize"]; }
    7676    }
    7777
     
    8585      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
    8686    }
    87     private IValueParameter<PercentValue> MutationProbabilityParameter {
    88       get { return (IValueParameter<PercentValue>)Parameters["MutationProbability"]; }
    89     }
    90     private IValueParameter<IntValue> ElitesParameter {
    91       get { return (IValueParameter<IntValue>)Parameters["Elites"]; }
     87    private IFixedValueParameter<PercentValue> MutationProbabilityParameter {
     88      get { return (IFixedValueParameter<PercentValue>)Parameters["MutationProbability"]; }
     89    }
     90    private IFixedValueParameter<IntValue> ElitesParameter {
     91      get { return (IFixedValueParameter<IntValue>)Parameters["Elites"]; }
    9292    }
    9393    private IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
    9494      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
    9595    }
    96     private IValueParameter<BoolValue> PlusSelectionParameter {
    97       get { return (IValueParameter<BoolValue>)Parameters["PlusSelection"]; }
    98     }
    99 
    100     private IValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter {
    101       get { return (IValueParameter<EnumValue<AgingScheme>>)Parameters["AgingScheme"]; }
    102     }
    103     private IValueParameter<IntValue> AgeGapParameter {
    104       get { return (IValueParameter<IntValue>)Parameters["AgeGap"]; }
    105     }
    106     private IValueParameter<DoubleValue> AgeInheritanceParameter {
    107       get { return (IValueParameter<DoubleValue>)Parameters["AgeInheritance"]; }
    108     }
    109     private IValueParameter<IntArray> AgeLimitsParameter {
    110       get { return (IValueParameter<IntArray>)Parameters["AgeLimits"]; }
    111     }
    112 
    113     private IValueParameter<IntValue> MatingPoolRangeParameter {
    114       get { return (IValueParameter<IntValue>)Parameters["MatingPoolRange"]; }
    115     }
    116     private IValueParameter<BoolValue> ReduceToPopulationSizeParameter {
    117       get { return (IValueParameter<BoolValue>)Parameters["ReduceToPopulationSize"]; }
    118     }
    119 
    120     private IValueParameter<MultiTerminator> TerminatorParameter {
    121       get { return (IValueParameter<MultiTerminator>)Parameters["Terminator"]; }
     96
     97    private IFixedValueParameter<DoubleValue> SuccessRatioParameter {
     98      get { return (IFixedValueParameter<DoubleValue>)Parameters["SuccessRatio"]; }
     99    }
     100    private IFixedValueParameter<DoubleValue> ComparisonFactorParameter {
     101      get { return (IFixedValueParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
     102    }
     103    private IFixedValueParameter<DoubleValue> MaximumSelectionPressureParameter {
     104      get { return (IFixedValueParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
     105    }
     106    private IFixedValueParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
     107      get { return (IFixedValueParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
     108    }
     109    private IFixedValueParameter<IntValue> SelectedParentsParameter {
     110      get { return (IFixedValueParameter<IntValue>)Parameters["SelectedParents"]; }
     111    }
     112    private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter {
     113      get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
     114    }
     115
     116    private IFixedValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter {
     117      get { return (IFixedValueParameter<EnumValue<AgingScheme>>)Parameters["AgingScheme"]; }
     118    }
     119    private IFixedValueParameter<IntValue> AgeGapParameter {
     120      get { return (IFixedValueParameter<IntValue>)Parameters["AgeGap"]; }
     121    }
     122    private IFixedValueParameter<DoubleValue> AgeInheritanceParameter {
     123      get { return (IFixedValueParameter<DoubleValue>)Parameters["AgeInheritance"]; }
     124    }
     125    private IFixedValueParameter<IntArray> AgeLimitsParameter {
     126      get { return (IFixedValueParameter<IntArray>)Parameters["AgeLimits"]; }
     127    }
     128
     129    private IFixedValueParameter<IntValue> MatingPoolRangeParameter {
     130      get { return (IFixedValueParameter<IntValue>)Parameters["MatingPoolRange"]; }
     131    }
     132    private IFixedValueParameter<BoolValue> ReduceToPopulationSizeParameter {
     133      get { return (IFixedValueParameter<BoolValue>)Parameters["ReduceToPopulationSize"]; }
     134    }
     135
     136    private IFixedValueParameter<MultiTerminator> TerminatorParameter {
     137      get { return (IFixedValueParameter<MultiTerminator>)Parameters["Terminator"]; }
    122138    }
    123139    #endregion
    124140
    125141    #region Properties
    126     public IntValue Seed {
    127       get { return SeedParameter.Value; }
    128       set { SeedParameter.Value = value; }
    129     }
    130     public BoolValue SetSeedRandomly {
    131       get { return SetSeedRandomlyParameter.Value; }
    132       set { SetSeedRandomlyParameter.Value = value; }
     142    public int Seed {
     143      get { return SeedParameter.Value.Value; }
     144      set { SeedParameter.Value.Value = value; }
     145    }
     146    public bool SetSeedRandomly {
     147      get { return SetSeedRandomlyParameter.Value.Value; }
     148      set { SetSeedRandomlyParameter.Value.Value = value; }
    133149    }
    134150
     
    140156    }
    141157
    142     public IntValue NumberOfLayers {
    143       get { return NumberOfLayersParameter.Value; }
    144       set { NumberOfLayersParameter.Value = value; }
    145     }
    146     public IntValue PopulationSize {
    147       get { return PopulationSizeParameter.Value; }
    148       set { PopulationSizeParameter.Value = value; }
     158    public int NumberOfLayers {
     159      get { return NumberOfLayersParameter.Value.Value; }
     160      set { NumberOfLayersParameter.Value.Value = value; }
     161    }
     162    public int PopulationSize {
     163      get { return PopulationSizeParameter.Value.Value; }
     164      set { PopulationSizeParameter.Value.Value = value; }
    149165    }
    150166
     
    161177      set { MutatorParameter.Value = value; }
    162178    }
    163     public PercentValue MutationProbability {
    164       get { return MutationProbabilityParameter.Value; }
    165       set { MutationProbabilityParameter.Value = value; }
    166     }
    167     public IntValue Elites {
    168       get { return ElitesParameter.Value; }
    169       set { ElitesParameter.Value = value; }
     179    public double MutationProbability {
     180      get { return MutationProbabilityParameter.Value.Value; }
     181      set { MutationProbabilityParameter.Value.Value = value; }
     182    }
     183    public int Elites {
     184      get { return ElitesParameter.Value.Value; }
     185      set { ElitesParameter.Value.Value = value; }
    170186    }
    171187    public bool ReevaluteElites {
     
    173189      set { ReevaluateElitesParameter.Value.Value = value; }
    174190    }
    175     public bool PlusSelection {
    176       get { return PlusSelectionParameter.Value.Value; }
    177       set { PlusSelectionParameter.Value.Value = value; }
    178     }
    179 
    180     public EnumValue<AgingScheme> AgingScheme {
    181       get { return AgingSchemeParameter.Value; }
    182       set { AgingSchemeParameter.Value = value; }
    183     }
    184     public IntValue AgeGap {
    185       get { return AgeGapParameter.Value; }
    186       set { AgeGapParameter.Value = value; }
    187     }
    188     public DoubleValue AgeInheritance {
    189       get { return AgeInheritanceParameter.Value; }
    190       set { AgeInheritanceParameter.Value = value; }
     191
     192    public double SuccessRatio {
     193      get { return SuccessRatioParameter.Value.Value; }
     194      set { SuccessRatioParameter.Value.Value = value; }
     195    }
     196    public double ComparisonFactor {
     197      get { return ComparisonFactorParameter.Value.Value; }
     198      set { ComparisonFactorParameter.Value.Value = value; }
     199    }
     200    public double MaximumSelectionPressure {
     201      get { return MaximumSelectionPressureParameter.Value.Value; }
     202      set { MaximumSelectionPressureParameter.Value.Value = value; }
     203    }
     204    public bool OffspringSelectionBeforeMutation {
     205      get { return OffspringSelectionBeforeMutationParameter.Value.Value; }
     206      set { OffspringSelectionBeforeMutationParameter.Value.Value = value; }
     207    }
     208    public int SelectedParents {
     209      get { return SelectedParentsParameter.Value.Value; }
     210      set { SelectedParentsParameter.Value.Value = value; }
     211    }
     212    public bool FillPopulationWithParents {
     213      get { return FillPopulationWithParentsParameter.Value.Value; }
     214      set { FillPopulationWithParentsParameter.Value.Value = value; }
     215    }
     216
     217    public AgingScheme AgingScheme {
     218      get { return AgingSchemeParameter.Value.Value; }
     219      set { AgingSchemeParameter.Value.Value = value; }
     220    }
     221    public int AgeGap {
     222      get { return AgeGapParameter.Value.Value; }
     223      set { AgeGapParameter.Value.Value = value; }
     224    }
     225    public double AgeInheritance {
     226      get { return AgeInheritanceParameter.Value.Value; }
     227      set { AgeInheritanceParameter.Value.Value = value; }
    191228    }
    192229    public IntArray AgeLimits {
    193230      get { return AgeLimitsParameter.Value; }
    194       set { AgeLimitsParameter.Value = value; }
    195     }
    196 
    197     public IntValue MatingPoolRange {
    198       get { return MatingPoolRangeParameter.Value; }
    199       set { MatingPoolRangeParameter.Value = value; }
     231      set {
     232        AgeLimits.Length = value.Length;
     233        for (int i = 0; i < value.Length; i++)
     234          AgeLimits[i] = value[i];
     235      }
     236    }
     237
     238    public int MatingPoolRange {
     239      get { return MatingPoolRangeParameter.Value.Value; }
     240      set { MatingPoolRangeParameter.Value.Value = value; }
    200241    }
    201242
     
    214255      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
    215256    }
    216     private AlpsGeneticAlgorithmMainLoop MainLoop {
    217       get { return OperatorGraph.Iterate().OfType<AlpsGeneticAlgorithmMainLoop>().First(); }
     257    private AlpsOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
     258      get { return OperatorGraph.Iterate().OfType<AlpsOffspringSelectionGeneticAlgorithmMainLoop>().First(); }
    218259    }
    219260    #endregion
     
    232273    [Storable]
    233274    private AgeDistributionAnalyzer layerAgeDistributionAnalyzer;
     275    [Storable]
     276    private ValueAnalyzer selectionPressureAnalyzer;
     277    [Storable]
     278    private ValueAnalyzer layerSelectionPressureAnalyzer;
     279    [Storable]
     280    private ValueAnalyzer currentSuccessRatioAnalyzer;
    234281    #endregion
    235282
     
    237284    [Storable]
    238285    private ComparisonTerminator<IntValue> generationsTerminator;
     286    //[Storable]
     287    //private ComparisonTerminator<DoubleValue> selectionPressureTerminator;
    239288    [Storable]
    240289    private ComparisonTerminator<IntValue> evaluationsTerminator;
     
    247296    #region Constructors
    248297    [StorableConstructor]
    249     private AlpsGeneticAlgorithm(bool deserializing)
     298    private AlpsOffspringSelectionGeneticAlgorithm(bool deserializing)
    250299      : base(deserializing) { }
    251300    [StorableHook(HookType.AfterDeserialization)]
     
    253302      Initialize();
    254303    }
    255     private AlpsGeneticAlgorithm(AlpsGeneticAlgorithm original, Cloner cloner)
     304    private AlpsOffspringSelectionGeneticAlgorithm(AlpsOffspringSelectionGeneticAlgorithm original, Cloner cloner)
    256305      : base(original, cloner) {
    257306      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
     
    261310      ageDistributionAnalyzer = cloner.Clone(original.ageDistributionAnalyzer);
    262311      layerAgeDistributionAnalyzer = cloner.Clone(original.layerAgeDistributionAnalyzer);
     312      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
     313      layerSelectionPressureAnalyzer = cloner.Clone(original.layerSelectionPressureAnalyzer);
     314      currentSuccessRatioAnalyzer = cloner.Clone(original.currentSuccessRatioAnalyzer);
    263315      generationsTerminator = cloner.Clone(original.generationsTerminator);
     316      //selectionPressureTerminator = cloner.Clone(original.selectionPressureTerminator);
    264317      evaluationsTerminator = cloner.Clone(original.evaluationsTerminator);
    265318      qualityTerminator = cloner.Clone(original.qualityTerminator);
     
    268321    }
    269322    public override IDeepCloneable Clone(Cloner cloner) {
    270       return new AlpsGeneticAlgorithm(this, cloner);
    271     }
    272     public AlpsGeneticAlgorithm()
     323      return new AlpsOffspringSelectionGeneticAlgorithm(this, cloner);
     324    }
     325    public AlpsOffspringSelectionGeneticAlgorithm()
    273326      : base() {
    274327      #region Add parameters
    275       Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    276       Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
     328      Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
     329      Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    277330
    278331      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze all individuals from all layers combined.", new MultiAnalyzer()));
    279332      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));
    280333
    281       Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
    282       Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer.", new IntValue(100)));
     334      Parameters.Add(new FixedValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
     335      Parameters.Add(new FixedValueParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer.", new IntValue(100)));
    283336
    284337      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    285338      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    286339      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    287       Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    288       Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
     340      Parameters.Add(new FixedValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
     341      Parameters.Add(new FixedValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    289342      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
    290       Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.", new BoolValue(false)));
    291 
    292       Parameters.Add(new ValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial)));
    293       Parameters.Add(new ValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
    294       Parameters.Add(new ValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1.0)) { Hidden = true });
    295       Parameters.Add(new ValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) { Hidden = true });
    296 
    297       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 });
    298       Parameters.Add(new ValueParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize", new BoolValue(true)) { Hidden = true });
    299 
    300       Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
     343
     344      Parameters.Add(new FixedValueParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
     345      Parameters.Add(new FixedValueParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1].", new DoubleValue(1)));
     346      Parameters.Add(new FixedValueParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
     347      Parameters.Add(new FixedValueParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
     348      Parameters.Add(new FixedValueParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200)));
     349      Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true });
     350
     351      Parameters.Add(new FixedValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial)));
     352      Parameters.Add(new FixedValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
     353      Parameters.Add(new FixedValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1.0)) { Hidden = true });
     354      Parameters.Add(new FixedValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) { Hidden = true });
     355
     356      Parameters.Add(new FixedValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true });
     357      Parameters.Add(new FixedValueParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize", new BoolValue(true)) { Hidden = true });
     358
     359      Parameters.Add(new FixedValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
    301360      #endregion
    302361
     
    313372      var initializeGlobalEvaluatedSolutions = new DataReducer() { Name = "Initialize EvaluatedSolutions" };
    314373      var resultsCollector = new ResultsCollector();
    315       var mainLoop = new AlpsGeneticAlgorithmMainLoop();
     374      var mainLoop = new AlpsOffspringSelectionGeneticAlgorithmMainLoop();
    316375      #endregion
    317376
     
    373432      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
    374433      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
    375       mainLoop.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
     434      mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
     435      mainLoop.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
     436      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     437      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
     438      mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
    376439      mainLoop.AgeParameter.ActualName = "Age";
    377440      mainLoop.AgeGapParameter.ActualName = AgeGapParameter.Name;
     
    383446      #endregion
    384447
    385       #region Set selectors
     448      #region Set operators
    386449      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
    387450        SelectorParameter.ValidValues.Add(selector);
     
    400463      ageDistributionAnalyzer = new AgeDistributionAnalyzer();
    401464      layerAgeDistributionAnalyzer = new AgeDistributionAnalyzer();
     465      selectionPressureAnalyzer = new ValueAnalyzer();
     466      layerSelectionPressureAnalyzer = new ValueAnalyzer();
     467      currentSuccessRatioAnalyzer = new ValueAnalyzer();
    402468      #endregion
    403469
    404470      #region Create terminators
    405471      generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" };
     472      //selectionPressureTerminator = new ComparisonTerminator<DoubleValue>("SelectionPressure", ComparisonType.Less, MaximumSelectionPressureParameter);
    406473      evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };
    407474      qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" };
     
    503570    }
    504571
    505     private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
    506       AgeGap.ValueChanged += AgeGap_ValueChanged;
    507       ParameterizeAgeLimits();
    508     }
    509572    private void AgeGap_ValueChanged(object sender, EventArgs e) {
    510573      ParameterizeAgeLimits();
    511574    }
    512     private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
    513       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    514       ParameterizeAgeLimits();
    515     }
    516575    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
    517       ParameterizeAgeLimits();
    518     }
    519     private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
    520       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
    521576      ParameterizeAgeLimits();
    522577    }
     
    552607        Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    553608
    554       NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
    555       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
     609      NumberOfLayersParameter.Value.ValueChanged += NumberOfLayers_ValueChanged;
    556610
    557611      Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
    558612      LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
    559613
    560       AgeGapParameter.ValueChanged += AgeGapParameter_ValueChanged;
    561       AgeGap.ValueChanged += AgeGap_ValueChanged;
    562       AgingSchemeParameter.ValueChanged += AgingSchemeParameter_ValueChanged;
    563       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    564 
    565       qualityAnalyzer.CurrentBestQualityParameter.NameChanged += new EventHandler(QualityAnalyzer_CurrentBestQualityParameter_NameChanged);
     614      AgeGapParameter.Value.ValueChanged += AgeGap_ValueChanged;
     615      AgingSchemeParameter.Value.ValueChanged += AgingScheme_ValueChanged;
     616
     617      qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged;
    566618    }
    567619    private void ParameterizeSolutionsCreator() {
     
    581633      layerQualityAnalyzer.ResultsParameter.Hidden = true;
    582634      layerQualityAnalyzer.QualityParameter.Depth = 1;
     635      selectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
     636      selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
     637      selectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
     638      selectionPressureAnalyzer.ValueParameter.Depth = 1;
     639      selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
     640      layerSelectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
     641      layerSelectionPressureAnalyzer.ResultsParameter.ActualName = "LayerResults";
     642      layerSelectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
     643      layerSelectionPressureAnalyzer.ValueParameter.Depth = 0;
     644      layerSelectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
     645      currentSuccessRatioAnalyzer.Name = "CurrentSuccessRatio Analyzer";
     646      currentSuccessRatioAnalyzer.ResultsParameter.ActualName = "Results";
     647      currentSuccessRatioAnalyzer.ValueParameter.ActualName = "CurrentSuccessRatio";
     648      currentSuccessRatioAnalyzer.ValueParameter.Depth = 1;
     649      currentSuccessRatioAnalyzer.ValuesParameter.ActualName = "Success Ratio History";
    583650      if (Problem != null) {
    584651        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    600667        selector.CopySelected = new BoolValue(true);
    601668        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
     669        selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
    602670        ParameterizeStochasticOperatorForLayer(selector);
    603671      }
     
    625693    }
    626694    private void ParameterizeAgeLimits() {
    627       var scheme = AgingScheme.Value;
    628       int ageGap = AgeGap.Value;
    629       int numberOfLayers = NumberOfLayers.Value;
    630       AgeLimits = scheme.CalculateAgeLimits(ageGap, numberOfLayers);
     695      AgeLimits = AgingScheme.CalculateAgeLimits(AgeGap, NumberOfLayers);
    631696    }
    632697
     
    657722      Analyzer.Operators.Add(ageAnalyzer, ageAnalyzer.EnabledByDefault);
    658723      Analyzer.Operators.Add(ageDistributionAnalyzer, ageDistributionAnalyzer.EnabledByDefault);
     724      Analyzer.Operators.Add(selectionPressureAnalyzer, false); // find way to make history "pretty"
     725      selectionPressureAnalyzer.ValueParameter.Depth = 1; // Adding analyzer sets depth to 2
     726      Analyzer.Operators.Add(currentSuccessRatioAnalyzer, false);
     727      currentSuccessRatioAnalyzer.ValueParameter.Depth = 1; // Adding analyzer sets depth to 2
    659728      LayerAnalyzer.Operators.Add(layerQualityAnalyzer, false);
    660729      LayerAnalyzer.Operators.Add(layerAgeAnalyzer, false);
    661730      LayerAnalyzer.Operators.Add(layerAgeDistributionAnalyzer, false);
     731      LayerAnalyzer.Operators.Add(layerSelectionPressureAnalyzer, false);
     732      layerSelectionPressureAnalyzer.ValueParameter.Depth = 0; // Adding layer-analyzer sets depth to 1
     733
    662734
    663735      if (Problem != null) {
     
    702774      var newTerminators = new Dictionary<ITerminator, bool> {
    703775        {generationsTerminator, !Terminators.Operators.Contains(generationsTerminator) || Terminators.Operators.ItemChecked(generationsTerminator)},
     776        //{selectionPressureTerminator, !Terminators.Operators.Contains(selectionPressureTerminator) || Terminators.Operators.ItemChecked(selectionPressureTerminator)},
    704777        {evaluationsTerminator, Terminators.Operators.Contains(evaluationsTerminator) && Terminators.Operators.ItemChecked(evaluationsTerminator)},
    705778        {qualityTerminator, Terminators.Operators.Contains(qualityTerminator) && Terminators.Operators.ItemChecked(qualityTerminator) },
  • trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithmMainLoop.cs

    r13326 r13402  
    3232namespace HeuristicLab.Algorithms.ALPS {
    3333
    34   [Item("AlpsGeneticAlgorithmMainLoop", "An ALPS genetic algorithm main loop operator.")]
     34  [Item("AlpsOffspringSelectionGeneticAlgorithmMainLoop", "An ALPS offspring selection genetic algorithm main loop operator.")]
    3535  [StorableClass]
    36   public sealed class AlpsGeneticAlgorithmMainLoop : AlgorithmOperator {
     36  public sealed class AlpsOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
    3737    #region Parameter Properties
    3838    public IValueLookupParameter<IRandom> GlobalRandomParameter {
     
    9191      get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
    9292    }
    93     public IValueLookupParameter<BoolValue> PlusSelectionParameter {
    94       get { return (IValueLookupParameter<BoolValue>)Parameters["PlusSelection"]; }
     93
     94    public IValueLookupParameter<DoubleValue> SuccessRatioParameter {
     95      get { return (IValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
     96    }
     97    public ILookupParameter<DoubleValue> ComparisonFactorParameter {
     98      get { return (ILookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
     99    }
     100    public IValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
     101      get { return (IValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
     102    }
     103    public IValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
     104      get { return (IValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
     105    }
     106    public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter {
     107      get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
    95108    }
    96109
     
    121134
    122135    [StorableConstructor]
    123     private AlpsGeneticAlgorithmMainLoop(bool deserializing)
     136    private AlpsOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing)
    124137      : base(deserializing) { }
    125     private AlpsGeneticAlgorithmMainLoop(AlpsGeneticAlgorithmMainLoop original, Cloner cloner)
     138    private AlpsOffspringSelectionGeneticAlgorithmMainLoop(AlpsOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner)
    126139      : base(original, cloner) { }
    127140    public override IDeepCloneable Clone(Cloner cloner) {
    128       return new AlpsGeneticAlgorithmMainLoop(this, cloner);
    129     }
    130     public AlpsGeneticAlgorithmMainLoop()
     141      return new AlpsOffspringSelectionGeneticAlgorithmMainLoop(this, cloner);
     142    }
     143    public AlpsOffspringSelectionGeneticAlgorithmMainLoop()
    131144      : base() {
    132145      Parameters.Add(new ValueLookupParameter<IRandom>("GlobalRandom", "A pseudo random number generator."));
     
    151164      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
    152165      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
    153       Parameters.Add(new ValueLookupParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation."));
     166
     167      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
     168      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1]."));
     169      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
     170      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation."));
     171      Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded."));
    154172
    155173      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The age of individuals."));
     
    168186      var layerVariableCreator = new VariableCreator() { Name = "Initialize Layer" };
    169187      var initLayerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
     188      var layerResultCollector = new ResultsCollector() { Name = "Collect layer results" };
    170189      var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
    171190      var resultsCollector = new ResultsCollector();
     
    173192      var matingPoolProcessor = new UniformSubScopesProcessor() { Name = "Process Mating Pools" };
    174193      var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" };
    175       var mainOperator = new AlpsGeneticAlgorithmMainOperator();
     194      var mainOperator = new AlpsOffspringSelectionGeneticAlgorithmMainOperator();
    176195      var generationsIcrementor = new IntCounter() { Name = "Increment Generations" };
    177196      var evaluatedSolutionsReducer = new DataReducer() { Name = "Increment EvaluatedSolutions" };
     
    195214      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer", new IntValue(0)));
    196215      layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("LayerResults"));
     216      layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
     217      layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
    197218      layerVariableCreator.Successor = initLayerAnalyzerPlaceholder;
    198219
    199220      initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
    200       initLayerAnalyzerPlaceholder.Successor = null;
     221      initLayerAnalyzerPlaceholder.Successor = layerResultCollector;
     222
     223      layerResultCollector.ResultsParameter.ActualName = "LayerResults";
     224      layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
     225      layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio"));
     226      layerResultCollector.Successor = null;
    201227
    202228      initAnalyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
     
    233259      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
    234260      mainOperator.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
    235       mainOperator.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
     261      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
     262      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
     263      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
     264      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
     265      mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     266      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
     267      mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
    236268      mainOperator.AgeParameter.ActualName = AgeParameter.Name;
    237269      mainOperator.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
     
    327359      var updateLayerNumber = new Assigner() { Name = "Layer = OpenLayers" };
    328360      var historyWiper = new ResultsHistoryWiper() { Name = "Clear History in Results" };
    329       var createChildrenViaCrossover = new AlpsGeneticAlgorithmMainOperator();
     361      var createChildrenViaCrossover = new AlpsOffspringSelectionGeneticAlgorithmMainOperator();
    330362      var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };
    331363      var incrOpenLayers = new IntCounter() { Name = "Incr. OpenLayers" };
     
    373405      createChildrenViaCrossover.SelectorParameter.ActualName = SelectorParameter.Name;
    374406      createChildrenViaCrossover.CrossoverParameter.ActualName = CrossoverParameter.Name;
    375       createChildrenViaCrossover.MutatorParameter.ActualName = MutatorParameter.Name;
     407      createChildrenViaCrossover.MutatorParameter.ActualName = MutatorParameter.ActualName;
    376408      createChildrenViaCrossover.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    377409      createChildrenViaCrossover.ElitesParameter.ActualName = ElitesParameter.Name;
    378410      createChildrenViaCrossover.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
    379       createChildrenViaCrossover.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
     411      createChildrenViaCrossover.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
     412      createChildrenViaCrossover.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
     413      createChildrenViaCrossover.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
     414      createChildrenViaCrossover.SelectionPressureParameter.ActualName = "SelectionPressure";
     415      createChildrenViaCrossover.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     416      createChildrenViaCrossover.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
     417      createChildrenViaCrossover.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
    380418      createChildrenViaCrossover.AgeParameter.ActualName = AgeParameter.Name;
    381419      createChildrenViaCrossover.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
  • trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithmMainOperator.cs

    r13326 r13402  
    2929using HeuristicLab.Selection;
    3030
    31 namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
     31namespace HeuristicLab.Algorithms.ALPS {
    3232  /// <summary>
    3333  /// An operator which represents the main loop of an offspring selection genetic algorithm.
    3434  /// </summary>
    35   [Item("OffspringSelectionGeneticAlgorithmMainOperator", "An operator that represents the core of an offspring selection genetic algorithm.")]
     35  [Item("AlpsOffspringSelectionGeneticAlgorithmMainOperator", "An operator that represents the core of an alps offspring selection genetic algorithm.")]
    3636  [StorableClass]
    37   public sealed class OffspringSelectionGeneticAlgorithmMainOperator : AlgorithmOperator {
     37  public sealed class AlpsOffspringSelectionGeneticAlgorithmMainOperator : AlgorithmOperator {
    3838    #region Parameter properties
    39     public ValueLookupParameter<IRandom> RandomParameter {
    40       get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
    41     }
    42     public ValueLookupParameter<BoolValue> MaximizationParameter {
    43       get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
    44     }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48     public ValueLookupParameter<IOperator> SelectorParameter {
    49       get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
    50     }
    51     public ValueLookupParameter<IOperator> CrossoverParameter {
    52       get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
    53     }
    54     public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
    55       get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
    56     }
    57     public ValueLookupParameter<IOperator> MutatorParameter {
    58       get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
    59     }
    60     public ValueLookupParameter<IOperator> EvaluatorParameter {
    61       get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
    62     }
    63     public LookupParameter<IntValue> EvaluatedSolutionsParameter {
    64       get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
    65     }
    66     public ValueLookupParameter<IntValue> ElitesParameter {
    67       get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
     39    public IValueLookupParameter<IRandom> RandomParameter {
     40      get { return (IValueLookupParameter<IRandom>)Parameters["Random"]; }
     41    }
     42    public IValueLookupParameter<IOperator> EvaluatorParameter {
     43      get { return (IValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
     44    }
     45    public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
     46      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     47    }
     48    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     49      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     50    }
     51    public IValueLookupParameter<BoolValue> MaximizationParameter {
     52      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     53    }
     54
     55    public ILookupParameter<IntValue> PopulationSizeParameter {
     56      get { return (ILookupParameter<IntValue>)Parameters["PopulationSize"]; }
     57    }
     58
     59    public IValueLookupParameter<IOperator> SelectorParameter {
     60      get { return (IValueLookupParameter<IOperator>)Parameters["Selector"]; }
     61    }
     62    public IValueLookupParameter<IOperator> CrossoverParameter {
     63      get { return (IValueLookupParameter<IOperator>)Parameters["Crossover"]; }
     64    }
     65    public IValueLookupParameter<IOperator> MutatorParameter {
     66      get { return (IValueLookupParameter<IOperator>)Parameters["Mutator"]; }
     67    }
     68    public IValueLookupParameter<PercentValue> MutationProbabilityParameter {
     69      get { return (IValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
     70    }
     71    public IValueLookupParameter<IntValue> ElitesParameter {
     72      get { return (IValueLookupParameter<IntValue>)Parameters["Elites"]; }
    6873    }
    6974    public IValueLookupParameter<BoolValue> ReevaluateElitesParameter {
    7075      get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
    7176    }
    72     public LookupParameter<DoubleValue> ComparisonFactorParameter {
    73       get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
    74     }
    75     public LookupParameter<DoubleValue> CurrentSuccessRatioParameter {
    76       get { return (LookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
    77     }
    78     public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
    79       get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
    80     }
    81     public LookupParameter<DoubleValue> SelectionPressureParameter {
    82       get { return (LookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
    83     }
    84     public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
    85       get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
    86     }
    87     public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
    88       get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
     77
     78    public ILookupParameter<DoubleValue> ComparisonFactorParameter {
     79      get { return (ILookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
     80    }
     81    public ILookupParameter<DoubleValue> CurrentSuccessRatioParameter {
     82      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
     83    }
     84    public IValueLookupParameter<DoubleValue> SuccessRatioParameter {
     85      get { return (IValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
     86    }
     87    public ILookupParameter<DoubleValue> SelectionPressureParameter {
     88      get { return (ILookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
     89    }
     90    public IValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
     91      get { return (IValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
     92    }
     93    public IValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
     94      get { return (IValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
    8995    }
    9096    public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter {
    9197      get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
    9298    }
     99
     100    public IScopeTreeLookupParameter<DoubleValue> AgeParameter {
     101      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; }
     102    }
     103    public IValueLookupParameter<DoubleValue> AgeInheritanceParameter {
     104      get { return (IValueLookupParameter<DoubleValue>)Parameters["AgeInheritance"]; }
     105    }
     106    public IValueLookupParameter<DoubleValue> AgeIncrementParameter {
     107      get { return (IValueLookupParameter<DoubleValue>)Parameters["AgeIncrement"]; }
     108    }
    93109    #endregion
    94110
    95111    [StorableConstructor]
    96     private OffspringSelectionGeneticAlgorithmMainOperator(bool deserializing) : base(deserializing) { }
    97     private OffspringSelectionGeneticAlgorithmMainOperator(OffspringSelectionGeneticAlgorithmMainOperator original, Cloner cloner)
     112    private AlpsOffspringSelectionGeneticAlgorithmMainOperator(bool deserializing) : base(deserializing) { }
     113    private AlpsOffspringSelectionGeneticAlgorithmMainOperator(AlpsOffspringSelectionGeneticAlgorithmMainOperator original, Cloner cloner)
    98114      : base(original, cloner) {
    99115    }
    100116    public override IDeepCloneable Clone(Cloner cloner) {
    101       return new OffspringSelectionGeneticAlgorithmMainOperator(this, cloner);
    102     }
    103     public OffspringSelectionGeneticAlgorithmMainOperator()
     117      return new AlpsOffspringSelectionGeneticAlgorithmMainOperator(this, cloner);
     118    }
     119    public AlpsOffspringSelectionGeneticAlgorithmMainOperator()
    104120      : base() {
    105121      Initialize();
    106122    }
    107123
    108     [StorableHook(HookType.AfterDeserialization)]
    109     private void AfterDeserialization() {
    110       // BackwardsCompatibility3.3
    111       #region Backwards compatible code, remove with 3.4
    112       if (!Parameters.ContainsKey("ReevaluateElites")) {
    113         Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
    114       }
    115       if (!Parameters.ContainsKey("FillPopulationWithParents"))
    116         Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded."));
    117       #endregion
    118     }
    119 
    120124    private void Initialize() {
    121       #region Create parameters
    122125      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
     126
     127      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
     128      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions."));
     129      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
    123130      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
    124       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
     131
     132      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer."));
    125133      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
    126134      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
     135      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
    127136      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
    128       Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
    129       Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
    130       Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions."));
    131137      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
    132138      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
     139
    133140      Parameters.Add(new LookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1]."));
    134141      Parameters.Add(new LookupParameter<DoubleValue>("CurrentSuccessRatio", "The current success ratio."));
     
    138145      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation."));
    139146      Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded."));
    140       #endregion
    141 
    142       #region Create operators
    143       Placeholder selector = new Placeholder();
    144       SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
    145       ChildrenCreator childrenCreator = new ChildrenCreator();
    146       ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
    147       UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
    148       Placeholder crossover1 = new Placeholder();
    149       UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
    150       Placeholder evaluator1 = new Placeholder();
    151       SubScopesCounter subScopesCounter1 = new SubScopesCounter();
    152       WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
    153       SubScopesRemover subScopesRemover1 = new SubScopesRemover();
    154       UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
    155       StochasticBranch mutationBranch1 = new StochasticBranch();
    156       Placeholder mutator1 = new Placeholder();
    157       VariableCreator variableCreator1 = new VariableCreator();
    158       VariableCreator variableCreator2 = new VariableCreator();
    159       ConditionalSelector conditionalSelector = new ConditionalSelector();
    160       SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
    161       UniformSubScopesProcessor uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
    162       Placeholder evaluator2 = new Placeholder();
    163       SubScopesCounter subScopesCounter2 = new SubScopesCounter();
    164       MergingReducer mergingReducer1 = new MergingReducer();
    165       UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
    166       Placeholder crossover2 = new Placeholder();
    167       StochasticBranch mutationBranch2 = new StochasticBranch();
    168       Placeholder mutator2 = new Placeholder();
    169       UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
    170       Placeholder evaluator3 = new Placeholder();
    171       SubScopesCounter subScopesCounter3 = new SubScopesCounter();
    172       WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
    173       SubScopesRemover subScopesRemover2 = new SubScopesRemover();
    174       OffspringSelector offspringSelector = new OffspringSelector();
    175       SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor();
    176       BestSelector bestSelector = new BestSelector();
    177       WorstSelector worstSelector = new WorstSelector();
    178       RightReducer rightReducer = new RightReducer();
    179       LeftReducer leftReducer = new LeftReducer();
    180       MergingReducer mergingReducer2 = new MergingReducer();
    181       ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
    182       UniformSubScopesProcessor uniformSubScopesProcessor7 = new UniformSubScopesProcessor();
    183       Placeholder evaluator4 = new Placeholder();
    184       SubScopesCounter subScopesCounter4 = new SubScopesCounter();
     147
     148      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The age of individuals."));
     149      Parameters.Add(new ValueLookupParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent."));
     150      Parameters.Add(new ValueLookupParameter<DoubleValue>("AgeIncrement", "The value the age the individuals is incremented if they survives a generation."));
     151
     152
     153      var selector = new Placeholder();
     154      var subScopesProcessor1 = new SubScopesProcessor();
     155      var childrenCreator = new ChildrenCreator();
     156      var osBeforeMutationBranch = new ConditionalBranch();
     157      var uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
     158      var crossover1 = new Placeholder();
     159      var uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
     160      var evaluator1 = new Placeholder();
     161      var subScopesCounter1 = new SubScopesCounter();
     162      var qualityComparer1 = new WeightedParentsQualityComparator();
     163      var ageCalculator1 = new WeightingReducer() { Name = "Calculate Age" };
     164      var subScopesRemover1 = new SubScopesRemover();
     165      var uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
     166      var mutationBranch1 = new StochasticBranch();
     167      var mutator1 = new Placeholder();
     168      var variableCreator1 = new VariableCreator();
     169      var variableCreator2 = new VariableCreator();
     170      var conditionalSelector = new ConditionalSelector();
     171      var subScopesProcessor2 = new SubScopesProcessor();
     172      var uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
     173      var evaluator2 = new Placeholder();
     174      var subScopesCounter2 = new SubScopesCounter();
     175      var mergingReducer1 = new MergingReducer();
     176      var uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
     177      var crossover2 = new Placeholder();
     178      var mutationBranch2 = new StochasticBranch();
     179      var mutator2 = new Placeholder();
     180      var uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
     181      var evaluator3 = new Placeholder();
     182      var subScopesCounter3 = new SubScopesCounter();
     183      var qualityComparer2 = new WeightedParentsQualityComparator();
     184      var ageCalculator2 = new WeightingReducer() { Name = "Calculate Age" };
     185      var subScopesRemover2 = new SubScopesRemover();
     186      var offspringSelector = new AlpsOffspringSelector();
     187      var subScopesProcessor3 = new SubScopesProcessor();
     188      var bestSelector = new BestSelector();
     189      var worstSelector = new WorstSelector();
     190      var rightReducer = new RightReducer();
     191      var leftReducer = new LeftReducer();
     192      var mergingReducer2 = new MergingReducer();
     193      var reevaluateElitesBranch = new ConditionalBranch();
     194      var uniformSubScopesProcessor7 = new UniformSubScopesProcessor();
     195      var evaluator4 = new Placeholder();
     196      var subScopesCounter4 = new SubScopesCounter();
     197      var incrementAgeProcessor = new UniformSubScopesProcessor();
     198      var ageIncrementor = new DoubleCounter() { Name = "Increment Age" };
     199
     200
     201      OperatorGraph.InitialOperator = selector;
    185202
    186203      selector.Name = "Selector (placeholder)";
    187204      selector.OperatorParameter.ActualName = SelectorParameter.Name;
     205      selector.Successor = subScopesProcessor1;
     206
     207      subScopesProcessor1.Operators.Add(new EmptyOperator());
     208      subScopesProcessor1.Operators.Add(childrenCreator);
     209      subScopesProcessor1.Successor = offspringSelector;
    188210
    189211      childrenCreator.ParentsPerChild = new IntValue(2);
     212      childrenCreator.Successor = osBeforeMutationBranch;
    190213
    191214      osBeforeMutationBranch.Name = "Apply OS before mutation?";
    192215      osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
     216      osBeforeMutationBranch.TrueBranch = uniformSubScopesProcessor1;
     217      osBeforeMutationBranch.FalseBranch = uniformSubScopesProcessor5;
     218      osBeforeMutationBranch.Successor = null;
     219
     220      uniformSubScopesProcessor1.Operator = crossover1;
     221      uniformSubScopesProcessor1.Successor = uniformSubScopesProcessor2;
    193222
    194223      crossover1.Name = "Crossover (placeholder)";
    195224      crossover1.OperatorParameter.ActualName = CrossoverParameter.Name;
     225      crossover1.Successor = null;
    196226
    197227      uniformSubScopesProcessor2.Parallel.Value = true;
     228      uniformSubScopesProcessor2.Operator = evaluator1;
     229      uniformSubScopesProcessor2.Successor = subScopesCounter1;
    198230
    199231      evaluator1.Name = "Evaluator (placeholder)";
    200232      evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;
     233      evaluator1.Successor = qualityComparer1;
    201234
    202235      subScopesCounter1.Name = "Increment EvaluatedSolutions";
    203236      subScopesCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     237      subScopesCounter1.Successor = uniformSubScopesProcessor3;
     238
     239      uniformSubScopesProcessor3.Operator = mutationBranch1;
     240      uniformSubScopesProcessor3.Successor = conditionalSelector;
    204241
    205242      qualityComparer1.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
     
    208245      qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
    209246      qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
     247      qualityComparer1.Successor = ageCalculator1;
     248
     249      ageCalculator1.ParameterToReduce.ActualName = AgeParameter.Name;
     250      ageCalculator1.TargetParameter.ActualName = AgeParameter.Name;
     251      ageCalculator1.WeightParameter.ActualName = AgeInheritanceParameter.Name;
     252      ageCalculator1.Successor = subScopesRemover1;
    210253
    211254      subScopesRemover1.RemoveAllSubScopes = true;
     255      subScopesRemover1.Successor = null;
    212256
    213257      mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    214258      mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;
     259      mutationBranch1.FirstBranch = mutator1;
     260      mutationBranch1.SecondBranch = variableCreator2;
     261      mutationBranch1.Successor = null;
    215262
    216263      mutator1.Name = "Mutator (placeholder)";
    217264      mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
     265      mutator1.Successor = variableCreator1;
    218266
    219267      variableCreator1.Name = "MutatedOffspring = true";
    220268      variableCreator1.CollectedValues.Add(new ValueParameter<BoolValue>("MutatedOffspring", null, new BoolValue(true), false));
     269      variableCreator1.Successor = null;
    221270
    222271      variableCreator2.Name = "MutatedOffspring = false";
    223272      variableCreator2.CollectedValues.Add(new ValueParameter<BoolValue>("MutatedOffspring", null, new BoolValue(false), false));
     273      variableCreator2.Successor = null;
    224274
    225275      conditionalSelector.ConditionParameter.ActualName = "MutatedOffspring";
    226276      conditionalSelector.ConditionParameter.Depth = 1;
    227277      conditionalSelector.CopySelected.Value = false;
     278      conditionalSelector.Successor = subScopesProcessor2;
     279
     280      subScopesProcessor2.Operators.Add(new EmptyOperator());
     281      subScopesProcessor2.Operators.Add(uniformSubScopesProcessor4);
     282      subScopesProcessor2.Successor = mergingReducer1;
     283
     284      mergingReducer1.Successor = null;
    228285
    229286      uniformSubScopesProcessor4.Parallel.Value = true;
     287      uniformSubScopesProcessor4.Operator = evaluator2;
     288      uniformSubScopesProcessor4.Successor = subScopesCounter2;
    230289
    231290      evaluator2.Name = "Evaluator (placeholder)";
    232291      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
     292      evaluator2.Successor = null;
    233293
    234294      subScopesCounter2.Name = "Increment EvaluatedSolutions";
    235295      subScopesCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     296      subScopesCounter2.Successor = null;
     297
     298      uniformSubScopesProcessor5.Operator = crossover2;
     299      uniformSubScopesProcessor5.Successor = uniformSubScopesProcessor6;
    236300
    237301      crossover2.Name = "Crossover (placeholder)";
    238302      crossover2.OperatorParameter.ActualName = CrossoverParameter.Name;
     303      crossover2.Successor = mutationBranch2;
    239304
    240305      mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    241306      mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;
     307      mutationBranch2.FirstBranch = mutator2;
     308      mutationBranch2.SecondBranch = null;
     309      mutationBranch2.Successor = null;
    242310
    243311      mutator2.Name = "Mutator (placeholder)";
    244312      mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
     313      mutator2.Successor = null;
    245314
    246315      uniformSubScopesProcessor6.Parallel.Value = true;
     316      uniformSubScopesProcessor6.Operator = evaluator3;
     317      uniformSubScopesProcessor6.Successor = subScopesCounter3;
    247318
    248319      evaluator3.Name = "Evaluator (placeholder)";
    249320      evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;
     321      evaluator3.Successor = qualityComparer2;
    250322
    251323      subScopesCounter3.Name = "Increment EvaluatedSolutions";
     
    257329      qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
    258330      qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
     331      qualityComparer2.Successor = ageCalculator2;
     332
     333      ageCalculator2.ParameterToReduce.ActualName = AgeParameter.Name;
     334      ageCalculator2.TargetParameter.ActualName = AgeParameter.Name;
     335      ageCalculator2.WeightParameter.ActualName = AgeInheritanceParameter.Name;
     336      ageCalculator2.Successor = subScopesRemover2;
    259337
    260338      subScopesRemover2.RemoveAllSubScopes = true;
     339      subScopesRemover2.Successor = null;
     340
     341      subScopesCounter3.Successor = null;
    261342
    262343      offspringSelector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name;
     
    268349      offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";
    269350      offspringSelector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
     351      offspringSelector.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
     352      offspringSelector.OffspringCreator = selector;
     353      offspringSelector.Successor = subScopesProcessor3;
     354
     355      subScopesProcessor3.Operators.Add(bestSelector);
     356      subScopesProcessor3.Operators.Add(worstSelector);
     357      subScopesProcessor3.Successor = mergingReducer2;
    270358
    271359      bestSelector.CopySelected = new BoolValue(false);
     
    273361      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
    274362      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
     363      bestSelector.Successor = rightReducer;
     364
     365      rightReducer.Successor = reevaluateElitesBranch;
     366
     367      reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
     368      reevaluateElitesBranch.Name = "Reevaluate elites ?";
     369      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor7;
     370      reevaluateElitesBranch.FalseBranch = null;
     371      reevaluateElitesBranch.Successor = null;
     372
     373      uniformSubScopesProcessor7.Parallel.Value = true;
     374      uniformSubScopesProcessor7.Operator = evaluator4;
     375      uniformSubScopesProcessor7.Successor = subScopesCounter4;
     376
     377      evaluator4.Name = "Evaluator (placeholder)";
     378      evaluator4.OperatorParameter.ActualName = EvaluatorParameter.Name;
     379
     380      subScopesCounter4.Name = "Increment EvaluatedSolutions";
     381      subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     382      subScopesCounter4.Successor = null;
    275383
    276384      worstSelector.CopySelected = new BoolValue(false);
     
    278386      worstSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
    279387      worstSelector.QualityParameter.ActualName = QualityParameter.Name;
    280 
    281       reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
    282       reevaluateElitesBranch.Name = "Reevaluate elites ?";
    283 
    284       uniformSubScopesProcessor7.Parallel.Value = true;
    285 
    286       evaluator4.Name = "Evaluator (placeholder)";
    287       evaluator4.OperatorParameter.ActualName = EvaluatorParameter.Name;
    288 
    289       subScopesCounter4.Name = "Increment EvaluatedSolutions";
    290       subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    291       #endregion
    292 
    293       #region Create operator graph
    294       OperatorGraph.InitialOperator = selector;
    295       selector.Successor = subScopesProcessor1;
    296       subScopesProcessor1.Operators.Add(new EmptyOperator());
    297       subScopesProcessor1.Operators.Add(childrenCreator);
    298       subScopesProcessor1.Successor = offspringSelector;
    299       childrenCreator.Successor = osBeforeMutationBranch;
    300       osBeforeMutationBranch.TrueBranch = uniformSubScopesProcessor1;
    301       osBeforeMutationBranch.FalseBranch = uniformSubScopesProcessor5;
    302       osBeforeMutationBranch.Successor = null;
    303       uniformSubScopesProcessor1.Operator = crossover1;
    304       uniformSubScopesProcessor1.Successor = uniformSubScopesProcessor2;
    305       crossover1.Successor = null;
    306       uniformSubScopesProcessor2.Operator = evaluator1;
    307       uniformSubScopesProcessor2.Successor = subScopesCounter1;
    308       evaluator1.Successor = qualityComparer1;
    309       qualityComparer1.Successor = subScopesRemover1;
    310       subScopesRemover1.Successor = null;
    311       subScopesCounter1.Successor = uniformSubScopesProcessor3;
    312       uniformSubScopesProcessor3.Operator = mutationBranch1;
    313       uniformSubScopesProcessor3.Successor = conditionalSelector;
    314       mutationBranch1.FirstBranch = mutator1;
    315       mutationBranch1.SecondBranch = variableCreator2;
    316       mutationBranch1.Successor = null;
    317       mutator1.Successor = variableCreator1;
    318       variableCreator1.Successor = null;
    319       variableCreator2.Successor = null;
    320       conditionalSelector.Successor = subScopesProcessor2;
    321       subScopesProcessor2.Operators.Add(new EmptyOperator());
    322       subScopesProcessor2.Operators.Add(uniformSubScopesProcessor4);
    323       subScopesProcessor2.Successor = mergingReducer1;
    324       uniformSubScopesProcessor4.Operator = evaluator2;
    325       uniformSubScopesProcessor4.Successor = subScopesCounter2;
    326       evaluator2.Successor = null;
    327       subScopesCounter2.Successor = null;
    328       mergingReducer1.Successor = null;
    329       uniformSubScopesProcessor5.Operator = crossover2;
    330       uniformSubScopesProcessor5.Successor = uniformSubScopesProcessor6;
    331       crossover2.Successor = mutationBranch2;
    332       mutationBranch2.FirstBranch = mutator2;
    333       mutationBranch2.SecondBranch = null;
    334       mutationBranch2.Successor = null;
    335       mutator2.Successor = null;
    336       uniformSubScopesProcessor6.Operator = evaluator3;
    337       uniformSubScopesProcessor6.Successor = subScopesCounter3;
    338       evaluator3.Successor = qualityComparer2;
    339       qualityComparer2.Successor = subScopesRemover2;
    340       subScopesRemover2.Successor = null;
    341       subScopesCounter3.Successor = null;
    342       offspringSelector.OffspringCreator = selector;
    343       offspringSelector.Successor = subScopesProcessor3;
    344       subScopesProcessor3.Operators.Add(bestSelector);
    345       subScopesProcessor3.Operators.Add(worstSelector);
    346       subScopesProcessor3.Successor = mergingReducer2;
    347       bestSelector.Successor = rightReducer;
    348       rightReducer.Successor = reevaluateElitesBranch;
    349       reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor7;
    350       uniformSubScopesProcessor7.Operator = evaluator4;
    351       uniformSubScopesProcessor7.Successor = subScopesCounter4;
    352       subScopesCounter4.Successor = null;
    353       reevaluateElitesBranch.FalseBranch = null;
    354       reevaluateElitesBranch.Successor = null;
    355388      worstSelector.Successor = leftReducer;
     389
    356390      leftReducer.Successor = null;
    357       mergingReducer2.Successor = null;
    358       #endregion
     391
     392      mergingReducer2.Successor = incrementAgeProcessor;
     393
     394      incrementAgeProcessor.Operator = ageIncrementor;
     395      incrementAgeProcessor.Successor = null;
     396
     397      ageIncrementor.ValueParameter.ActualName = AgeParameter.Name;
     398      ageIncrementor.IncrementParameter.Value = null;
     399      ageIncrementor.IncrementParameter.ActualName = AgeIncrementParameter.Name;
     400      ageIncrementor.Successor = null;
    359401    }
    360402
  • trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelector.cs

    r13391 r13402  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Selection {
    31   [Item("OffspringSelector", "Selects among the offspring population those that are designated successful and discards the unsuccessful offspring, except for some lucky losers. It expects the parent scopes to be below the first sub-scope, and offspring scopes to be below the second sub-scope separated again in two sub-scopes, the first with the failed offspring and the second with successful offspring.")]
     30namespace HeuristicLab.Algorithms.ALPS {
     31  [Item("AlpsOffspringSelector", "Selects among the offspring population those that are designated successful and discards the unsuccessful offspring, except for some lucky losers. It expects the parent scopes to be below the first sub-scope, and offspring scopes to be below the second sub-scope separated again in two sub-scopes, the first with the failed offspring and the second with successful offspring.")]
    3232  [StorableClass]
    33   public class OffspringSelector : SingleSuccessorOperator {
    34     public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
    35       get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
     33  public class AlpsOffspringSelector : SingleSuccessorOperator {
     34    public IValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
     35      get { return (IValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
    3636    }
    37     public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
    38       get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
     37    public IValueLookupParameter<DoubleValue> SuccessRatioParameter {
     38      get { return (IValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
    3939    }
    40     public LookupParameter<DoubleValue> SelectionPressureParameter {
    41       get { return (ValueLookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
     40    public ILookupParameter<DoubleValue> SelectionPressureParameter {
     41      get { return (IValueLookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
    4242    }
    43     public LookupParameter<DoubleValue> CurrentSuccessRatioParameter {
    44       get { return (LookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
     43    public ILookupParameter<DoubleValue> CurrentSuccessRatioParameter {
     44      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
    4545    }
    46     public LookupParameter<ItemList<IScope>> OffspringPopulationParameter {
    47       get { return (LookupParameter<ItemList<IScope>>)Parameters["OffspringPopulation"]; }
     46    public ILookupParameter<ItemList<IScope>> OffspringPopulationParameter {
     47      get { return (ILookupParameter<ItemList<IScope>>)Parameters["OffspringPopulation"]; }
    4848    }
    49     public LookupParameter<IntValue> OffspringPopulationWinnersParameter {
    50       get { return (LookupParameter<IntValue>)Parameters["OffspringPopulationWinners"]; }
     49    public ILookupParameter<IntValue> OffspringPopulationWinnersParameter {
     50      get { return (ILookupParameter<IntValue>)Parameters["OffspringPopulationWinners"]; }
    5151    }
    52     public ScopeTreeLookupParameter<BoolValue> SuccessfulOffspringParameter {
    53       get { return (ScopeTreeLookupParameter<BoolValue>)Parameters["SuccessfulOffspring"]; }
     52    public IScopeTreeLookupParameter<BoolValue> SuccessfulOffspringParameter {
     53      get { return (IScopeTreeLookupParameter<BoolValue>)Parameters["SuccessfulOffspring"]; }
    5454    }
    5555    public OperatorParameter OffspringCreatorParameter {
    5656      get { return (OperatorParameter)Parameters["OffspringCreator"]; }
    5757    }
    58 
    5958    public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter {
    6059      get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
     60    }
     61    public ILookupParameter<IntValue> PopulationSizeParameter {
     62      get { return (ILookupParameter<IntValue>)Parameters["PopulationSize"]; }
    6163    }
    6264
     
    6769
    6870    [StorableConstructor]
    69     protected OffspringSelector(bool deserializing) : base(deserializing) { }
    70     [StorableHook(HookType.AfterDeserialization)]
    71     private void AfterDeserialization() {
    72       // BackwardsCompatibility3.3
    73       #region Backwards compatible code, remove with 3.4
    74       if (Parameters.ContainsKey("FillPopulationWithParents") && Parameters["FillPopulationWithParents"] is FixedValueParameter<BoolValue>)
    75         Parameters.Remove("FillPopulationWithParents");
    76       if (!Parameters.ContainsKey("FillPopulationWithParents"))
    77         Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individuals instead of lucky losers."));
    78       #endregion
     71    protected AlpsOffspringSelector(bool deserializing) : base(deserializing) { }
     72    protected AlpsOffspringSelector(AlpsOffspringSelector original, Cloner cloner) : base(original, cloner) { }
     73    public override IDeepCloneable Clone(Cloner cloner) {
     74      return new AlpsOffspringSelector(this, cloner);
    7975    }
    80 
    81     protected OffspringSelector(OffspringSelector original, Cloner cloner) : base(original, cloner) { }
    82     public override IDeepCloneable Clone(Cloner cloner) {
    83       return new OffspringSelector(this, cloner);
    84     }
    85     public OffspringSelector()
     76    public AlpsOffspringSelector()
    8677      : base() {
    8778      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure which prematurely terminates the offspring selection step."));
     
    9485      Parameters.Add(new OperatorParameter("OffspringCreator", "The operator used to create new offspring."));
    9586      Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded."));
     87      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer."));
    9688    }
    9789
     
    10597      IScope parents = scope.SubScopes[0];
    10698      IScope offspring = scope.SubScopes[1];
    107       int populationSize = parents.SubScopes.Count;
     99      int populationSize = PopulationSizeParameter.ActualValue.Value;
    108100
    109101      // retrieve actual selection pressure and success ratio
  • trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj

    r13231 r13402  
    8585  </ItemGroup>
    8686  <ItemGroup>
     87    <Compile Include="AlpsOffspringSelectionGeneticAlgorithmMainLoop.cs" />
     88    <Compile Include="AlpsOffspringSelectionGeneticAlgorithm.cs" />
    8789    <Compile Include="AlpsGeneticAlgorithmMainOperator.cs" />
     90    <Compile Include="AlpsOffspringSelectionGeneticAlgorithmMainOperator.cs" />
     91    <Compile Include="AlpsOffspringSelector.cs" />
    8892    <Compile Include="ReseedingController.cs" />
    8993    <Compile Include="ResultsHistoryWiper.cs" />
Note: See TracChangeset for help on using the changeset viewer.