Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9154


Ignore:
Timestamp:
01/14/13 15:23:17 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added XCSSolution, XCSModel, XCSClassifier to represent the xcs classifier
  • XCSSolution also shows the current accuracy (training and test partition has to be added)
  • added XCSSolutionAnalyzer to create a XCSSolution during the run of the algorithm
  • added XCSModelView to show the xcs model
  • fixed a bug in XCSDeletionOperator (sometimes it deleted less classifiers than it should)
  • moved some parameter from ConditionActionClassificationProblem to ConditionActionClassificationProblemData
Location:
branches/LearningClassifierSystems
Files:
19 added
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/HeuristicLab.Algorithms.LearningClassifierSystems-3.3.csproj

    r9089 r9154  
    4141      <Private>False</Private>
    4242    </Reference>
     43    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     44      <Private>False</Private>
     45    </Reference>
    4346    <Reference Include="HeuristicLab.Collections-3.3">
    4447      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     
    5760      <Private>False</Private>
    5861    </Reference>
    59     <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     62    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     63      <Private>False</Private>
     64    </Reference>
    6065    <Reference Include="HeuristicLab.Operators-3.3">
    6166      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     
    8691      <Private>False</Private>
    8792    </Reference>
    88     <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     93    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     94      <Private>False</Private>
     95    </Reference>
    8996    <Reference Include="System" />
    9097    <Reference Include="System.Core" />
     
    111118      <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project>
    112119      <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name>
     120      <Private>False</Private>
    113121    </ProjectReference>
    114122    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
    115123      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
    116124      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     125      <Private>False</Private>
    117126    </ProjectReference>
    118127    <ProjectReference Include="..\..\HeuristicLab.Problems.ConditionActionClassification\3.3\HeuristicLab.Problems.ConditionActionClassification-3.3.csproj">
    119128      <Project>{EA51D441-F6A3-41E1-9993-A2488E93C222}</Project>
    120129      <Name>HeuristicLab.Problems.ConditionActionClassification-3.3</Name>
     130      <Private>False</Private>
    121131    </ProjectReference>
    122132  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs

    r9110 r9154  
    7272      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
    7373    }
    74     public ValueLookupParameter<IOperator> AnalyzerParameter {
    75       get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
    76     }
    7774    public ValueLookupParameter<IntValue> EvaluatedSolutionsParameter {
    7875      get { return (ValueLookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     
    118115      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
    119116      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    120       Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    121117      Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
    122118      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
     
    128124      VariableCreator variableCreator = new VariableCreator();
    129125      ResultsCollector resultsCollector1 = new ResultsCollector();
    130       Placeholder analyzer1 = new Placeholder();
    131126      Placeholder selector = new Placeholder();
    132127      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
     
    141136      IntCounter intCounter = new IntCounter();
    142137      Comparator comparator = new Comparator();
    143       Placeholder analyzer2 = new Placeholder();
    144138      ConditionalBranch conditionalBranch = new ConditionalBranch();
    145139
     
    157151      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations
    158152
    159       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     153      //resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
    160154      resultsCollector1.ResultsParameter.ActualName = "Results";
    161 
    162       analyzer1.Name = "Analyzer";
    163       analyzer1.OperatorParameter.ActualName = "Analyzer";
    164155
    165156      tempIdAssigner.LeftSideParameter.ActualName = TEMPID;
     
    220211      comparator.RightSideParameter.ActualName = "MaximumGenerations";
    221212
    222       analyzer2.Name = "Analyzer";
    223       analyzer2.OperatorParameter.ActualName = "Analyzer";
    224 
    225213      conditionalBranch.ConditionParameter.ActualName = "Terminate";
    226214      #endregion
     
    229217      OperatorGraph.InitialOperator = variableCreator;
    230218      variableCreator.Successor = resultsCollector1;
    231       resultsCollector1.Successor = analyzer1;
    232       analyzer1.Successor = tempIdAssigner;
     219      resultsCollector1.Successor = tempIdAssigner;
    233220      tempIdAssigner.Successor = setSubsumptionFalseSubScopesProcessor;
    234221      setSubsumptionFalseSubScopesProcessor.Operator = setSubsumpByAssigner;
     
    259246      doGASubsumptionBranch2.Successor = intCounter;
    260247      intCounter.Successor = comparator;
    261       comparator.Successor = analyzer2;
    262       analyzer2.Successor = conditionalBranch;
     248      comparator.Successor = conditionalBranch;
    263249      conditionalBranch.FalseBranch = selector;
    264250      conditionalBranch.TrueBranch = null;
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs

    r9089 r9154  
    2121
    2222using System;
     23using System.Linq;
     24using HeuristicLab.Analysis;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.Data;
    2628using HeuristicLab.Encodings.ConditionActionEncoding;
     29using HeuristicLab.Operators;
    2730using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    2832using HeuristicLab.Parameters;
    2933using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    105109      get { return (ValueParameter<BoolValue>)Parameters["DoActionSetSubsumption"]; }
    106110    }
     111    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
     112      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
     113    }
     114    private ValueParameter<IntValue> MaxIterationsParameter {
     115      get { return (ValueParameter<IntValue>)Parameters["MaxIterations"]; }
     116    }
    107117    #endregion
    108118
     
    180190      set { DoActionSetSubsumptionParameter.Value = value; }
    181191    }
     192    public IntValue MaxIterations {
     193      get { return MaxIterationsParameter.Value; }
     194      set { MaxIterationsParameter.Value = value; }
     195    }
     196    public MultiAnalyzer Analyzer {
     197      get { return AnalyzerParameter.Value; }
     198      set { AnalyzerParameter.Value = value; }
     199    }
    182200    private RandomCreator RandomCreator {
    183201      get { return (RandomCreator)OperatorGraph.InitialOperator; }
    184202    }
    185203    public LearningClassifierSystemMainLoop MainLoop {
    186       get { return (LearningClassifierSystemMainLoop)RandomCreator.Successor; }
     204      get { return FindMainLoop(RandomCreator.Successor); }
    187205    }
    188206    #endregion
     
    209227      Parameters.Add(new ValueParameter<BoolValue>("DoGASubsumption", "Specifies if offsprings are tested for possible logical subsumption by parents.", new BoolValue(true)));
    210228      Parameters.Add(new ValueParameter<BoolValue>("DoActionSetSubsumption", "Specifies if action set is tested for subsuming classifiers.", new BoolValue(true)));
     229      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
     230      Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "The maximum number of iterations.", new IntValue(1000)));
    211231      #endregion
    212232
     
    214234      RandomCreator randomCreator = new RandomCreator();
    215235
    216       //ResultsCollector resultsCollector = new ResultsCollector();
     236      ResultsCollector resultsCollector = new ResultsCollector();
    217237      LearningClassifierSystemMainLoop mainLoop = new LearningClassifierSystemMainLoop();
    218238
     
    222242      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
    223243      randomCreator.SetSeedRandomlyParameter.Value = null;
     244
     245      resultsCollector.ResultsParameter.ActualName = "Results";
     246
     247      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     248      mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name;
    224249      #endregion
    225250
    226251      #region Create operator graph
    227252      OperatorGraph.InitialOperator = randomCreator;
    228       randomCreator.Successor = mainLoop;
     253      randomCreator.Successor = resultsCollector;
     254      resultsCollector.Successor = mainLoop;
    229255      #endregion
     256
     257      UpdateAnalyzers();
    230258    }
    231259    private LearningClassifierSystem(LearningClassifierSystem original, Cloner cloner)
     
    242270        ParameterizeEvaluator(Problem.Evaluator);
    243271        MainLoop.SetCurrentProblem(Problem);
     272        UpdateAnalyzers();
    244273      }
    245274      base.OnProblemChanged();
     
    253282      MainLoop.SetCurrentProblem(Problem);
    254283      base.Problem_SolutionCreatorChanged(sender, e);
     284    }
     285    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
     286      UpdateAnalyzers();
     287      base.Problem_OperatorsChanged(sender, e);
    255288    }
    256289
     
    262295      evaluator.ErrorZeroParameter.ActualName = ErrorZeroParameter.Name;
    263296    }
     297
     298    private void UpdateAnalyzers() {
     299      Analyzer.Operators.Clear();
     300      if (Problem != null) {
     301        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
     302          Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
     303        }
     304      }
     305    }
     306
     307    private LearningClassifierSystemMainLoop FindMainLoop(IOperator start) {
     308      IOperator mainLoop = start;
     309      while (mainLoop != null && !(mainLoop is LearningClassifierSystemMainLoop))
     310        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     311      if (mainLoop == null) return null;
     312      else return (LearningClassifierSystemMainLoop)mainLoop;
     313    }
    264314  }
    265315}
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs

    r9110 r9154  
    5555      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
    5656    }
     57    public LookupParameter<IntValue> MaxIterationsParameter {
     58      get { return (LookupParameter<IntValue>)Parameters["MaxIterations"]; }
     59    }
     60    public ValueLookupParameter<IOperator> AnalyzerParameter {
     61      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
     62    }
    5763    #endregion
    5864
     
    97103      XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator();
    98104      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "The operator used to select solutions for reproduction.", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
     105      Parameters.Add(new LookupParameter<IntValue>("MaxIterations", "The maximum number of iterations the algorithm will do."));
     106      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    99107      #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);
    100116
    101117      #region Create operators
    102118      VariableCreator variableCreator = new VariableCreator();
     119      ResultsCollector resultsCollector = new ResultsCollector();
     120      Placeholder finalAnalyzer = new Placeholder();
    103121      ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
    104122      initialSolutionsCreator = new SolutionsCreator();
    105123      Assigner initialPopulationSizeAssigner = new Assigner();
     124      Comparator maxIterationsComparator = new Comparator();
     125      ConditionalBranch terminationConditionalBranch1 = new ConditionalBranch();
    106126      IntCounter iterationCounter = new IntCounter();
    107127      UniformSubScopesProcessor matchCondtionSubScopesProcessor = new UniformSubScopesProcessor();
     
    159179      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
    160180
     181      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iteration"));
     182      resultsCollector.ResultsParameter.ActualName = "Results";
     183
     184      finalAnalyzer.Name = "Analyzer";
     185      finalAnalyzer.OperatorParameter.ActualName = "Analyzer";
     186
    161187      initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
    162188
     
    165191      initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize";
    166192      initialPopulationSizeAssigner.RightSideParameter.ActualName = "N";
     193
     194      maxIterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     195      maxIterationsComparator.LeftSideParameter.ActualName = "Iteration";
     196      maxIterationsComparator.RightSideParameter.ActualName = MaxIterationsParameter.ActualName;
     197      maxIterationsComparator.ResultParameter.ActualName = "TerminateMaxIterations";
     198
     199      terminationConditionalBranch1.ConditionParameter.ActualName = "TerminateMaxIterations";
    167200
    168201      iterationCounter.ValueParameter.ActualName = "Iteration";
     
    311344      OperatorGraph.InitialOperator = variableCreator;
    312345
    313       variableCreator.Successor = initialPopulationConditionalBranch;
     346      variableCreator.Successor = resultsCollector;
     347      resultsCollector.Successor = initialPopulationConditionalBranch;
    314348      initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
    315349      initialSolutionsCreator.Successor = initialPopulationSizeAssigner;
    316350      initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
    317       initialPopulationConditionalBranch.Successor = classifierFetcher;
     351      initialPopulationConditionalBranch.Successor = maxIterationsComparator;
     352      maxIterationsComparator.Successor = terminationConditionalBranch1;
     353      terminationConditionalBranch1.TrueBranch = finalAnalyzer;
     354      terminationConditionalBranch1.FalseBranch = classifierFetcher;
    318355      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
    319356      matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
     
    371408      deletionSelectorAfterGA.Successor = leftReducerAfterGA;
    372409      leftReducerAfterGA.Successor = iterationCounter;
    373       iterationCounter.Successor = classifierFetcher;
     410      //iterationCounter.Successor = maxIterationsComparator;
     411
     412      iterationCounter.Successor = testReducer;
     413      testReducer.Successor = maxIterationsComparator;
    374414      #endregion
    375415    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj

    r9110 r9154  
    8383  </PropertyGroup>
    8484  <ItemGroup>
    85     <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    86     <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    87     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    88     <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    89     <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    90     <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    91     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    92     <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    93     <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    94     <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     85    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     86      <Private>False</Private>
     87    </Reference>
     88    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     89      <Private>False</Private>
     90    </Reference>
     91    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     92      <Private>False</Private>
     93    </Reference>
     94    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     95      <Private>False</Private>
     96    </Reference>
     97    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     98      <Private>False</Private>
     99    </Reference>
     100    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     101      <Private>False</Private>
     102    </Reference>
     103    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     104      <Private>False</Private>
     105    </Reference>
     106    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     107      <Private>False</Private>
     108    </Reference>
     109    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     110      <Private>False</Private>
     111    </Reference>
     112    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     113      <Private>False</Private>
     114    </Reference>
    95115    <Reference Include="System" />
    96116    <Reference Include="System.Core" />
     
    132152      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
    133153      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     154      <Private>False</Private>
    134155    </ProjectReference>
    135156  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Manipulator/UniformSomePositionManipulator.cs

    r9110 r9154  
    4646    public UniformSomePositionManipulator()
    4747      : base() {
    48       Parameters.Add(new ValueLookupParameter<PercentValue>("Probability", "The probability for each dimension to be manipulated.", new PercentValue(0.5)));
     48      Parameters.Add(new ValueLookupParameter<PercentValue>("Probability", "The probability for each dimension to be manipulated."));
    4949      Parameters.Add(new LookupParameter<IItemSet<CombinedIntegerVector>>("PossibleActions"));
    5050    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Deletion/XCSDeletionOperator.cs

    r9110 r9154  
    112112        double averageFitnessInPopulation = fitnessSum / numerositySum;
    113113        for (int cl = 0; cl < fitnesses.Length; cl++) {
    114           if (numerosities[cl].Value > 0) {
     114          if (numerosities[cl].Value > 0 && !hasToBeDeleted[cl].Value) {
    115115            voteSum += DeletionVote(averageFitnessInPopulation, averageActionSetSizes[cl].Value, numerosities[cl].Value, fitnesses[cl].Value, experiences[cl].Value);
    116116          }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj

    r9110 r9154  
    6565      <Private>False</Private>
    6666    </Reference>
    67     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     67    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     68      <Private>False</Private>
     69    </Reference>
    6870    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    6971      <Private>False</Private>
     
    8385    <Compile Include="ActionSelection\MaxValueActionSelector.cs" />
    8486    <Compile Include="ActionSelection\RandomActionSelector.cs" />
     87    <Compile Include="Analyzer\XCSSolutionAnalyzer.cs" />
    8588    <Compile Include="Covering\CoveringOperator.cs" />
    8689    <Compile Include="Covering\DoDeletionBeforeCovering.cs" />
     
    9598    <Compile Include="GA\XCSAfterCrossoverOperator.cs" />
    9699    <Compile Include="IClassifier.cs" />
     100    <Compile Include="Interfaces\IConditionActionModel.cs" />
    97101    <Compile Include="Interfaces\IConditionActionProblem.cs" />
    98102    <Compile Include="Interfaces\IConditionActionProblemData.cs" />
     103    <Compile Include="Interfaces\IConditionActionSolution.cs" />
     104    <Compile Include="Interfaces\IXCSModel.cs" />
     105    <Compile Include="Interfaces\IXCSSolution.cs" />
    99106    <Compile Include="Operator\CalculateAccuracy.cs" />
    100107    <Compile Include="GA\XCSCheckIfGAShouldBeApplied.cs" />
     
    108115    <Compile Include="Plugin.cs" />
    109116    <Compile Include="Reinforcement\ActionExecuter.cs" />
     117    <Compile Include="Reinforcement\ClassifierFetcher.cs" />
    110118    <Compile Include="Reinforcement\IActionExecuter.cs" />
    111119    <Compile Include="Reinforcement\IClassifierFetcher.cs" />
     
    116124    <Compile Include="Subsumption\ExecuteGASubsumptionOperator.cs" />
    117125    <Compile Include="Subsumption\IActionSetSubsumption.cs" />
     126    <Compile Include="XCSClassifier.cs" />
     127    <Compile Include="XCSModel.cs" />
     128    <Compile Include="XCSSolution.cs" />
    118129    <None Include="Properties\AssemblyInfo.cs.frame" />
    119130  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblemData.cs

    r9089 r9154  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Core;
     
    3233    IEnumerable<string> AllowedConditionVariables { get; }
    3334    IEnumerable<string> AllowedActionVariables { get; }
     35
     36    IntValue Length { get; }
     37    IntValue ActionLength { get; }
     38    IntMatrix Bounds { get; }
     39
     40    IClassifier FetchClassifier(int rowNumber);
     41
     42    event EventHandler Changed;
    3443  }
    3544}
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/HeuristicLab.Problems.ConditionActionClassification-3.3.csproj

    r9105 r9154  
    4040    <Reference Include="HeuristicLab.Collections-3.3">
    4141      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     42      <Private>False</Private>
    4243    </Reference>
    4344    <Reference Include="HeuristicLab.Common-3.3">
    4445      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     46      <Private>False</Private>
    4547    </Reference>
    4648    <Reference Include="HeuristicLab.Core-3.3">
    4749      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     50      <Private>False</Private>
    4851    </Reference>
    4952    <Reference Include="HeuristicLab.Data-3.3">
    5053      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     54      <Private>False</Private>
    5155    </Reference>
    52     <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    53     <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    54     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     56    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     57      <Private>False</Private>
     58    </Reference>
     59    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     60      <Private>False</Private>
     61    </Reference>
     62    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     63      <Private>False</Private>
     64    </Reference>
    5565    <Reference Include="HeuristicLab.Parameters-3.3">
    5666      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     67      <Private>False</Private>
    5768    </Reference>
    5869    <Reference Include="HeuristicLab.Persistence-3.3">
    5970      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     71      <Private>False</Private>
    6072    </Reference>
    6173    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    6274      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     75      <Private>False</Private>
    6376    </Reference>
    64     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     77    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     78      <Private>False</Private>
     79    </Reference>
    6580    <Reference Include="System" />
    6681    <Reference Include="System.Core" />
     
    7691    <Compile Include="Implementation\ConditionActionClassificationProblemData.cs" />
    7792    <Compile Include="Plugin.cs" />
    78     <Compile Include="Reinforcement\CombinedIntegerVectorClassifierFetcher.cs" />
    7993    <None Include="HeuristicLab.snk" />
    8094    <None Include="Properties\AssemblyInfo.cs.frame" />
     
    88102      <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project>
    89103      <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name>
     104      <Private>False</Private>
    90105    </ProjectReference>
    91106    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
    92107      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
    93108      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     109      <Private>False</Private>
    94110    </ProjectReference>
    95111  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs

    r9110 r9154  
    7676      get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; }
    7777    }
    78     //for test purposes
    79     public IFixedValueParameter<IntValue> LengthParameter {
    80       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    81     }
    82     public IFixedValueParameter<IntValue> ActionPartLengthParameter {
    83       get { return (IFixedValueParameter<IntValue>)Parameters["ActionPartLength"]; }
    84     }
    85     public IFixedValueParameter<IntMatrix> BoundsParameter {
    86       get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }
    87     }
    8878    #endregion
    8979
     
    120110    }
    121111    IParameter IConditionActionProblem.ActionExecuterParameter { get { return ActionExecuterParameter; } }
    122     public CombinedIntegerVectorClassifierFetcher ClassifierFetcher {
     112    public ClassifierFetcher ClassifierFetcher {
    123113      get { return ClassifierFetcherParameter.Value; }
    124114    }
    125     public ValueParameter<CombinedIntegerVectorClassifierFetcher> ClassifierFetcherParameter {
    126       get { return (ValueParameter<CombinedIntegerVectorClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
     115    public ValueParameter<ClassifierFetcher> ClassifierFetcherParameter {
     116      get { return (ValueParameter<ClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
    127117    }
    128118    IClassifierFetcher IConditionActionProblem.ClassifierFetcher { get { return ClassifierFetcher; } }
     
    150140    IParameter IConditionActionProblem.CoveringSolutionCreatorParameter {
    151141      get { return CoveringSolutionCreatorParameter; }
     142    }
     143    private XCSSolutionAnalyzer XCSSolutionAnalyzer {
     144      get { return Operators.OfType<XCSSolutionAnalyzer>().FirstOrDefault(); }
    152145    }
    153146    #endregion
     
    170163    public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator, ICoveringSolutionCreator coveringSolutionCreator)
    171164      : base(evaluator, solutionCreator) {
    172       Parameters.Add(new FixedValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(7)));
    173       Parameters.Add(new FixedValueParameter<IntValue>("ActionPartLength", "The operator to create a solution.", new IntValue(1)));
    174       int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };
    175       Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "The operator to create a solution.", new IntMatrix(elements)));
    176165      Parameters.Add(new ValueParameter<ConditionActionClassificationProblemData>("ProblemData", "", problemData));
    177166      Parameters.Add(new FixedValueParameter<DoubleValue>("PositiveReward", "", new DoubleValue(1000)));
     
    182171
    183172      Parameters.Add(new ValueParameter<IActionExecuter>(ActionExecuterParameterName, "", new ActionExecuter()));
    184       Parameters.Add(new ValueParameter<CombinedIntegerVectorClassifierFetcher>(ClassifierFetcherParameterName, "", new CombinedIntegerVectorClassifierFetcher()));
     173      Parameters.Add(new ValueParameter<ClassifierFetcher>(ClassifierFetcherParameterName, "", new ClassifierFetcher()));
    185174      Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions"));
    186175      Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass"));
     
    196185      Evaluator.InitialPredictionParameter.ActualName = "InitialPrediction";
    197186
    198       SolutionCreator.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    199       SolutionCreator.LengthParameter.ActualName = LengthParameter.Name;
    200       SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
     187      SolutionCreator.ActionPartLengthParameter.ActualName = ProblemData.ActionLengthParameter.Name;
     188      SolutionCreator.LengthParameter.ActualName = ProblemData.LengthParameter.Name;
     189      SolutionCreator.BoundsParameter.ActualName = ProblemData.BoundsParameter.Name;
    201190
    202191      coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name;
     
    204193      coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector";
    205194
    206       ClassifierFetcher.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    207       ClassifierFetcher.BoundsParameter.ActualName = BoundsParameter.Name;
    208195      ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    209196
     
    217204      ThetaMinimalNumberOfActions.Value = PossibleActions.Count;
    218205
    219       BoundsParameter.ValueChanged += new System.EventHandler(BoundsParameter_ValueChanged);
    220       LengthParameter.ValueChanged += new System.EventHandler(LengthParameter_ValueChanged);
    221       ActionPartLengthParameter.ValueChanged += new System.EventHandler(ActionPartLengthParameter_ValueChanged);
    222     }
    223 
    224     #region event handler
    225     private void ActionPartLengthParameter_ValueChanged(object sender, System.EventArgs e) {
     206      InitializeOperators();
     207
     208      problemData.Changed += new System.EventHandler(problemData_Changed);
     209    }
     210
     211    private void problemData_Changed(object sender, System.EventArgs e) {
    226212      SetPossibleActions();
    227213    }
    228     private void LengthParameter_ValueChanged(object sender, System.EventArgs e) {
    229       SetPossibleActions();
    230     }
    231     private void BoundsParameter_ValueChanged(object sender, System.EventArgs e) {
    232       SetPossibleActions();
    233     }
    234     #endregion
     214
     215    private void InitializeOperators() {
     216      Operators.Add(new XCSSolutionAnalyzer());
     217
     218      ParameterizeAnalyzers();
     219    }
     220
     221    private void ParameterizeAnalyzers() {
     222      if (XCSSolutionAnalyzer != null) {
     223        XCSSolutionAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName;
     224        XCSSolutionAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName;
     225        XCSSolutionAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName;
     226        XCSSolutionAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName;
     227        XCSSolutionAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName;
     228        XCSSolutionAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName;
     229        XCSSolutionAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName;
     230        XCSSolutionAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName;
     231        XCSSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     232        XCSSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     233      }
     234    }
    235235
    236236    private void SetPossibleActions() {
    237237      //get bounds of action
    238       IntMatrix actionBounds = GetElementsOfBoundsForAction(BoundsParameter.Value, LengthParameter.Value.Value, ActionPartLengthParameter.Value.Value);
    239       int actionLength = ActionPartLengthParameter.Value.Value;
    240       int start = LengthParameter.Value.Value - actionLength;
     238      IntMatrix actionBounds = GetElementsOfBoundsForAction(ProblemData.Bounds, ProblemData.Length.Value, ProblemData.ActionLength.Value);
     239      int actionLength = ProblemData.ActionLength.Value;
     240      int start = ProblemData.Length.Value - actionLength;
    241241      int[] elements = new int[actionLength];
    242242      int[] curPos = new int[actionLength];
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs

    r9089 r9154  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Encodings.CombinedIntegerVectorEncoding;
    2829using HeuristicLab.Encodings.ConditionActionEncoding;
    2930using HeuristicLab.Parameters;
     
    5455      get { return (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters["ActionVariables"]; }
    5556    }
     57    public IFixedValueParameter<IntValue> LengthParameter {
     58      get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
     59    }
     60    public IFixedValueParameter<IntValue> ActionLengthParameter {
     61      get { return (IFixedValueParameter<IntValue>)Parameters["ActionLength"]; }
     62    }
     63    public IFixedValueParameter<IntMatrix> BoundsParameter {
     64      get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }
     65    }
    5666    #endregion
    5767
     
    7484      get { return ActionVariables.CheckedItems.Select(x => x.Value.Value); }
    7585    }
     86
     87    private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>();
    7688
    7789
     
    105117      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ActionVariables", "", actionVariables.AsReadOnly()));
    106118      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ConditionVariables", "", conditionVariables.AsReadOnly()));
     119      Parameters.Add(new FixedValueParameter<IntValue>("Length", "", new IntValue(7)));
     120      Parameters.Add(new FixedValueParameter<IntValue>("ActionLength", "", new IntValue(1)));
     121      int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };
     122      Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "", new IntMatrix(elements)));
    107123
    108124      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
    109125    }
     126
     127    public event EventHandler Changed;
     128    protected virtual void OnChanged() {
     129      var listeners = Changed;
     130      if (listeners != null) listeners(this, EventArgs.Empty);
     131    }
     132
     133    public IntValue Length {
     134      get { return LengthParameter.Value; }
     135    }
     136
     137    public IntValue ActionLength {
     138      get { return ActionLengthParameter.Value; }
     139    }
     140
     141    public IntMatrix Bounds {
     142      get { return BoundsParameter.Value; }
     143    }
     144
     145    public IClassifier FetchClassifier(int rowNumber) {
     146      if (!fetchClassifiersCache.ContainsKey(rowNumber)) {
     147        int[] elements = new int[Length.Value];
     148        var variableNamesList = Dataset.VariableNames.ToList();
     149        int elementIndex = 0;
     150        for (int i = 0; i < variableNamesList.Count; i++) {
     151          if (AllowedConditionVariables.Contains(variableNamesList[i])) {
     152            elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i));
     153            elementIndex++;
     154          }
     155        }
     156        for (int i = 0; i < variableNamesList.Count; i++) {
     157          if (AllowedActionVariables.Contains(variableNamesList[i])) {
     158            elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i));
     159            elementIndex++;
     160          }
     161        }
     162        if (elementIndex != Length.Value) {
     163          throw new ArgumentException("Length of classifier is not equal to the number of allowed condition + action variables.");
     164        }
     165        fetchClassifiersCache.Add(rowNumber, new CombinedIntegerVector(elements, ActionLengthParameter.Value.Value, BoundsParameter.Value));
     166      }
     167      return fetchClassifiersCache[rowNumber];
     168    }
    110169  }
    111170}
  • branches/LearningClassifierSystems/LearningClassifierSystem.sln

    r9089 r9154  
    1515EndProject
    1616Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.ConditionActionClassification-3.3", "HeuristicLab.Problems.ConditionActionClassification\3.3\HeuristicLab.Problems.ConditionActionClassification-3.3.csproj", "{EA51D441-F6A3-41E1-9993-A2488E93C222}"
     17EndProject
     18Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.XCS.Views-3.3", "HeuristicLab.Problems.XCS.Views\3.3\HeuristicLab.Problems.XCS.Views-3.3.csproj", "{8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}"
    1719EndProject
    1820Global
     
    6264    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x64.ActiveCfg = Release|Any CPU
    6365    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x86.ActiveCfg = Release|Any CPU
     66    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     67    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
     68    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|x64.ActiveCfg = Debug|Any CPU
     69    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|x86.ActiveCfg = Debug|Any CPU
     70    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
     71    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|Any CPU.Build.0 = Release|Any CPU
     72    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x64.ActiveCfg = Release|Any CPU
     73    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x86.ActiveCfg = Release|Any CPU
    6474  EndGlobalSection
    6575  GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset for help on using the changeset viewer.