Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/13 10:52:38 (10 years ago)
Author:
mkommend
Message:

#1997: Worked on symbolic data analysis island algorithms:

  • Refactored and removed unnecessary code in symbolic island GA and symbolic island GA evaluator.
  • Added EnumerableItem to ease the passing of rows to the actual evaluator.
  • Added prototype of island offspring selection GA.
  • Corrected build configuration (plugin classes, project settings, ...)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs

    r9756 r10142  
    4141  [Creatable("Algorithms")]
    4242  [StorableClass]
    43   public sealed class IslandOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
     43  public class IslandOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    4444    public string Filename { get; set; }
    4545
     
    5555
    5656    #region Parameter Properties
    57     private ValueParameter<IntValue> SeedParameter {
     57    protected ValueParameter<IntValue> SeedParameter {
    5858      get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
    5959    }
    60     private ValueParameter<BoolValue> SetSeedRandomlyParameter {
     60    protected ValueParameter<BoolValue> SetSeedRandomlyParameter {
    6161      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    6262    }
    63     private ValueParameter<IntValue> NumberOfIslandsParameter {
     63    protected ValueParameter<IntValue> NumberOfIslandsParameter {
    6464      get { return (ValueParameter<IntValue>)Parameters["NumberOfIslands"]; }
    6565    }
    66     private ValueParameter<IntValue> MigrationIntervalParameter {
     66    protected ValueParameter<IntValue> MigrationIntervalParameter {
    6767      get { return (ValueParameter<IntValue>)Parameters["MigrationInterval"]; }
    6868    }
    69     private ValueParameter<PercentValue> MigrationRateParameter {
     69    protected ValueParameter<PercentValue> MigrationRateParameter {
    7070      get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; }
    7171    }
     
    7979      get { return (IConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
    8080    }
    81     private ValueParameter<IntValue> PopulationSizeParameter {
     81    protected ValueParameter<IntValue> PopulationSizeParameter {
    8282      get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
    8383    }
    84     private ValueParameter<IntValue> MaximumGenerationsParameter {
     84    protected ValueParameter<IntValue> MaximumGenerationsParameter {
    8585      get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
    8686    }
     
    9191      get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
    9292    }
    93     private ValueParameter<PercentValue> MutationProbabilityParameter {
     93    protected ValueParameter<PercentValue> MutationProbabilityParameter {
    9494      get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
    9595    }
     
    9797      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
    9898    }
    99     private ValueParameter<IntValue> ElitesParameter {
     99    protected ValueParameter<IntValue> ElitesParameter {
    100100      get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
    101101    }
    102     private IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
     102    protected IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
    103103      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
    104104    }
    105     private ValueLookupParameter<DoubleValue> SuccessRatioParameter {
     105    protected ValueLookupParameter<DoubleValue> SuccessRatioParameter {
    106106      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
    107107    }
    108     private ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
     108    protected ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
    109109      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
    110110    }
    111     private ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
     111    protected ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
    112112      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
    113113    }
     
    115115      get { return (IConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }
    116116    }
    117     private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
     117    protected ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
    118118      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
    119119    }
    120     private ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
     120    protected ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
    121121      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
    122122    }
    123     private ValueLookupParameter<IntValue> SelectedParentsParameter {
     123    protected ValueLookupParameter<IntValue> SelectedParentsParameter {
    124124      get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; }
    125125    }
    126     private ValueParameter<MultiAnalyzer> AnalyzerParameter {
     126    protected ValueParameter<MultiAnalyzer> AnalyzerParameter {
    127127      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    128128    }
    129     private ValueParameter<MultiAnalyzer> IslandAnalyzerParameter {
     129    protected ValueParameter<MultiAnalyzer> IslandAnalyzerParameter {
    130130      get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; }
    131131    }
    132     private ValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
     132    protected ValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
    133133      get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; }
    134134    }
     
    236236      set { MaximumEvaluatedSolutionsParameter.Value = value; }
    237237    }
    238     private RandomCreator RandomCreator {
     238    protected RandomCreator RandomCreator {
    239239      get { return (RandomCreator)OperatorGraph.InitialOperator; }
    240240    }
    241     private UniformSubScopesProcessor IslandProcessor {
     241    protected UniformSubScopesProcessor IslandProcessor {
    242242      get { return ((RandomCreator.Successor as SubScopesCreator).Successor as UniformSubScopesProcessor); }
    243243    }
    244     private SolutionsCreator SolutionsCreator {
     244    protected SolutionsCreator SolutionsCreator {
    245245      get { return (SolutionsCreator)IslandProcessor.Operator; }
    246246    }
    247     private IslandOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
     247    protected IslandOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
    248248      get { return FindMainLoop(IslandProcessor.Successor); }
    249249    }
     
    261261
    262262    [StorableConstructor]
    263     private IslandOffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }
     263    protected IslandOffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }
    264264    [StorableHook(HookType.AfterDeserialization)]
    265265    private void AfterDeserialization() {
     
    275275      Initialize();
    276276    }
    277     private IslandOffspringSelectionGeneticAlgorithm(IslandOffspringSelectionGeneticAlgorithm original, Cloner cloner)
     277    protected IslandOffspringSelectionGeneticAlgorithm(IslandOffspringSelectionGeneticAlgorithm original, Cloner cloner)
    278278      : base(original, cloner) {
    279279      islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer);
     
    456456      base.Problem_OperatorsChanged(sender, e);
    457457    }
    458     private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
     458    protected virtual void ElitesParameter_ValueChanged(object sender, EventArgs e) {
    459459      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
    460460      ParameterizeSelectors();
    461461    }
    462     private void Elites_ValueChanged(object sender, EventArgs e) {
    463       ParameterizeSelectors();
    464     }
    465     private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
     462    protected virtual void Elites_ValueChanged(object sender, EventArgs e) {
     463      ParameterizeSelectors();
     464    }
     465    protected virtual void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
    466466      NumberOfIslands.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
    467467      ParameterizeSelectors();
    468468    }
    469     private void PopulationSize_ValueChanged(object sender, EventArgs e) {
     469    protected virtual void PopulationSize_ValueChanged(object sender, EventArgs e) {
    470470      ParameterizeSelectors();
    471471    }
     
    475475      ParameterizeAnalyzers();
    476476    }
    477     private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
     477    protected virtual void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
    478478      MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
    479479      ParameterizeSelectors();
    480480    }
    481     private void MigrationRate_ValueChanged(object sender, EventArgs e) {
    482       ParameterizeSelectors();
    483     }
    484     private void MaximumMigrationsParameter_ValueChanged(object sender, EventArgs e) {
     481    protected virtual void MigrationRate_ValueChanged(object sender, EventArgs e) {
     482      ParameterizeSelectors();
     483    }
     484    protected virtual void MaximumMigrationsParameter_ValueChanged(object sender, EventArgs e) {
    485485      MaximumGenerations.ValueChanged += new EventHandler(MaximumMigrations_ValueChanged);
    486486      ParameterizeComparisonFactorModifiers();
    487487    }
    488     private void MaximumMigrations_ValueChanged(object sender, EventArgs e) {
     488    protected virtual void MaximumMigrations_ValueChanged(object sender, EventArgs e) {
    489489      ParameterizeComparisonFactorModifiers();
    490490    }
    491     private void MigrationIntervalParameter_ValueChanged(object sender, EventArgs e) {
     491    protected virtual void MigrationIntervalParameter_ValueChanged(object sender, EventArgs e) {
    492492      MigrationInterval.ValueChanged += new EventHandler(MigrationInterval_ValueChanged);
    493493      ParameterizeComparisonFactorModifiers();
    494494    }
    495     private void MigrationInterval_ValueChanged(object sender, EventArgs e) {
     495    protected virtual void MigrationInterval_ValueChanged(object sender, EventArgs e) {
    496496      ParameterizeComparisonFactorModifiers();
    497497    }
     
    514514      }
    515515    }
    516     private void ParameterizeSolutionsCreator() {
     516    protected virtual void ParameterizeSolutionsCreator() {
    517517      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    518518      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    519519    }
    520     private void ParameterizeMainLoop() {
     520    protected virtual void ParameterizeMainLoop() {
    521521      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    522522      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     
    524524      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    525525    }
    526     private void ParameterizeStochasticOperator(IOperator op) {
     526    protected virtual void ParameterizeStochasticOperator(IOperator op) {
    527527      if (op is IStochasticOperator)
    528528        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    529529    }
    530     private void ParameterizeSelectors() {
     530    protected virtual void ParameterizeSelectors() {
    531531      foreach (ISelector selector in SelectorParameter.ValidValues) {
    532532        selector.CopySelected = new BoolValue(true);
     
    558558      }
    559559    }
    560     private void ParameterizeAnalyzers() {
     560    protected virtual void ParameterizeAnalyzers() {
    561561      islandQualityAnalyzer.ResultsParameter.ActualName = "Results";
    562562      islandQualityAnalyzer.QualityParameter.Depth = 1;
     
    591591      }
    592592    }
    593     private void ParameterizeComparisonFactorModifiers() {
     593    protected virtual void ParameterizeComparisonFactorModifiers() {
    594594      foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) {
    595595        modifier.IndexParameter.ActualName = "Generations";
     
    601601      }
    602602    }
    603     private void ParameterizeIterationBasedOperators() {
     603    protected virtual void ParameterizeIterationBasedOperators() {
    604604      if (Problem != null) {
    605605        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
     
    609609      }
    610610    }
    611     private void UpdateCrossovers() {
     611    protected virtual void UpdateCrossovers() {
    612612      ICrossover oldCrossover = CrossoverParameter.Value;
    613613      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
     
    623623        CrossoverParameter.Value = defaultCrossover;
    624624    }
    625     private void UpdateMutators() {
     625    protected virtual void UpdateMutators() {
    626626      IManipulator oldMutator = MutatorParameter.Value;
    627627      MutatorParameter.ValidValues.Clear();
     
    649649      Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault);
    650650    }
    651     private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
     651    protected virtual IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
    652652      IOperator mainLoop = start;
    653653      while (mainLoop != null && !(mainLoop is IslandOffspringSelectionGeneticAlgorithmMainLoop))
Note: See TracChangeset for help on using the changeset viewer.