Changeset 9160


Ignore:
Timestamp:
01/15/13 10:47:09 (5 years ago)
Author:
sforsten
Message:

#1980:

  • added problem instance provider to import csv files for ConditionActionClassificationProblemData
  • adapted LCSAdaptedGeneticAlgorithm to use the crossover probability
  • fixed a bug in XCSModelView
Location:
branches/LearningClassifierSystems
Files:
10 added
12 edited

Legend:

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

    r9154 r9160  
    8787      <Private>False</Private>
    8888    </Reference>
     89    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    8990    <Reference Include="HeuristicLab.Random-3.3">
    9091      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs

    r9154 r9160  
    6363      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
    6464    }
     65    public ValueLookupParameter<PercentValue> CrossoverProbabilityParameter {
     66      get { return (ValueLookupParameter<PercentValue>)Parameters["CrossoverProbability"]; }
     67    }
    6568    public ValueLookupParameter<IOperator> MutatorParameter {
    6669      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
     
    111114      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
    112115      Parameters.Add(new ValueLookupParameter<IOperator>("AfterCrossover", "The operator executed after crossing the solutions."));
    113       Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
     116      Parameters.Add(new ValueLookupParameter<PercentValue>("CrossoverProbability", "The probability that the crossover operator is applied on a solution."));
     117      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that druing the mutation operator a mutation takes place."));
    114118      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
    115119      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
     
    128132      ChildrenCreator childrenCreator = new ChildrenCreator();
    129133      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
     134      StochasticBranch crossoverStochasticBranch = new StochasticBranch();
     135      RandomSelector randomSelector = new RandomSelector();
     136      PreservingRightReducer preservingRightReducer = new PreservingRightReducer();
     137      Assigner numerosityAssigner = new Assigner();
     138      Assigner experienceAssigner = new Assigner();
    130139      Placeholder crossover = new Placeholder();
    131140      Placeholder afterCrossover = new Placeholder();
     
    167176      childrenCreator.ParentsPerChild = new IntValue(2);
    168177
     178      crossoverStochasticBranch.ProbabilityParameter.ActualName = CrossoverProbabilityParameter.ActualName;
     179      crossoverStochasticBranch.RandomParameter.ActualName = "Random";
     180
     181      randomSelector.CopySelected.Value = true;
     182      randomSelector.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
     183
    169184      crossover.Name = "Crossover";
    170185      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);
    171192
    172193      afterCrossover.Name = "AfterCrossover";
     
    228249      subScopesProcessor1.Successor = mergingReducer;
    229250      childrenCreator.Successor = uniformSubScopesProcessor1;
    230       uniformSubScopesProcessor1.Operator = crossover;
     251      uniformSubScopesProcessor1.Operator = crossoverStochasticBranch;
    231252      uniformSubScopesProcessor1.Successor = subScopesCounter;
     253      crossoverStochasticBranch.FirstBranch = crossover;
     254      crossoverStochasticBranch.SecondBranch = randomSelector;
     255      randomSelector.Successor = preservingRightReducer;
     256      preservingRightReducer.Successor = numerosityAssigner;
     257      numerosityAssigner.Successor = experienceAssigner;
     258      experienceAssigner.Successor = null;
     259      crossoverStochasticBranch.Successor = mutator;
    232260      crossover.Successor = afterCrossover;
    233       afterCrossover.Successor = mutator;
    234261      mutator.Successor = doGASubsumptionBranch1;
    235262      doGASubsumptionBranch1.TrueBranch = checkGASubsumptionOperator;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj

    r9154 r9160  
    6868      <Private>False</Private>
    6969    </Reference>
     70    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    7071    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    7172      <Private>False</Private>
     
    120121    <Compile Include="Selectors\IMatchSelector.cs" />
    121122    <Compile Include="Selectors\MatchSelector.cs" />
     123    <Compile Include="Selectors\PreservingRightReducer.cs" />
    122124    <Compile Include="Subsumption\ActionSetSubsumptionOperator.cs" />
    123125    <Compile Include="Subsumption\CheckGASubsumptionOperator.cs" />
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblemData.cs

    r9154 r9160  
    3434    IEnumerable<string> AllowedActionVariables { get; }
    3535
    36     IntValue Length { get; }
    37     IntValue ActionLength { get; }
    38     IntMatrix Bounds { get; }
    39 
    4036    IClassifier FetchClassifier(int rowNumber);
    4137
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3

    • Property svn:ignore
      •  

        old new  
        11obj
        22Plugin.cs
         3*.user
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/HeuristicLab.Problems.ConditionActionClassification-3.3.csproj

    r9154 r9160  
    7878      <Private>False</Private>
    7979    </Reference>
     80    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    8081    <Reference Include="System" />
    8182    <Reference Include="System.Core" />
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs

    r9154 r9160  
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3131using HeuristicLab.Problems.DataAnalysis;
     32using HeuristicLab.Problems.Instances;
    3233
    3334namespace HeuristicLab.Problems.ConditionActionClassification {
    3435  [StorableClass]
    35   public class ConditionActionClassificationProblem : HeuristicOptimizationProblem<XCSEvaluator, UniformRandomCombinedIntegerVectorCreator>, IConditionActionProblem {
     36  public class ConditionActionClassificationProblem : HeuristicOptimizationProblem<XCSEvaluator, UniformRandomCombinedIntegerVectorCreator>, IConditionActionProblem,
     37  IProblemInstanceConsumer<ConditionActionClassificationProblemData> {
    3638    private const string ClassifierFetcherParameterName = "ClassifierFetcher";
    3739    private const string ActionExecuterParameterName = "ActionExecuter";
     
    8789    public ConditionActionClassificationProblemData ProblemData {
    8890      get { return ProblemDataParameter.Value; }
     91      protected set {
     92        ProblemDataParameter.Value = value;
     93        if (value != null) {
     94          SetProblemDataSpecificParameters();
     95        }
     96      }
    8997    }
    9098    IParameter IConditionActionProblem.PossibleActionsConcreteClassParameter {
     
    185193      Evaluator.InitialPredictionParameter.ActualName = "InitialPrediction";
    186194
     195      coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name;
     196      coveringSolutionCreator.CoverClassifierParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
     197      coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector";
     198
     199      ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     200
     201      ActionExecuter.CurrentClassifierToMatchParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
     202      ActionExecuter.NegativeRewardParameter.ActualName = NegativeRewardParameter.Name;
     203      ActionExecuter.PositiveRewardParameter.ActualName = PositiveRewardParameter.Name;
     204
     205      ActionSetSubsumptionOperator.ClassifiersParameter.ActualName = "CombinedIntegerVector";
     206
     207      SetProblemDataSpecificParameters();
     208      ThetaMinimalNumberOfActions.Value = PossibleActions.Count;
     209
     210      InitializeOperators();
     211
     212      problemData.Changed += new System.EventHandler(problemData_Changed);
     213    }
     214
     215    private void problemData_Changed(object sender, System.EventArgs e) {
     216      SetProblemDataSpecificParameters();
     217    }
     218
     219    private void SetProblemDataSpecificParameters() {
    187220      SolutionCreator.ActionPartLengthParameter.ActualName = ProblemData.ActionLengthParameter.Name;
    188221      SolutionCreator.LengthParameter.ActualName = ProblemData.LengthParameter.Name;
    189222      SolutionCreator.BoundsParameter.ActualName = ProblemData.BoundsParameter.Name;
    190223
    191       coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name;
    192       coveringSolutionCreator.CoverClassifierParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
    193       coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector";
    194 
    195       ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    196 
    197       ActionExecuter.CurrentClassifierToMatchParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
    198       ActionExecuter.NegativeRewardParameter.ActualName = NegativeRewardParameter.Name;
    199       ActionExecuter.PositiveRewardParameter.ActualName = PositiveRewardParameter.Name;
    200 
    201       ActionSetSubsumptionOperator.ClassifiersParameter.ActualName = "CombinedIntegerVector";
    202 
    203       SetPossibleActions();
    204       ThetaMinimalNumberOfActions.Value = PossibleActions.Count;
    205 
    206       InitializeOperators();
    207 
    208       problemData.Changed += new System.EventHandler(problemData_Changed);
    209     }
    210 
    211     private void problemData_Changed(object sender, System.EventArgs e) {
    212224      SetPossibleActions();
    213225    }
     
    282294      return actionBounds;
    283295    }
     296
     297    public void Load(ConditionActionClassificationProblemData data) {
     298      Name = data.Name;
     299      Description = data.Description;
     300      ProblemData = data;
     301    }
    284302  }
    285303}
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs

    r9154 r9160  
    4040      {0,0,1,1,0,0,0},
    4141      {0,1,1,1,0,0,0},
    42       {0,0,1,0,0,0,0},
     42      {0,0,1,0,0,0,1},
    4343      {1,0,1,0,1,1,0}
    4444    };
     
    117117      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ActionVariables", "", actionVariables.AsReadOnly()));
    118118      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)));
     119      Parameters.Add(new FixedValueParameter<IntValue>("Length", "", new IntValue(allowedConditionVariables.Count() + allowedActionVariables.Count())));
     120      Parameters.Add(new FixedValueParameter<IntValue>("ActionLength", "", new IntValue(allowedActionVariables.Count())));
     121      Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "", GetBoundsMatrix(dataset, allowedConditionVariables, allowedActionVariables)));
    123122
    124123      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     124    }
     125
     126    private IntMatrix GetBoundsMatrix(Dataset dataset, IEnumerable<string> conditionVariables, IEnumerable<string> actionVariables) {
     127      IntMatrix bounds = new IntMatrix(conditionVariables.Count() + actionVariables.Count(), 2);
     128      int index = 0;
     129      foreach (var variable in conditionVariables) {
     130        var values = dataset.GetDoubleValues(variable);
     131        bounds[index, 0] = (int)values.Min();
     132        bounds[index, 1] = (int)values.Max() + 2;
     133        index++;
     134      }
     135      foreach (var variable in actionVariables) {
     136        var values = dataset.GetDoubleValues(variable);
     137        bounds[index, 0] = (int)values.Min();
     138        bounds[index, 1] = (int)values.Max() + 1;
     139        index++;
     140      }
     141      return bounds;
    125142    }
    126143
  • branches/LearningClassifierSystems/HeuristicLab.Problems.XCS.Views/3.3

    • Property svn:ignore set to
      Plugin.cs
      *.user
  • branches/LearningClassifierSystems/HeuristicLab.Problems.XCS.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/LearningClassifierSystems/HeuristicLab.Problems.XCS.Views/3.3/XCSModelView.cs

    r9154 r9160  
    5252        if (Content == null) {
    5353          dataGridView.Rows.Clear();
     54        } else {
     55
     56          dataGridView.RowCount = Content.Count;
     57
     58          int row = 0;
     59          foreach (var xcsClassifier in Content) {
     60            dataGridView[0, row].Value = xcsClassifier.Classifier.ToString();
     61            dataGridView[1, row].Value = xcsClassifier.Prediction.ToString();
     62            dataGridView[2, row].Value = xcsClassifier.PredictionError.ToString();
     63            dataGridView[3, row].Value = xcsClassifier.Fitness.ToString();
     64            dataGridView[4, row].Value = xcsClassifier.Numerosity.ToString();
     65            dataGridView[5, row].Value = xcsClassifier.Timestamp.ToString();
     66            dataGridView[6, row].Value = xcsClassifier.Experience.ToString();
     67            dataGridView[7, row].Value = xcsClassifier.AverageActionSetSize.ToString();
     68            row++;
     69          }
     70
     71          dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
     72          dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
    5473        }
    55 
    56         dataGridView.RowCount = Content.Count;
    57 
    58         int row = 0;
    59         foreach (var xcsClassifier in Content) {
    60           dataGridView[0, row].Value = xcsClassifier.Classifier.ToString();
    61           dataGridView[1, row].Value = xcsClassifier.Prediction.ToString();
    62           dataGridView[2, row].Value = xcsClassifier.PredictionError.ToString();
    63           dataGridView[3, row].Value = xcsClassifier.Fitness.ToString();
    64           dataGridView[4, row].Value = xcsClassifier.Numerosity.ToString();
    65           dataGridView[5, row].Value = xcsClassifier.Timestamp.ToString();
    66           dataGridView[6, row].Value = xcsClassifier.Experience.ToString();
    67           dataGridView[7, row].Value = xcsClassifier.AverageActionSetSize.ToString();
    68           row++;
    69         }
    70 
    71         dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
    72         dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
    7374      }
    7475    }
  • branches/LearningClassifierSystems/LearningClassifierSystem.sln

    r9154 r9160  
    1717EndProject
    1818Project("{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}"
     19EndProject
     20Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Instances.ConditionActionClassification", "HeuristicLab.Problems.Instances.ConditionActionClassification\3.3\HeuristicLab.Problems.Instances.ConditionActionClassification.csproj", "{1CC7585E-DD22-41FA-869B-93DE41EA8936}"
    1921EndProject
    2022Global
     
    7274    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x64.ActiveCfg = Release|Any CPU
    7375    {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x86.ActiveCfg = Release|Any CPU
     76    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     77    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Debug|Any CPU.Build.0 = Debug|Any CPU
     78    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Debug|x64.ActiveCfg = Debug|Any CPU
     79    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Debug|x86.ActiveCfg = Debug|Any CPU
     80    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|Any CPU.ActiveCfg = Release|Any CPU
     81    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|Any CPU.Build.0 = Release|Any CPU
     82    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|x64.ActiveCfg = Release|Any CPU
     83    {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|x86.ActiveCfg = Release|Any CPU
    7484  EndGlobalSection
    7585  GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset for help on using the changeset viewer.