Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/27/12 19:14:51 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added ConditionActionClassificationProblem
  • added ConditionActionEncoding
  • added Manipulators, Crossovers and an LCSAdaptedGeneticAlgorithm
  • changed LearningClassifierSystemMainLoop
Location:
branches/LearningClassifierSystems
Files:
63 added
16 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems

    • Property svn:ignore set to
      *.suo
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3

    • Property svn:ignore set to
      *.user
      Plugin.cs
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/HeuristicLab.Algorithms.LearningClassifierSystems-3.3.csproj

    r8941 r9089  
    9696  </ItemGroup>
    9797  <ItemGroup>
    98     <Compile Include="ActionSelection\ActionSelector.cs" />
    99     <Compile Include="ActionSelection\MaxValueActionSelector.cs" />
    100     <Compile Include="ActionSelection\RandomActionSelector.cs" />
     98    <Compile Include="LCSAdaptedGeneticAlgorithm.cs" />
    10199    <Compile Include="LearningClassifierSystem.cs" />
    102100    <Compile Include="LearningClassifierSystemMainLoop.cs" />
    103101    <Compile Include="Properties\AssemblyInfo.cs" />
    104102    <Compile Include="Plugin.cs" />
    105     <Compile Include="Selectors\IMatchSelector.cs" />
    106     <Compile Include="Selectors\MatchSelector.cs" />
    107103    <None Include="Properties\AssemblyInfo.cs.frame" />
    108104  </ItemGroup>
     
    115111      <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project>
    116112      <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name>
     113    </ProjectReference>
     114    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
     115      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
     116      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     117    </ProjectReference>
     118    <ProjectReference Include="..\..\HeuristicLab.Problems.ConditionActionClassification\3.3\HeuristicLab.Problems.ConditionActionClassification-3.3.csproj">
     119      <Project>{EA51D441-F6A3-41E1-9993-A2488E93C222}</Project>
     120      <Name>HeuristicLab.Problems.ConditionActionClassification-3.3</Name>
    117121    </ProjectReference>
    118122  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs

    r8941 r9089  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
    26 using HeuristicLab.Encodings.CombinedIntegerVectorEncoding;
    27 using HeuristicLab.Operators;
     26using HeuristicLab.Encodings.ConditionActionEncoding;
    2827using HeuristicLab.Optimization;
    29 using HeuristicLab.Optimization.Operators;
    3028using HeuristicLab.Parameters;
    3129using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3937  [Creatable("Algorithms")]
    4038  [StorableClass]
    41   public class LearningClassifierSystem : HeuristicOptimizationEngineAlgorithm, IStorableContent {
     39  public sealed class LearningClassifierSystem : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    4240    public string Filename { get; set; }
    4341
    4442    #region Problem Properties
    4543    public override Type ProblemType {
    46       get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
    47     }
    48     public new ISingleObjectiveHeuristicOptimizationProblem Problem {
    49       get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
     44      get { return typeof(IConditionActionProblem); }
     45    }
     46    public new IConditionActionProblem Problem {
     47      get { return (IConditionActionProblem)base.Problem; }
    5048      set { base.Problem = value; }
    5149    }
     
    5957      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    6058    }
     59    private ValueParameter<BoolValue> CreateInitialPopulationParameter {
     60      get { return (ValueParameter<BoolValue>)Parameters["CreateInitialPopulation"]; }
     61    }
    6162    private ValueParameter<IntValue> PopulationSizeParameter {
    62       get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
    63     }
    64     //for test purpose
    65     public ValueParameter<ICombinedIntegerVectorCreator> SolutionCreatorParameter {
    66       get { return (ValueParameter<ICombinedIntegerVectorCreator>)Parameters["SolutionCreator"]; }
    67     }
    68     public ValueParameter<IntValue> Length {
    69       get { return (ValueParameter<IntValue>)Parameters["Length"]; }
    70     }
    71     public ValueParameter<IntValue> ActionPartLength {
    72       get { return (ValueParameter<IntValue>)Parameters["ActionPartLength"]; }
    73     }
    74     public ValueParameter<IntMatrix> Bounds {
    75       get { return (ValueParameter<IntMatrix>)Parameters["Bounds"]; }
     63      get { return (ValueParameter<IntValue>)Parameters["N"]; }
     64    }
     65    private ValueParameter<PercentValue> BetaParameter {
     66      get { return (ValueParameter<PercentValue>)Parameters["Beta"]; }
     67    }
     68    private ValueParameter<PercentValue> AlphaParameter {
     69      get { return (ValueParameter<PercentValue>)Parameters["Alpha"]; }
     70    }
     71    private ValueParameter<DoubleValue> ErrorZeroParameter {
     72      get { return (ValueParameter<DoubleValue>)Parameters["ErrorZero"]; }
     73    }
     74    private ValueParameter<DoubleValue> PowerParameter {
     75      get { return (ValueParameter<DoubleValue>)Parameters["v"]; }
     76    }
     77    private ValueParameter<PercentValue> GammaParameter {
     78      get { return (ValueParameter<PercentValue>)Parameters["Gamma"]; }
     79    }
     80    private ValueParameter<PercentValue> CrossoverProbabilityParameter {
     81      get { return (ValueParameter<PercentValue>)Parameters["CrossoverProbability"]; }
     82    }
     83    private ValueParameter<PercentValue> MutationProbabilityParameter {
     84      get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
     85    }
     86    private ValueParameter<IntValue> ThetaGAParameter {
     87      get { return (ValueParameter<IntValue>)Parameters["ThetaGA"]; }
     88    }
     89    private ValueParameter<IntValue> ThetaDeletionParameter {
     90      get { return (ValueParameter<IntValue>)Parameters["ThetaDeletion"]; }
     91    }
     92    private ValueParameter<IntValue> ThetaSubsumptionParameter {
     93      get { return (ValueParameter<IntValue>)Parameters["ThetaSubsumption"]; }
     94    }
     95    private ValueParameter<PercentValue> DeltaParameter {
     96      get { return (ValueParameter<PercentValue>)Parameters["Delta"]; }
     97    }
     98    private ValueParameter<PercentValue> ExplorationProbabilityParameter {
     99      get { return (ValueParameter<PercentValue>)Parameters["ExplorationProbability"]; }
     100    }
     101    private ValueParameter<BoolValue> DoGASubsumptionParameter {
     102      get { return (ValueParameter<BoolValue>)Parameters["DoGASubsumption"]; }
     103    }
     104    private ValueParameter<BoolValue> DoActionSetSubsumptionParameter {
     105      get { return (ValueParameter<BoolValue>)Parameters["DoActionSetSubsumption"]; }
    76106    }
    77107    #endregion
     
    86116      set { SetSeedRandomlyParameter.Value = value; }
    87117    }
     118    public BoolValue CreateInitialPopulation {
     119      get { return CreateInitialPopulationParameter.Value; }
     120      set { CreateInitialPopulationParameter.Value = value; }
     121    }
    88122    public IntValue PopulationSize {
    89123      get { return PopulationSizeParameter.Value; }
    90124      set { PopulationSizeParameter.Value = value; }
    91125    }
    92 
     126    public PercentValue Beta {
     127      get { return BetaParameter.Value; }
     128      set { BetaParameter.Value = value; }
     129    }
     130    public PercentValue Alpha {
     131      get { return AlphaParameter.Value; }
     132      set { AlphaParameter.Value = value; }
     133    }
     134    public DoubleValue ErrorZero {
     135      get { return ErrorZeroParameter.Value; }
     136      set { ErrorZeroParameter.Value = value; }
     137    }
     138    public DoubleValue Power {
     139      get { return PowerParameter.Value; }
     140      set { PowerParameter.Value = value; }
     141    }
     142    public PercentValue Gamma {
     143      get { return GammaParameter.Value; }
     144      set { GammaParameter.Value = value; }
     145    }
     146    public PercentValue CrossoverProbability {
     147      get { return CrossoverProbabilityParameter.Value; }
     148      set { CrossoverProbabilityParameter.Value = value; }
     149    }
     150    public PercentValue MutationProbability {
     151      get { return MutationProbabilityParameter.Value; }
     152      set { MutationProbabilityParameter.Value = value; }
     153    }
     154    public IntValue ThetaGA {
     155      get { return ThetaGAParameter.Value; }
     156      set { ThetaGAParameter.Value = value; }
     157    }
     158    public IntValue ThetaDeletion {
     159      get { return ThetaDeletionParameter.Value; }
     160      set { ThetaDeletionParameter.Value = value; }
     161    }
     162    public IntValue ThetaSubsumption {
     163      get { return ThetaSubsumptionParameter.Value; }
     164      set { ThetaSubsumptionParameter.Value = value; }
     165    }
     166    public PercentValue Delta {
     167      get { return DeltaParameter.Value; }
     168      set { DeltaParameter.Value = value; }
     169    }
     170    public PercentValue ExplorationProbability {
     171      get { return ExplorationProbabilityParameter.Value; }
     172      set { ExplorationProbabilityParameter.Value = value; }
     173    }
     174    public BoolValue DoGASubsumption {
     175      get { return DoGASubsumptionParameter.Value; }
     176      set { DoGASubsumptionParameter.Value = value; }
     177    }
     178    public BoolValue DoActionSetSubsumption {
     179      get { return DoActionSetSubsumptionParameter.Value; }
     180      set { DoActionSetSubsumptionParameter.Value = value; }
     181    }
     182    private RandomCreator RandomCreator {
     183      get { return (RandomCreator)OperatorGraph.InitialOperator; }
     184    }
     185    public LearningClassifierSystemMainLoop MainLoop {
     186      get { return (LearningClassifierSystemMainLoop)RandomCreator.Successor; }
     187    }
    93188    #endregion
    94189
     
    98193      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    99194      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    100       Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
    101       //for test purpose
    102       Parameters.Add(new ValueParameter<ICombinedIntegerVectorCreator>("SolutionCreator", "The operator to create a solution.", new UniformRandomCombinedIntegerVectorCreator()));
    103       Parameters.Add(new ValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(3)));
    104       Parameters.Add(new ValueParameter<IntValue>("ActionPartLength", "The operator to create a solution.", new IntValue(1)));
    105       int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 2 } };
    106       Parameters.Add(new ValueParameter<IntMatrix>("Bounds", "The operator to create a solution.", new IntMatrix(elements)));
     195      Parameters.Add(new ValueParameter<BoolValue>("CreateInitialPopulation", "Specifies if a population should be created at the beginning of the algorithm.", new BoolValue(false)));
     196      Parameters.Add(new ValueParameter<IntValue>("N", "Max size of the population of solutions.", new IntValue(100)));
     197      Parameters.Add(new ValueParameter<PercentValue>("Beta", "Learning rate", new PercentValue(0.1)));
     198      Parameters.Add(new ValueParameter<PercentValue>("Alpha", "", new PercentValue(0.1)));
     199      Parameters.Add(new ValueParameter<DoubleValue>("ErrorZero", "The error below which classifiers are considered to have equal accuracy", new DoubleValue(10)));
     200      Parameters.Add(new ValueParameter<DoubleValue>("v", "Power parameter", new DoubleValue(5)));
     201      Parameters.Add(new ValueParameter<PercentValue>("Gamma", "Discount factor", new PercentValue(0.71)));
     202      Parameters.Add(new ValueParameter<PercentValue>("CrossoverProbability", "Probability of crossover", new PercentValue(0.9)));
     203      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "Probability of mutation", new PercentValue(0.05)));
     204      Parameters.Add(new ValueParameter<IntValue>("ThetaGA", "GA threshold. GA is applied in a set when the average time since the last GA is greater than ThetaGA.", new IntValue(25)));
     205      Parameters.Add(new ValueParameter<IntValue>("ThetaDeletion", "Deletion threshold. If the experience of a classifier is greater than ThetaDeletion, its fitness may be considered in its probability of deletion.", new IntValue(20)));
     206      Parameters.Add(new ValueParameter<IntValue>("ThetaSubsumption", "Subsumption threshold. The experience of a classifier must be greater than TheatSubsumption to be able to subsume another classifier.", new IntValue(20)));
     207      Parameters.Add(new ValueParameter<PercentValue>("Delta", "Delta specifies the fraction of mean fitness in [P] below which the fitness of a classifier may be considered in its probability of deletion", new PercentValue(0.1)));
     208      Parameters.Add(new ValueParameter<PercentValue>("ExplorationProbability", "Probability of selecting the action uniform randomly", new PercentValue(0.5)));
     209      Parameters.Add(new ValueParameter<BoolValue>("DoGASubsumption", "Specifies if offsprings are tested for possible logical subsumption by parents.", new BoolValue(true)));
     210      Parameters.Add(new ValueParameter<BoolValue>("DoActionSetSubsumption", "Specifies if action set is tested for subsuming classifiers.", new BoolValue(true)));
    107211      #endregion
    108212
    109213      #region Create operators
    110214      RandomCreator randomCreator = new RandomCreator();
    111       SolutionsCreator solutionsCreator = new SolutionsCreator();
    112       UniformSubScopesProcessor uniformSubScopeProcessor = new UniformSubScopesProcessor();
    113       UniformRandomizer uniformRandomizer = new UniformRandomizer();
     215
    114216      //ResultsCollector resultsCollector = new ResultsCollector();
    115217      LearningClassifierSystemMainLoop mainLoop = new LearningClassifierSystemMainLoop();
     
    120222      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
    121223      randomCreator.SetSeedRandomlyParameter.Value = null;
    122 
    123       SolutionCreatorParameter.Value.ActionPartLengthParameter.ActualName = ActionPartLength.Name;
    124       SolutionCreatorParameter.Value.LengthParameter.ActualName = Length.Name;
    125       SolutionCreatorParameter.Value.BoundsParameter.ActualName = Bounds.Name;
    126 
    127       solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
    128       solutionsCreator.SolutionCreatorParameter.ActualName = SolutionCreatorParameter.Name;
    129 
    130       uniformSubScopeProcessor.Parallel = new BoolValue(true);
    131 
    132       uniformRandomizer.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
    133       uniformRandomizer.MinParameter.Value = new DoubleValue(0);
    134       uniformRandomizer.MaxParameter.Value = new DoubleValue(100);
    135       uniformRandomizer.ValueParameter.ActualName = "Fitness";
    136 
    137224      #endregion
    138225
    139226      #region Create operator graph
    140227      OperatorGraph.InitialOperator = randomCreator;
    141       randomCreator.Successor = solutionsCreator;
    142       solutionsCreator.Successor = uniformSubScopeProcessor;
    143       uniformSubScopeProcessor.Operator = uniformRandomizer;
    144       uniformSubScopeProcessor.Successor = mainLoop;
     228      randomCreator.Successor = mainLoop;
    145229      #endregion
    146230    }
    147     protected LearningClassifierSystem(LearningClassifierSystem original, Cloner cloner)
     231    private LearningClassifierSystem(LearningClassifierSystem original, Cloner cloner)
    148232      : base(original, cloner) {
    149233    }
     
    153237    [StorableConstructor]
    154238    private LearningClassifierSystem(bool deserializing) : base(deserializing) { }
     239
     240    protected override void OnProblemChanged() {
     241      if (Problem != null) {
     242        ParameterizeEvaluator(Problem.Evaluator);
     243        MainLoop.SetCurrentProblem(Problem);
     244      }
     245      base.OnProblemChanged();
     246    }
     247    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
     248      ParameterizeEvaluator(Problem.Evaluator);
     249      MainLoop.SetCurrentProblem(Problem);
     250      base.Problem_EvaluatorChanged(sender, e);
     251    }
     252    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
     253      MainLoop.SetCurrentProblem(Problem);
     254      base.Problem_SolutionCreatorChanged(sender, e);
     255    }
     256
     257    private void ParameterizeEvaluator(IXCSEvaluator evaluator) {
     258      evaluator.ActualTimeParameter.ActualName = "Iteration";
     259      evaluator.BetaParameter.ActualName = BetaParameter.Name;
     260      evaluator.AlphaParameter.ActualName = AlphaParameter.Name;
     261      evaluator.PowerParameter.ActualName = PowerParameter.Name;
     262      evaluator.ErrorZeroParameter.ActualName = ErrorZeroParameter.Name;
     263    }
    155264  }
    156265}
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs

    r8941 r9089  
    2020#endregion
    2121
    22 using HeuristicLab.Algorithms.GeneticAlgorithm;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
    2524using HeuristicLab.Data;
    26 using HeuristicLab.Encodings.CombinedIntegerVectorEncoding;
     25using HeuristicLab.Encodings.ConditionActionEncoding;
    2726using HeuristicLab.Encodings.IntegerVectorEncoding;
    2827using HeuristicLab.Operators;
     
    3130using HeuristicLab.Parameters;
    3231using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    33 using HeuristicLab.Random;
    3432using HeuristicLab.Selection;
    3533
     
    4038  [Item("LearningClassifierSystemMainLoop", "An operator which represents the main loop of a learning classifier system.")]
    4139  [StorableClass]
    42   public class LearningClassifierSystemMainLoop : AlgorithmOperator {
     40  public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator {
    4341
    4442    #region Parameter Properties
     
    5452    #endregion
    5553
    56     #region Properties
    57     public ISelector Selector {
    58       get { return SelectorParameter.Value; }
    59       set { SelectorParameter.Value = value; }
    60     }
    61     public ICrossover Crossover {
    62       get { return CrossoverParameter.Value; }
    63       set { CrossoverParameter.Value = value; }
    64     }
    65     public IManipulator Mutator {
    66       get { return MutatorParameter.Value; }
    67       set { MutatorParameter.Value = value; }
    68     }
     54    #region private properties
     55    private SolutionsCreator initialSolutionsCreator;
     56    private SolutionsCreator coveringMechanism;
     57    private MatchConditionOperator matchConditionOperator;
     58    private PredictionArrayCalculator predictionArrayCalculator;
     59    private ActionSelector actionSelector;
     60
     61    private Placeholder evaluator;
     62    private Placeholder actionExecuter;
     63    private Placeholder classifierFetcher;
    6964    #endregion
    7065
    7166    [StorableConstructor]
    7267    private LearningClassifierSystemMainLoop(bool deserializing) : base(deserializing) { }
    73     protected LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
     68    private LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
    7469      : base(original, cloner) {
    7570    }
     
    8580      #region Create parameters
    8681      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.", new ItemSet<ISelector>() { new ProportionalSelector() }, new ProportionalSelector()));
    87       Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.", new ItemSet<ICrossover>() { new SinglePointCrossover() }, new SinglePointCrossover()));
    88       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.", new ItemSet<IManipulator>() { new UniformOnePositionManipulator() }, new UniformOnePositionManipulator()));
    89       //for test purposes
    90       int[] numbers = new int[3] { 1, 1, 1 };
    91       int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 2 } };
    92       Parameters.Add(new ValueLookupParameter<CombinedIntegerVector>("TestTarget", "Target for test", new CombinedIntegerVector(numbers, 1, elements)));
    93 
     82      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.", new ItemSet<ICrossover>() { new HeuristicLab.Encodings.CombinedIntegerVectorEncoding.SinglePointCrossover() }, new HeuristicLab.Encodings.CombinedIntegerVectorEncoding.SinglePointCrossover()));
     83      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
     84      UniformOnePositionManipulator test = new UniformOnePositionManipulator();
     85      test.IntegerVectorParameter.ActualName = "CombinedIntegerVector";
     86      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.", new ItemSet<IManipulator>() { new UniformOnePositionManipulator() }, test));
    9487      #endregion
    9588
    9689      #region Create operators
    9790      VariableCreator variableCreator = new VariableCreator();
    98       MatchSelector conditionMatchSelector = new MatchSelector();
    99       MatchSelector actionMatchSelector = new MatchSelector();
     91      ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
     92      initialSolutionsCreator = new SolutionsCreator();
     93      IntCounter iterationCounter = new IntCounter();
     94      UniformSubScopesProcessor matchCondtionSubScopesProcessor = new UniformSubScopesProcessor();
     95      matchConditionOperator = new MatchConditionOperator();
     96      predictionArrayCalculator = new PredictionArrayCalculator();
     97      actionSelector = new ActionSelector();
     98      UniformSubScopesProcessor matchActionSubScopesProcessor = new UniformSubScopesProcessor();
     99      MatchActionOperator matchActionOperator = new MatchActionOperator();
     100      ConditionalSelector conditionMatchSelector = new ConditionalSelector();
     101      ConditionalSelector actionMatchSelector = new ConditionalSelector();
    100102      SubScopesProcessor coveringSubScopesProcessor = new SubScopesProcessor();
    101       SubScopesRemover subScopesRemover = new SubScopesRemover();
     103      SubScopesCounter matchsetCounter = new SubScopesCounter();
    102104      Comparator comparator = new Comparator();
    103       ConditionalBranch conditionalBranch = new ConditionalBranch();
     105      ConditionalBranch coveringConditionalBranch = new ConditionalBranch();
    104106      MergingReducer mergingReducer = new MergingReducer();
    105       SolutionsCreator coveringMechanism = new SolutionsCreator();
    106       SubScopesProcessor actionSelectionSubScopesProcessor = new SubScopesProcessor();
    107       MaxValueActionSelector maxValueActionSelection = new MaxValueActionSelector();
    108       GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop();
    109 
    110       UniformSubScopesProcessor uniformSubScopeProcessor = new UniformSubScopesProcessor();
    111       UniformRandomizer uniformRandomizer = new UniformRandomizer();
     107      MergingReducer mergingReducerWithSuccessor = new MergingReducer();
     108      coveringMechanism = new SolutionsCreator();
     109      evaluator = new Placeholder();
     110      SubScopesProcessor actionSetSubScopesProcessor = new SubScopesProcessor();
     111      DataReducer actionSetSizeDataReducer = new DataReducer();
     112      UniformSubScopesProcessor accuracySubScopesProcessor = new UniformSubScopesProcessor();
     113      CalculateAccuracy calculateAccuracy = new CalculateAccuracy();
     114      SumAccuracy sumAccuracy = new SumAccuracy();
     115      UniformSubScopesProcessor updateParametersSubScopesProcessor = new UniformSubScopesProcessor();
     116      LCSAdaptedGeneticAlgorithm adaptedGeneticAlgorithmMainLoop = new LCSAdaptedGeneticAlgorithm();
     117
     118      classifierFetcher = new Placeholder();
     119      actionExecuter = new Placeholder();
    112120
    113121      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("ZeroIntValue", new IntValue(0)));
    114122      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OneIntValue", new IntValue(1)));
     123      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iteration", new IntValue(0)));
     124
     125      initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
     126
     127      initialSolutionsCreator.NumberOfSolutionsParameter.ActualName = "N";
     128
     129      iterationCounter.ValueParameter.ActualName = "Iteration";
     130      iterationCounter.IncrementParameter.ActualName = "OneIntValue";
     131
     132      matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
     133
     134      matchConditionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
    115135
    116136      conditionMatchSelector.CopySelected = new BoolValue(false);
    117       conditionMatchSelector.MatchCondition = new BoolValue(true);
    118       //this has to be set differently
    119       conditionMatchSelector.MatchParameter.ActualName = "CombinedIntegerVector";
    120       conditionMatchSelector.TargetMatchParameter.ActualName = "TestTarget";
     137      conditionMatchSelector.ConditionParameter.ActualName = "MatchCondition";
     138
     139      matchsetCounter.Name = "Count number of rules in match set";
     140      matchsetCounter.AccumulateParameter.Value = new BoolValue(false);
     141      matchsetCounter.ValueParameter.ActualName = "MatchSetCount";
    121142
    122143      comparator.Comparison = new Comparison(ComparisonType.LessOrEqual);
    123       comparator.LeftSideParameter.ActualName = conditionMatchSelector.NumberOfSelectedSubScopesParameter.ActualName;
     144      comparator.LeftSideParameter.ActualName = matchsetCounter.ValueParameter.ActualName;
    124145      comparator.ResultParameter.ActualName = "Covering";
    125146      //more than zero solutions have to be selected
    126147      comparator.RightSideParameter.ActualName = "ZeroIntValue";
    127148
    128       conditionalBranch.ConditionParameter.ActualName = "Covering";
    129 
    130       subScopesRemover.SubScopeIndexParameter.ActualName = "OneIntValue";
    131       subScopesRemover.RemoveAllSubScopes = false;
     149      coveringConditionalBranch.Name = "Covering Branch";
     150      coveringConditionalBranch.ConditionParameter.ActualName = "Covering";
     151
     152      matchActionSubScopesProcessor.Operator = matchActionOperator;
     153
     154      matchActionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
     155      matchActionOperator.TargetMatchParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
    132156
    133157      coveringMechanism.NumberOfSolutionsParameter.ActualName = "OneIntValue";
    134       coveringMechanism.SolutionCreatorParameter.ActualName = "SolutionCreator";
    135 
    136       maxValueActionSelection.ValueParameter.ActualName = "Fitness";
    137       maxValueActionSelection.MatchParameter.ActualName = "CombinedIntegerVector";
     158
     159      predictionArrayCalculator.MatchParameter.ActualName = "CombinedIntegerVector";
     160
     161      actionSelector.PredictionArrayParameter.ActualName = predictionArrayCalculator.PredictionArrayParameter.Name;
     162      actionSelector.RandomParameter.ActualName = "Random";
     163      actionSelector.ExplorationProbabilityParameter.ActualName = "ExplorationProbability";
    138164
    139165      actionMatchSelector.CopySelected = new BoolValue(false);
    140       actionMatchSelector.MatchCondition = new BoolValue(false);
    141       //this has to be set differently
    142       actionMatchSelector.MatchParameter.ActualName = "CombinedIntegerVector";
    143       actionMatchSelector.TargetMatchParameter.ActualName = maxValueActionSelection.SelectedActionParameter.ActualName;
     166      actionMatchSelector.ConditionParameter.ActualName = "MatchAction";
    144167
    145168      SelectorParameter.Value.CopySelected = new BoolValue(true);
    146169      SelectorParameter.Value.NumberOfSelectedSubScopesParameter.Value = new IntValue(200);
    147170
    148       geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
    149       geneticAlgorithmMainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
    150       geneticAlgorithmMainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
    151       geneticAlgorithmMainLoop.RandomParameter.ActualName = "Random";
    152       geneticAlgorithmMainLoop.ElitesParameter.ActualName = "OneIntValue";
    153       geneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue";
    154       geneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness";
     171      evaluator.Name = "Evaluator";
     172
     173      classifierFetcher.Name = "ClassifierFetcher";
     174
     175      actionExecuter.Name = "ActionExecuter";
     176
     177      actionSetSizeDataReducer.TargetParameter.ActualName = "CurrentActionSetSize";
     178      actionSetSizeDataReducer.ParameterToReduce.ActualName = "Numerosity";
     179      actionSetSizeDataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     180      actionSetSizeDataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
     181
     182      calculateAccuracy.AlphaParameter.ActualName = "Alpha";
     183      calculateAccuracy.ErrorParameter.ActualName = "Error";
     184      calculateAccuracy.ErrorZeroParameter.ActualName = "ErrorZero";
     185      calculateAccuracy.PowerParameter.ActualName = "v";
     186
     187      sumAccuracy.AccuracyParameter.ActualName = calculateAccuracy.AccuracyParameter.ActualName;
     188      sumAccuracy.NumerosityParameter.ActualName = "Numerosity";
     189
     190      adaptedGeneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
     191      adaptedGeneticAlgorithmMainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
     192      adaptedGeneticAlgorithmMainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
     193      adaptedGeneticAlgorithmMainLoop.RandomParameter.ActualName = "Random";
     194      adaptedGeneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue";
     195      adaptedGeneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness";
    155196      //needed?
    156       geneticAlgorithmMainLoop.MutationProbabilityParameter.Value = new PercentValue(10);
    157       geneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
    158 
    159       uniformSubScopeProcessor.Parallel = new BoolValue(true);
    160 
    161       uniformRandomizer.RandomParameter.ActualName = "Random";
    162       uniformRandomizer.MinParameter.Value = new DoubleValue(0);
    163       uniformRandomizer.MaxParameter.Value = new DoubleValue(100);
    164       uniformRandomizer.ValueParameter.ActualName = "Fitness";
    165 
    166       //ParameterizeSelectors();
     197      adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter.Value = new PercentValue(10);
     198      adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
    167199      #endregion
    168200
    169201      #region Create operator graph
    170202      OperatorGraph.InitialOperator = variableCreator;
    171       variableCreator.Successor = conditionMatchSelector;
    172       //variableCreator.Successor = geneticAlgorithmMainLoop;
    173       //geneticAlgorithmMainLoop.Successor = conditionMatchSelector;
    174       conditionMatchSelector.Successor = comparator;
    175       comparator.Successor = conditionalBranch;
    176       conditionalBranch.TrueBranch = coveringSubScopesProcessor;
    177       conditionalBranch.FalseBranch = actionSelectionSubScopesProcessor;
    178       conditionalBranch.Successor = subScopesRemover;
    179       coveringMechanism.Successor = uniformSubScopeProcessor;
    180       uniformSubScopeProcessor.Operator = uniformRandomizer;
     203
     204      variableCreator.Successor = initialPopulationConditionalBranch;
     205      initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
     206      initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
     207      initialPopulationConditionalBranch.Successor = classifierFetcher;
     208      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
     209      matchCondtionSubScopesProcessor.Successor = conditionMatchSelector;
     210      //variableCreator.Successor = adaptedGeneticAlgorithmMainLoop;
     211      //adaptedGeneticAlgorithmMainLoop.Successor = conditionMatchSelector;
     212
     213      conditionMatchSelector.Successor = coveringSubScopesProcessor;
    181214      coveringSubScopesProcessor.Operators.Add(new EmptyOperator());
    182       coveringSubScopesProcessor.Operators.Add(coveringMechanism);
    183       coveringSubScopesProcessor.Successor = actionSelectionSubScopesProcessor;
    184       actionSelectionSubScopesProcessor.Operators.Add(new EmptyOperator());
    185       actionSelectionSubScopesProcessor.Operators.Add(maxValueActionSelection);
    186       maxValueActionSelection.Successor = actionMatchSelector;
    187       subScopesRemover.Successor = mergingReducer;
    188       mergingReducer.Successor = conditionMatchSelector;
    189       //mergingReducer.Successor = geneticAlgorithmMainLoop;
     215      coveringSubScopesProcessor.Operators.Add(matchsetCounter);
     216      coveringSubScopesProcessor.Successor = mergingReducerWithSuccessor;
     217      matchsetCounter.Successor = comparator;
     218      comparator.Successor = coveringConditionalBranch;
     219      coveringConditionalBranch.TrueBranch = coveringMechanism;
     220      coveringConditionalBranch.FalseBranch = new EmptyOperator();
     221      coveringConditionalBranch.Successor = predictionArrayCalculator;
     222      predictionArrayCalculator.Successor = actionSelector;
     223      actionSelector.Successor = matchActionSubScopesProcessor;
     224      matchActionSubScopesProcessor.Successor = actionMatchSelector;
     225      actionMatchSelector.Successor = actionExecuter;
     226      actionExecuter.Successor = actionSetSubScopesProcessor;
     227      actionSetSubScopesProcessor.Operators.Add(new EmptyOperator());
     228      actionSetSubScopesProcessor.Operators.Add(actionSetSizeDataReducer);
     229      actionSetSizeDataReducer.Successor = accuracySubScopesProcessor;
     230      accuracySubScopesProcessor.Operator = calculateAccuracy;
     231      accuracySubScopesProcessor.Successor = sumAccuracy;
     232      sumAccuracy.Successor = updateParametersSubScopesProcessor;
     233      updateParametersSubScopesProcessor.Operator = evaluator;
     234
     235      actionSetSubScopesProcessor.Successor = mergingReducer;
     236
     237      mergingReducerWithSuccessor.Successor = iterationCounter;
     238      iterationCounter.Successor = classifierFetcher;
     239      //mergingReducer.Successor = adaptedGeneticAlgorithmMainLoop;
    190240      #endregion
    191241    }
     
    197247        stochasticOp.RandomParameter.Hidden = true;
    198248      }
     249    }
     250
     251    internal void SetCurrentProblem(IConditionActionProblem problem) {
     252      initialSolutionsCreator.SolutionCreatorParameter.ActualName = problem.SolutionCreatorParameter.Name;
     253      initialSolutionsCreator.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
     254
     255      coveringMechanism.SolutionCreatorParameter.ActualName = problem.SolutionCreatorParameter.Name;
     256      coveringMechanism.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
     257
     258      problem.ActionExecuter.SelectedActionParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
     259
     260      problem.ClassifierFetcher.IterationParameter.ActualName = "Iteration";
     261
     262      evaluator.OperatorParameter.ActualName = problem.EvaluatorParameter.Name;
     263
     264      classifierFetcher.OperatorParameter.ActualName = problem.ClassifierFetcherParameter.Name;
     265
     266      actionExecuter.OperatorParameter.ActualName = problem.ActionExecuterParameter.Name;
     267
     268      matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.Name;
     269
     270      predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName;
     271      predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName;
    199272    }
    200273    //private void ParameterizeSelectors() {
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3

    • Property svn:ignore set to
      *.user
      Plugin.cs
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVector.cs

    r8941 r9089  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Encodings.ConditionActionEncoding;
    2729using HeuristicLab.Encodings.IntegerVectorEncoding;
    2830using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3133  [StorableClass]
    3234  [Item("CombinedIntegerVector", "Represents a combined vector of integer values.")]
    33   public class CombinedIntegerVector : IntegerVector, IMatching {
     35  public class CombinedIntegerVector : IntegerVector, IClassifier {
    3436
    3537    [Storable]
    36     protected int actionPart;
     38    protected int actionLength;
     39    public int ActionLength { get { return actionLength; } }
    3740
    3841    /// <summary>
     
    4245    /// </summary>
    4346    [Storable]
    44     protected int[,] bounds;
     47    protected IntMatrix bounds;
     48    public IntMatrix Bounds { get { return (IntMatrix)bounds.Clone(); } }
    4549
    4650    [StorableConstructor]
     
    4852    public CombinedIntegerVector() : base() { }
    4953
    50     public CombinedIntegerVector(int[] elements, int actionPart, int[,] bounds)
     54    public CombinedIntegerVector(int[] elements, int actionPart, IntMatrix bounds)
    5155      : base(elements) {
    52       this.actionPart = actionPart;
     56      this.actionLength = actionPart;
    5357      //check if combinedVector satisfies bounds and if bounds is set correctly (at leats one row with 2 columns) is missing!
    5458      this.bounds = bounds;
    5559    }
    5660
    57     public CombinedIntegerVector(IntegerVector combinedVector, int actionPart, int[,] bounds)
     61    public CombinedIntegerVector(IntegerVector combinedVector, int actionPart, IntMatrix bounds)
    5862      : this(combinedVector.ToArray(), actionPart, bounds) { }
    5963
    60     public CombinedIntegerVector(IntegerVector condition, IntegerVector action, int[,] bounds)
     64    public CombinedIntegerVector(IntegerVector condition, IntegerVector action, IntMatrix bounds)
    6165      : base(condition.Concat(action).ToArray()) {
    62       actionPart = action.Length;
     66      actionLength = action.Length;
    6367      //check if combinedVector satisfies bounds and if bounds is set correctly (at leats one row with 2 columns) is missing!
    6468      this.bounds = bounds;
    6569    }
    6670
     71    public CombinedIntegerVector(IntegerVector condition, IntMatrix conditionBounds, IntegerVector action, IntMatrix actionBounds)
     72      : this(condition, action, CombineBounds(conditionBounds, actionBounds)) {
     73    }
     74
     75    private static IntMatrix CombineBounds(IntMatrix conditionBounds, IntMatrix actionBounds) {
     76      int columns = conditionBounds.Columns < actionBounds.Columns ? conditionBounds.Columns : actionBounds.Columns;
     77      IntMatrix bounds = new IntMatrix(conditionBounds.Rows + actionBounds.Rows, columns);
     78      for (int i = 0; i < conditionBounds.Rows; i++) {
     79        for (int j = 0; j < columns; j++) {
     80          bounds[i, j] = conditionBounds[i % conditionBounds.Rows, j];
     81        }
     82      }
     83
     84      for (int i = conditionBounds.Rows; i < actionBounds.Rows + conditionBounds.Rows; i++) {
     85        for (int j = 0; j < columns; j++) {
     86          bounds[i, j] = actionBounds[i % actionBounds.Rows, j];
     87        }
     88      }
     89      return bounds;
     90    }
     91
    6792    public CombinedIntegerVector(IRandom random, int length, int min, int max, int actionLenght, int actionMin, int actionMax) :
    6893      this(new IntegerVector(length, random, min, max), new IntegerVector(actionLenght, random, actionMin, actionMax), null) {
    69       bounds = new int[length + actionLenght, 2];
     94      bounds = new IntMatrix(length + actionLenght, 2);
    7095      for (int i = 0; i < length; i++) {
    7196        bounds[i, 0] = min;
     
    78103    }
    79104
    80     public CombinedIntegerVector(int length, int actionPart, int[,] bounds)
     105    public CombinedIntegerVector(int length, int actionPart, IntMatrix bounds)
    81106      : base(length) {
    82       this.actionPart = actionPart;
     107      this.actionLength = actionPart;
    83108      this.bounds = bounds;
    84109    }
     
    86111    protected CombinedIntegerVector(CombinedIntegerVector original, Cloner cloner)
    87112      : base(original, cloner) {
    88       actionPart = original.actionPart;
    89       bounds = (int[,])original.bounds.Clone();
    90     }
     113      actionLength = original.actionLength;
     114      bounds = (IntMatrix)original.bounds.Clone();
     115    }
     116
    91117    public override IDeepCloneable Clone(Cloner cloner) {
    92118      return new CombinedIntegerVector(this, cloner);
    93119    }
    94120
    95     public IMatching Condition {
     121    public IClassifier Condition {
    96122      get {
    97         int[] condition = new int[Length - actionPart];
    98         Array.Copy(this.array, condition, Length - actionPart);
     123        int[] condition = new int[Length - actionLength];
     124        Array.Copy(this.array, condition, Length - actionLength);
    99125        return new CombinedIntegerVector(condition, 0, bounds);
    100126      }
    101127    }
    102128
    103     public IMatching Action {
     129    public IClassifier Action {
    104130      get {
    105         int[] action = new int[actionPart];
    106         Array.Copy(this.array, Length - actionPart, action, 0, actionPart);
    107         return new CombinedIntegerVector(action, actionPart, bounds);
    108       }
    109     }
    110 
    111     public bool MatchCondition(IMatching target) {
     131        int[] action = new int[actionLength];
     132        Array.Copy(this.array, Length - actionLength, action, 0, actionLength);
     133
     134        IntMatrix actionBounds = GetElementsOfBoundsForAction(bounds, Length, actionLength);
     135        return new CombinedIntegerVector(action, actionLength, actionBounds);
     136      }
     137    }
     138
     139    private IntMatrix GetElementsOfBoundsForAction(IntMatrix bounds, int length, int actionPartLength) {
     140      IntMatrix actionBounds = new IntMatrix(actionPartLength, bounds.Columns);
     141      int start = length - actionPartLength;
     142      for (int i = start; i < length; i++) {
     143        int pos = i % bounds.Rows;
     144        for (int j = 0; j < bounds.Columns; j++) {
     145          actionBounds[i - start, j] = bounds[pos, j];
     146        }
     147      }
     148      return actionBounds;
     149    }
     150
     151    public bool MatchCondition(IClassifier target) {
    112152      var targetVector = target as CombinedIntegerVector;
    113153      if (targetVector == null) return false;
     
    115155
    116156      int curbounds;
    117       for (int i = 0; i < this.Length - this.actionPart; i++) {
    118         curbounds = i % bounds.GetLength(0);
     157      for (int i = 0; i < this.Length - this.actionLength; i++) {
     158        curbounds = i % bounds.Rows;
    119159        //if don't care symbol is matched, next indices can be checked
    120160        if (this[i].Equals(bounds[curbounds, 1] - 1)) {
     
    129169
    130170    // no "don't care" symbols have to be considered
    131     public bool MatchAction(IMatching target) {
     171    public bool MatchAction(IClassifier target) {
    132172      var targetVector = target as CombinedIntegerVector;
    133173      if (targetVector == null) return false;
    134       if (targetVector.actionPart != this.actionPart) return false;
    135 
    136       int curPos = this.Length - this.actionPart;
    137       int curTargetPos = targetVector.Length - targetVector.actionPart;
    138       for (int i = 0; i < this.actionPart; i++) {
     174      if (targetVector.actionLength != this.actionLength) return false;
     175
     176      int curPos = this.Length - this.actionLength;
     177      int curTargetPos = targetVector.Length - targetVector.actionLength;
     178      for (int i = 0; i < this.actionLength; i++) {
    139179        if (!this[curPos + i].Equals(targetVector[curTargetPos + i])) {
    140180          return false;
     
    149189      int curbounds;
    150190      for (int i = 0; i < this.Length; i++) {
    151         curbounds = i % bounds.GetLength(0);
    152         if (i >= this.Length - this.actionPart || this[i] < bounds[curbounds, 1] - 1) {
     191        curbounds = i % bounds.Rows;
     192        if (i >= this.Length - this.actionLength || this[i] < bounds[curbounds, 1] - 1) {
    153193          strBuilder.Append(this[i]);
    154194        } else {
     
    171211    }
    172212
    173     public bool Equals(IMatching other) {
     213    public bool Equals(IClassifier other) {
    174214      return this.MatchAction(other) && this.MatchCondition(other);
    175215    }
    176216
    177217    public override int GetHashCode() {
    178       int result = actionPart;
     218      int result = actionLength;
    179219      for (int i = 0; i < array.Length; i++) {
    180220        result ^= array[i];
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorCreator.cs

    r8941 r9089  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
    25 using HeuristicLab.Encodings.IntegerVectorEncoding;
     25using HeuristicLab.Operators;
     26using HeuristicLab.Optimization;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3334  [Item("CombinedIntegerVectorCreator", "A base class for operators creating combined int-valued vectors.")]
    3435  [StorableClass]
    35   public abstract class CombinedIntegerVectorCreator : IntegerVectorCreator, ICombinedIntegerVectorCreator {
     36  public abstract class CombinedIntegerVectorCreator : SingleSuccessorOperator, IStochasticOperator, ICombinedIntegerVectorCreator {
     37    public override bool CanChangeName {
     38      get { return false; }
     39    }
     40    public ILookupParameter<IRandom> RandomParameter {
     41      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     42    }
     43    public IValueLookupParameter<IntValue> LengthParameter {
     44      get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; }
     45    }
     46    public IValueLookupParameter<IntMatrix> BoundsParameter {
     47      get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
     48    }
     49
    3650    public IValueLookupParameter<IntValue> ActionPartLengthParameter {
    3751      get { return (IValueLookupParameter<IntValue>)Parameters["ActionPartLength"]; }
     
    4458    [StorableConstructor]
    4559    protected CombinedIntegerVectorCreator(bool deserializing) : base(deserializing) { }
    46     protected CombinedIntegerVectorCreator(IntegerVectorCreator original, Cloner cloner) : base(original, cloner) { }
     60    protected CombinedIntegerVectorCreator(CombinedIntegerVectorCreator original, Cloner cloner) : base(original, cloner) { }
    4761    protected CombinedIntegerVectorCreator()
    4862      : base() {
     63      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     64      Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector."));
     65      Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled."));
    4966      Parameters.Add(new LookupParameter<CombinedIntegerVector>("CombinedIntegerVector", "The vector which should be manipulated."));
    5067      Parameters.Add(new ValueLookupParameter<IntValue>("ActionPartLength", "The length of the vector."));
    5168    }
    5269
    53     protected override IntegerVector Create(IRandom random, IntValue length, IntMatrix bounds) {
    54       CombinedIntegerVectorParameter.ActualValue = Create(random, length, bounds, ActionPartLengthParameter.ActualValue);
    55       return CombinedIntegerVectorParameter.ActualValue;
     70    public sealed override IOperation Apply() {
     71      CombinedIntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue, ActionPartLengthParameter.ActualValue);
     72      return base.Apply();
    5673    }
    5774
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Creators/UniformRandomCombinedIntegerVectorCreator.cs

    r8941 r9089  
    5050    /// <returns>The newly created integer vector.</returns>
    5151    public static CombinedIntegerVector Apply(IRandom random, int length, IntMatrix bounds, int actionPartLength) {
    52       var result = new CombinedIntegerVector(length, actionPartLength, GetElementsOfBounds(bounds));
     52      var result = new CombinedIntegerVector(length, actionPartLength, bounds);
    5353      result.Randomize(random, bounds);
    5454      return result;
    55     }
    56 
    57     private static int[,] GetElementsOfBounds(IntMatrix bounds) {
    58       int[,] realBounds = new int[bounds.Rows, bounds.Columns];
    59       for (int i = 0; i < bounds.Rows; i++) {
    60         for (int j = 0; j < bounds.Columns; j++) {
    61           realBounds[i, j] = bounds[i, j];
    62         }
    63       }
    64       return realBounds;
    6555    }
    6656
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj

    r8941 r9089  
    104104    <Compile Include="CombinedIntegerVector.cs" />
    105105    <Compile Include="CombinedIntegerVectorCreator.cs" />
     106    <Compile Include="CombinedIntegerVectorCrossover.cs" />
     107    <Compile Include="CombinedIntegerVectorManipulator.cs" />
     108    <Compile Include="Covering\CombinedIntegerVectorCoveringCreator.cs" />
    106109    <Compile Include="Creators\UniformRandomCombinedIntegerVectorCreator.cs" />
    107     <Compile Include="Matching\IMatching.cs" />
     110    <Compile Include="Crossovers\SinglePointCrossover.cs" />
     111    <Compile Include="Interfaces\ICombinedIntegerVectorManipulator.cs" />
     112    <Compile Include="Interfaces\ICombinedIntegerVectorCrossover.cs" />
    108113    <Compile Include="Interfaces\IBoundedCombinedIntegerVectorOperator.cs" />
    109114    <Compile Include="Interfaces\ICombinedIntegerVectorCreator.cs" />
    110115    <Compile Include="Interfaces\ICombinedIntegerVectorOperator.cs" />
    111     <Compile Include="Properties\AssemblyInfo.cs" />
     116    <Compile Include="Manipulator\UniformActionManipulator.cs">
     117      <SubType>Code</SubType>
     118    </Compile>
     119    <Compile Include="Manipulator\UniformOnePositionInConditionManipulator.cs" />
     120    <Compile Include="Manipulator\UniformSomePositionsManipulator.cs" />
    112121    <Compile Include="Plugin.cs" />
    113122    <None Include="Properties\AssemblyInfo.cs.frame" />
     123    <Compile Include="Properties\AssemblyInfo.cs" />
    114124  </ItemGroup>
    115125  <ItemGroup>
    116126    <None Include="HeuristicLab.snk" />
    117127    <None Include="Plugin.cs.frame" />
     128  </ItemGroup>
     129  <ItemGroup>
     130    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
     131      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
     132      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     133    </ProjectReference>
    118134  </ItemGroup>
    119135  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/IBoundedCombinedIntegerVectorOperator.cs

    r8941 r9089  
    2020#endregion
    2121
    22 using HeuristicLab.Encodings.IntegerVectorEncoding;
     22using System;
     23using HeuristicLab.Common;
     24using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2326
    2427namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
     
    2629  /// The bounds parameter must contain at least one row and at least two columns. The first two columns specify min and max values, the last column specifies the step size, but is optional (1 is assumed if omitted).
    2730  /// </summary>
    28   public interface IBoundedCombinedIntegerVectorOperator : IBoundedIntegerVectorOperator { }
     31  public interface IBoundedCombinedIntegerVectorOperator : ICombinedIntegerVectorOperator, IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable {
     32    IValueLookupParameter<IntMatrix> BoundsParameter { get; }
     33  }
    2934}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorCreator.cs

    r8941 r9089  
    2020#endregion
    2121
     22using System;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    2325using HeuristicLab.Data;
    24 using HeuristicLab.Encodings.IntegerVectorEncoding;
     26using HeuristicLab.Optimization;
    2527
    2628namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
    27   public interface ICombinedIntegerVectorCreator : IIntegerVectorCreator, IBoundedCombinedIntegerVectorOperator {
     29  public interface ICombinedIntegerVectorCreator : ISolutionCreator, IBoundedCombinedIntegerVectorOperator, ICombinedIntegerVectorOperator, IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable {
     30    IValueLookupParameter<IntValue> LengthParameter { get; }
    2831    IValueLookupParameter<IntValue> ActionPartLengthParameter { get; }
    2932    ILookupParameter<CombinedIntegerVector> CombinedIntegerVectorParameter { get; }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorOperator.cs

    r8941 r9089  
    2020#endregion
    2121
     22using System;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    2325
    2426namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
    25   public interface ICombinedIntegerVectorOperator : IOperator { }
     27  public interface ICombinedIntegerVectorOperator : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable {
     28  }
    2629}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/LearningClassifierSystems/LearningClassifierSystem.sln

    r8941 r9089  
    1111EndProject
    1212Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.LearningClassifierSystems-3.3", "HeuristicLab.Algorithms.LearningClassifierSystems\3.3\HeuristicLab.Algorithms.LearningClassifierSystems-3.3.csproj", "{1FAB379A-3624-4EE3-9756-E8CA34BAADB4}"
     13EndProject
     14Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Encodings.ConditionActionEncoding-3.3", "HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj", "{422FB262-0845-4969-8D16-12F057AA90B1}"
     15EndProject
     16Project("{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}"
    1317EndProject
    1418Global
     
    4246    {1FAB379A-3624-4EE3-9756-E8CA34BAADB4}.Release|x64.ActiveCfg = Release|Any CPU
    4347    {1FAB379A-3624-4EE3-9756-E8CA34BAADB4}.Release|x86.ActiveCfg = Release|Any CPU
     48    {422FB262-0845-4969-8D16-12F057AA90B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     49    {422FB262-0845-4969-8D16-12F057AA90B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
     50    {422FB262-0845-4969-8D16-12F057AA90B1}.Debug|x64.ActiveCfg = Debug|Any CPU
     51    {422FB262-0845-4969-8D16-12F057AA90B1}.Debug|x86.ActiveCfg = Debug|Any CPU
     52    {422FB262-0845-4969-8D16-12F057AA90B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
     53    {422FB262-0845-4969-8D16-12F057AA90B1}.Release|Any CPU.Build.0 = Release|Any CPU
     54    {422FB262-0845-4969-8D16-12F057AA90B1}.Release|x64.ActiveCfg = Release|Any CPU
     55    {422FB262-0845-4969-8D16-12F057AA90B1}.Release|x86.ActiveCfg = Release|Any CPU
     56    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     57    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Debug|Any CPU.Build.0 = Debug|Any CPU
     58    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Debug|x64.ActiveCfg = Debug|Any CPU
     59    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Debug|x86.ActiveCfg = Debug|Any CPU
     60    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|Any CPU.ActiveCfg = Release|Any CPU
     61    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|Any CPU.Build.0 = Release|Any CPU
     62    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x64.ActiveCfg = Release|Any CPU
     63    {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x86.ActiveCfg = Release|Any CPU
    4464  EndGlobalSection
    4565  GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset for help on using the changeset viewer.