Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9167


Ignore:
Timestamp:
01/15/13 15:52:54 (11 years ago)
Author:
sforsten
Message:

#1980:

  • change standard parameter settings in ConditionActionClassificationProblem
  • fixed bug: if a parent is copied instead of a crossover, the new individual is inserted in the population correctly
  • added missing attributes to ConditionActionClassificationProblemData
Location:
branches/LearningClassifierSystems
Files:
1 added
8 edited

Legend:

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

    r9160 r9167  
    5454      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
    5555    }
     56    public ValueLookupParameter<IOperator> AfterCopyingParentsParameter {
     57      get { return (ValueLookupParameter<IOperator>)Parameters["AfterCopyingParents"]; }
     58    }
    5659    public ValueLookupParameter<IOperator> CrossoverParameter {
    5760      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
     
    112115      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
    113116      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
     117      Parameters.Add(new ValueLookupParameter<IOperator>("AfterCopyingParents", "The operator executed after copying a parent instead of using crossover."));
    114118      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
    115119      Parameters.Add(new ValueLookupParameter<IOperator>("AfterCrossover", "The operator executed after crossing the solutions."));
     
    135139      RandomSelector randomSelector = new RandomSelector();
    136140      PreservingRightReducer preservingRightReducer = new PreservingRightReducer();
    137       Assigner numerosityAssigner = new Assigner();
    138       Assigner experienceAssigner = new Assigner();
     141      Placeholder afterCopyingParents = new Placeholder();
    139142      Placeholder crossover = new Placeholder();
    140143      Placeholder afterCrossover = new Placeholder();
     
    182185      randomSelector.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
    183186
     187      afterCopyingParents.Name = "AfterCopyingParents";
     188      afterCopyingParents.OperatorParameter.ActualName = "AfterCopyingParents";
     189
    184190      crossover.Name = "Crossover";
    185191      crossover.OperatorParameter.ActualName = "Crossover";
    186 
    187       numerosityAssigner.LeftSideParameter.ActualName = "Numerosity";
    188       numerosityAssigner.RightSideParameter.Value = new IntValue(1);
    189 
    190       experienceAssigner.LeftSideParameter.ActualName = "Experience";
    191       experienceAssigner.RightSideParameter.Value = new IntValue(0);
    192192
    193193      afterCrossover.Name = "AfterCrossover";
     
    254254      crossoverStochasticBranch.SecondBranch = randomSelector;
    255255      randomSelector.Successor = preservingRightReducer;
    256       preservingRightReducer.Successor = numerosityAssigner;
    257       numerosityAssigner.Successor = experienceAssigner;
    258       experienceAssigner.Successor = null;
     256      preservingRightReducer.Successor = afterCopyingParents;
    259257      crossoverStochasticBranch.Successor = mutator;
    260258      crossover.Successor = afterCrossover;
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs

    r9154 r9167  
    5252      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
    5353    }
     54    public IConstrainedValueParameter<IOperator> AfterCopyingParentsParameter {
     55      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCopyingParents"]; }
     56    }
    5457    public IConstrainedValueParameter<IOperator> AfterCrossoverParameter {
    5558      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
     
    101104      test.ChildParameter.ActualName = "CombinedIntegerVector";
    102105      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.", new ItemSet<IManipulator>() { new UniformSomePositionManipulator() }, test));
     106      XCSAfterCopyingParentOperator afterCopyingParents = new XCSAfterCopyingParentOperator();
     107      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCopyingParents", "", new ItemSet<IOperator>() { new XCSAfterCopyingParentOperator() }, afterCopyingParents));
    103108      XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator();
    104       Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "The operator used to select solutions for reproduction.", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
     109      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
    105110      Parameters.Add(new LookupParameter<IntValue>("MaxIterations", "The maximum number of iterations the algorithm will do."));
    106111      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    107112      #endregion
    108 
    109 
    110       //test
    111       DataReducer testReducer = new DataReducer();
    112       testReducer.TargetParameter.ActualName = "TestCurrentPopulation";
    113       testReducer.ParameterToReduce.ActualName = "Numerosity";
    114       testReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
    115       testReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
    116113
    117114      #region Create operators
     
    315312      adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
    316313      adaptedGeneticAlgorithmMainLoop.AfterCrossoverParameter.ActualName = AfterCrossoverParameter.Name;
     314      adaptedGeneticAlgorithmMainLoop.AfterCopyingParentsParameter.ActualName = AfterCopyingParentsParameter.Name;
    317315
    318316      currentPopulationSizeCounter.ValueParameter.ActualName = "CurrentPopulationSize";
     
    351349      initialPopulationConditionalBranch.Successor = maxIterationsComparator;
    352350      maxIterationsComparator.Successor = terminationConditionalBranch1;
    353       terminationConditionalBranch1.TrueBranch = finalAnalyzer;
     351      //terminationConditionalBranch1.TrueBranch = finalAnalyzer;
    354352      terminationConditionalBranch1.FalseBranch = classifierFetcher;
    355353      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
     
    410408      //iterationCounter.Successor = maxIterationsComparator;
    411409
    412       iterationCounter.Successor = testReducer;
    413       testReducer.Successor = maxIterationsComparator;
     410      iterationCounter.Successor = finalAnalyzer;
     411      finalAnalyzer.Successor = maxIterationsComparator;
    414412      #endregion
    415413    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVector.cs

    r9105 r9167  
    251251      return result.GetHashCode();
    252252    }
     253
     254    public bool Identical(IClassifier classifier) {
     255      var cast = classifier as CombinedIntegerVector;
     256      if (cast != null) {
     257        for (int i = 0; i < array.Length; i++) {
     258          if (!array[i].Equals(cast.array[i])) {
     259            return false;
     260          }
     261        }
     262      }
     263      return true;
     264    }
    253265  }
    254266}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/GA/XCSAfterCrossoverOperator.cs

    r9110 r9167  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
    26 using HeuristicLab.Operators;
    2726using HeuristicLab.Parameters;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3130  [Item("XCSAfterCrossoverOperator", "Description missing")]
    3231  [StorableClass]
    33   public class XCSAfterCrossoverOperator : SingleSuccessorOperator {
     32  public class XCSAfterCrossoverOperator : XCSAfterCopyingParentOperator {
    3433
    3534    #region Parameter Properties
    36     public IValueLookupParameter<IntValue> NumerosityParameter {
    37       get { return (IValueLookupParameter<IntValue>)Parameters["Numerosity"]; }
    38     }
    39     public IValueLookupParameter<IntValue> ExperienceParameter {
    40       get { return (IValueLookupParameter<IntValue>)Parameters["Experience"]; }
    41     }
    4235    public IValueLookupParameter<IntValue> TimestampParameter {
    4336      get { return (IValueLookupParameter<IntValue>)Parameters["Timestamp"]; }
     
    5447    public IValueLookupParameter<DoubleValue> FitnessParameter {
    5548      get { return (IValueLookupParameter<DoubleValue>)Parameters["Fitness"]; }
    56     }
    57     public IValueLookupParameter<BoolValue> InsertInPopulationParameter {
    58       get { return (IValueLookupParameter<BoolValue>)Parameters["InsertInPopulation"]; }
    59     }
    60     public IValueLookupParameter<IntValue> TempIDParameter {
    61       get { return (IValueLookupParameter<IntValue>)Parameters["TempID"]; }
    6249    }
    6350    public ILookupParameter<IntValue> CurrentIterationParameter {
     
    8572    public XCSAfterCrossoverOperator()
    8673      : base() {
    87       Parameters.Add(new ValueLookupParameter<IntValue>("Numerosity"));
    88       Parameters.Add(new ValueLookupParameter<IntValue>("Experience"));
    8974      Parameters.Add(new ValueLookupParameter<IntValue>("Timestamp"));
    9075      Parameters.Add(new ValueLookupParameter<DoubleValue>("AverageActionSetSize"));
     
    9277      Parameters.Add(new ValueLookupParameter<DoubleValue>("Error"));
    9378      Parameters.Add(new ValueLookupParameter<DoubleValue>("Fitness"));
    94       Parameters.Add(new ValueLookupParameter<BoolValue>("InsertInPopulation"));
    95       Parameters.Add(new ValueLookupParameter<IntValue>("TempID"));
    9679      Parameters.Add(new LookupParameter<IntValue>("CurrentIteration"));
    9780      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ParentAverageActionSetSize"));
     
    10588
    10689    public override IOperation Apply() {
    107       NumerosityParameter.ActualValue = new IntValue(1);
    108       ExperienceParameter.ActualValue = new IntValue(0);
    10990      TimestampParameter.ActualValue = new IntValue(CurrentIterationParameter.ActualValue.Value);
    11091      var parentAverageActionSetSize = ParentAverageActionSetSizeParameter.ActualValue;
     
    11697      ErrorParameter.ActualValue = new DoubleValue(0.25 * parentPrecisionError.Select(x => x.Value).Average());
    11798      FitnessParameter.ActualValue = new DoubleValue(0.1 * parentFitness.Select(x => x.Value).Average());
    118       InsertInPopulationParameter.ActualValue = new BoolValue(true);
    119       TempIDParameter.ActualValue = new IntValue(-1);
    12099      return base.Apply();
    121100    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj

    r9160 r9167  
    9797    <Compile Include="Evaluators\IXCSEvaluator.cs" />
    9898    <Compile Include="GA\InsertInPopulationOperator.cs" />
     99    <Compile Include="GA\XCSAfterCopyingParentOperator.cs" />
    99100    <Compile Include="GA\XCSAfterCrossoverOperator.cs" />
    100101    <Compile Include="IClassifier.cs" />
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/IClassifier.cs

    r9105 r9167  
    4141    bool Equals(object obj);
    4242    int GetHashCode();
     43
     44    //test
     45    bool Identical(IClassifier classifier);
    4346  }
    4447}
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs

    r9160 r9167  
    185185
    186186      Parameters.Add(new ValueParameter<ICoveringSolutionCreator>("CoveringSolutionCreator", "", coveringSolutionCreator));
    187       Parameters.Add(new FixedValueParameter<PercentValue>("ChangeSymbolProbabilityInCovering", "", new PercentValue(0.5)));
     187      Parameters.Add(new FixedValueParameter<PercentValue>("ChangeSymbolProbabilityInCovering", "", new PercentValue(0.33)));
    188188
    189189      Parameters.Add(new ValueParameter<ActionSetSubsumptionOperator>(ActionSetSubsumptionOperatorParameterName, "", new ActionSetSubsumptionOperator()));
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs

    r9161 r9167  
    3333
    3434namespace HeuristicLab.Problems.ConditionActionClassification {
     35  [StorableClass]
     36  [Item("ConditionActionClassificationProblemData", "A problem data for LCS.")]
    3537  public class ConditionActionClassificationProblemData : ParameterizedNamedItem, IConditionActionProblemData {
    3638
Note: See TracChangeset for help on using the changeset viewer.