Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/13 20:46:18 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added GA subsumption
  • simplified deletion before covering
  • simplified XCSDeletionOperator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs

    r9105 r9110  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.ConditionActionEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization.Operators;
     
    3637  [StorableClass]
    3738  public sealed class LCSAdaptedGeneticAlgorithm : AlgorithmOperator {
     39    private const string TEMPID = "TempID";
     40    private const string SUBSUMEDBY = "SubsumedBy";
     41    private const string SUBSUMED = "Subsumed";
     42
    3843    #region Parameter properties
    3944    public ValueLookupParameter<IRandom> RandomParameter {
     
    7580    public ValueLookupParameter<IntValue> PopulationSizeParameter {
    7681      get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
     82    }
     83    public ValueLookupParameter<BoolValue> DoGASubsumptionParameter {
     84      get { return (ValueLookupParameter<BoolValue>)Parameters["DoGASubsumption"]; }
    7785    }
    7886    private ScopeParameter CurrentScopeParameter {
     
    113121      Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
    114122      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
     123      Parameters.Add(new ValueLookupParameter<BoolValue>("DoGASubsumption", "Sets if GA subsumption is executed."));
    115124      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
    116125      #endregion
     
    126135      Placeholder crossover = new Placeholder();
    127136      Placeholder afterCrossover = new Placeholder();
    128       StochasticBranch stochasticBranch = new StochasticBranch();
    129137      Placeholder mutator = new Placeholder();
    130138      SubScopesRemover subScopesRemover = new SubScopesRemover();
     
    136144      ConditionalBranch conditionalBranch = new ConditionalBranch();
    137145
     146      TempSubScopeIDAssigner tempIdAssigner = new TempSubScopeIDAssigner();
     147      ConditionalBranch doGASubsumptionBranch1 = new ConditionalBranch();
     148      UniformSubScopesProcessor setSubsumptionFalseSubScopesProcessor = new UniformSubScopesProcessor();
     149      Assigner setSubsumpByAssigner = new Assigner();
     150      Assigner setSubsumptionFalseAssigner = new Assigner();
     151      CheckGASubsumptionOperator checkGASubsumptionOperator = new CheckGASubsumptionOperator();
     152      ConditionalBranch doGASubsumptionBranch2 = new ConditionalBranch();
     153      ExecuteGASubsumptionOperator executeGAsubsumptionOperator = new ExecuteGASubsumptionOperator();
     154      ConditionalSelector subsumptionSelector = new ConditionalSelector();
     155      LeftReducer subsumptionLeftReducer = new LeftReducer();
     156
    138157      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations
    139158
     
    144163      analyzer1.OperatorParameter.ActualName = "Analyzer";
    145164
     165      tempIdAssigner.LeftSideParameter.ActualName = TEMPID;
     166
     167      setSubsumpByAssigner.LeftSideParameter.ActualName = SUBSUMEDBY;
     168      setSubsumpByAssigner.RightSideParameter.Value = new IntValue(-1);
     169
     170      setSubsumptionFalseAssigner.LeftSideParameter.ActualName = SUBSUMED;
     171      setSubsumptionFalseAssigner.RightSideParameter.Value = new BoolValue(false);
     172
    146173      selector.Name = "Selector";
    147174      selector.OperatorParameter.ActualName = "Selector";
     
    155182      afterCrossover.OperatorParameter.ActualName = "AfterCrossover";
    156183
    157       stochasticBranch.ProbabilityParameter.ActualName = "MutationProbability";
    158       stochasticBranch.RandomParameter.ActualName = "Random";
    159 
    160184      mutator.Name = "Mutator";
    161185      mutator.OperatorParameter.ActualName = "Mutator";
    162186
     187      doGASubsumptionBranch1.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName;
     188
     189      checkGASubsumptionOperator.ChildClassifiersParameter.ActualName = "CombinedIntegerVector";
     190      checkGASubsumptionOperator.ParentsClassifiersParameter.ActualName = "CombinedIntegerVector";
     191      checkGASubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity";
     192      checkGASubsumptionOperator.ExperiencesParameter.ActualName = "Experience";
     193      checkGASubsumptionOperator.ErrorsParameter.ActualName = "Error";
     194      checkGASubsumptionOperator.TempIDParameter.ActualName = TEMPID;
     195      checkGASubsumptionOperator.ErrorZeroParameter.ActualName = "ErrorZero";
     196      checkGASubsumptionOperator.ThetaSubsumptionParameter.ActualName = "ThetaSubsumption";
     197      checkGASubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY;
     198      checkGASubsumptionOperator.SubsumedParameter.ActualName = SUBSUMED;
     199
    163200      subScopesRemover.RemoveAllSubScopes = true;
     201
     202      doGASubsumptionBranch2.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName;
     203
     204      executeGAsubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity";
     205      executeGAsubsumptionOperator.TempIDParameter.ActualName = TEMPID;
     206      executeGAsubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY;
     207
     208      subsumptionSelector.ConditionParameter.ActualName = SUBSUMED;
     209      subsumptionSelector.CopySelected = new BoolValue(false);
    164210
    165211      subScopesCounter.Name = "Increment EvaluatedSolutions";
     
    184230      variableCreator.Successor = resultsCollector1;
    185231      resultsCollector1.Successor = analyzer1;
    186       analyzer1.Successor = selector;
     232      analyzer1.Successor = tempIdAssigner;
     233      tempIdAssigner.Successor = setSubsumptionFalseSubScopesProcessor;
     234      setSubsumptionFalseSubScopesProcessor.Operator = setSubsumpByAssigner;
     235      setSubsumpByAssigner.Successor = setSubsumptionFalseAssigner;
     236      setSubsumptionFalseAssigner.Successor = null;
     237      setSubsumptionFalseSubScopesProcessor.Successor = selector;
    187238      selector.Successor = subScopesProcessor1;
    188239      subScopesProcessor1.Operators.Add(new EmptyOperator());
     
    193244      uniformSubScopesProcessor1.Successor = subScopesCounter;
    194245      crossover.Successor = afterCrossover;
    195       afterCrossover.Successor = stochasticBranch;
    196       stochasticBranch.FirstBranch = mutator;
    197       stochasticBranch.SecondBranch = null;
    198       stochasticBranch.Successor = subScopesRemover;
    199       mutator.Successor = null;
     246      afterCrossover.Successor = mutator;
     247      mutator.Successor = doGASubsumptionBranch1;
     248      doGASubsumptionBranch1.TrueBranch = checkGASubsumptionOperator;
     249      doGASubsumptionBranch1.FalseBranch = new EmptyOperator();
     250      doGASubsumptionBranch1.Successor = subScopesRemover;
    200251      subScopesRemover.Successor = null;
    201252      subScopesCounter.Successor = null;
    202       mergingReducer.Successor = intCounter;
     253      mergingReducer.Successor = doGASubsumptionBranch2;
     254      doGASubsumptionBranch2.TrueBranch = executeGAsubsumptionOperator;
     255      doGASubsumptionBranch2.FalseBranch = new EmptyOperator();
     256      executeGAsubsumptionOperator.Successor = subsumptionSelector;
     257      subsumptionSelector.Successor = subsumptionLeftReducer;
     258      subsumptionLeftReducer.Successor = null;
     259      doGASubsumptionBranch2.Successor = intCounter;
    203260      intCounter.Successor = comparator;
    204261      comparator.Successor = analyzer2;
Note: See TracChangeset for help on using the changeset viewer.