Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9392


Ignore:
Timestamp:
04/23/13 13:31:29 (12 years ago)
Author:
sforsten
Message:

#1980:

  • several small bug fixes
  • added windowing technique ILAS to GAssist
  • GAssist and XCS work now with real-valued features
  • severely improved the performance of XCS
Location:
branches/LearningClassifierSystems
Files:
11 added
3 deleted
35 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3

    • Property svn:ignore
      •  

        old new  
        11*.user
        22Plugin.cs
         3obj
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/GAssist.cs

    r9352 r9392  
    6565      get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
    6666    }
     67    public ValueParameter<MDLIterationOperator> MDLIterationOperatorParameter {
     68      get { return (ValueParameter<MDLIterationOperator>)Parameters["MDLIterationOperator"]; }
     69    }
    6770    public IConstrainedValueParameter<IDefaultRuleOperator> DefaultRuleParameter {
    6871      get { return (IConstrainedValueParameter<IDefaultRuleOperator>)Parameters["DefaultRule"]; }
     
    121124    private ValueParameter<ItemCollection<IDiscretizer>> DiscretizersParameter {
    122125      get { return (ValueParameter<ItemCollection<IDiscretizer>>)Parameters["Discretizers"]; }
     126    }
     127    public ValueParameter<IntValue> MDLActivationIterationParameter {
     128      get { return (ValueParameter<IntValue>)Parameters["MDLActivationIteration"]; }
     129    }
     130    public ValueParameter<DoubleValue> InitialTheoryLengthRatioParameter {
     131      get { return (ValueParameter<DoubleValue>)Parameters["InitialTheoryLengthRatio"]; }
     132    }
     133    public ValueParameter<DoubleValue> WeightRelaxFactorParameter {
     134      get { return (ValueParameter<DoubleValue>)Parameters["WeightRelaxFactor"]; }
     135    }
     136    public ValueParameter<IntValue> WeightAdaptionIterationsParameter {
     137      get { return (ValueParameter<IntValue>)Parameters["WeightAdaptionIterations"]; }
     138    }
     139    public ValueParameter<IntValue> NumberOfStrataParameter {
     140      get { return (ValueParameter<IntValue>)Parameters["NumberOfStrata"]; }
    123141    }
    124142    #endregion
     
    180198      get { return (RandomCreator)OperatorGraph.InitialOperator; }
    181199    }
     200    private VariableCreator VariableCreator {
     201      get { return (VariableCreator)RandomCreator.Successor; }
     202    }
     203    private Placeholder MDLIterationPlaceholder {
     204      get { return (Placeholder)VariableCreator.Successor; }
     205    }
     206    private ILASOperator ILASOperator {
     207      get { return (ILASOperator)MDLIterationPlaceholder.Successor; }
     208    }
     209    private InitializeDiscretizersOperator InitializeDiscretizers {
     210      get { return (InitializeDiscretizersOperator)ILASOperator.Successor; }
     211    }
    182212    private SolutionsCreator SolutionsCreator {
    183       get { return (SolutionsCreator)RandomCreator.Successor; }
     213      get { return (SolutionsCreator)InitializeDiscretizers.Successor; }
    184214    }
    185215    private GAssistMainLoop GeneticAlgorithmMainLoop {
     
    204234      Parameters.Add(new ValueParameter<GAssistSpecialStageMultiOperator>("SpecialStages", "", new GAssistSpecialStageMultiOperator()));
    205235      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
    206       Parameters.Add(new FixedValueParameter<PercentValue>("SplitProbability", "", new PercentValue(0.05)));
    207       Parameters.Add(new FixedValueParameter<PercentValue>("MergeProbability", "", new PercentValue(0.05)));
    208       Parameters.Add(new FixedValueParameter<PercentValue>("StartReinitializeProbability", "", new PercentValue(0.05)));
    209       Parameters.Add(new FixedValueParameter<PercentValue>("EndReinitializeProbability", "", new PercentValue(Double.Epsilon)));
    210       Parameters.Add(new FixedValueParameter<PercentValue>("OneProbability", "", new PercentValue(0.75)));
    211       Parameters.Add(new FixedValueParameter<IntValue>("MaximumNumberOfIntervals", "", new IntValue(5)));
    212       Parameters.Add(new FixedValueParameter<IntValue>("InitialNumberOfRules", "", new IntValue(20)));
     236      Parameters.Add(new ValueParameter<PercentValue>("SplitProbability", "", new PercentValue(0.05)));
     237      Parameters.Add(new ValueParameter<PercentValue>("MergeProbability", "", new PercentValue(0.05)));
     238      Parameters.Add(new ValueParameter<PercentValue>("StartReinitializeProbability", "", new PercentValue(0.05)));
     239      Parameters.Add(new ValueParameter<PercentValue>("EndReinitializeProbability", "", new PercentValue(Double.Epsilon)));
     240      Parameters.Add(new ValueParameter<PercentValue>("OneProbability", "", new PercentValue(0.75)));
     241      Parameters.Add(new ValueParameter<IntValue>("MaximumNumberOfIntervals", "", new IntValue(5)));
     242      Parameters.Add(new ValueParameter<IntValue>("InitialNumberOfRules", "", new IntValue(20)));
     243      Parameters.Add(new ValueParameter<MDLIterationOperator>("MDLIterationOperator", "", new MDLIterationOperator()));
    213244      Parameters.Add(new ConstrainedValueParameter<IDefaultRuleOperator>("DefaultRule", ""));
    214245      Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("ReinitializeCurveOperator", ""));
    215246      Parameters.Add(new ValueParameter<ItemCollection<IDiscretizer>>("Discretizers", "", new ItemCollection<IDiscretizer>()));
    216247
     248      Parameters.Add(new ValueParameter<IntValue>("MDLActivationIteration", "", new IntValue(25)));
     249      Parameters.Add(new ValueParameter<DoubleValue>("InitialTheoryLengthRatio", "", new DoubleValue(0.075)));
     250      Parameters.Add(new ValueParameter<DoubleValue>("WeightRelaxFactor", "", new DoubleValue(0.9)));
     251      Parameters.Add(new ValueParameter<IntValue>("WeightAdaptionIterations", "", new IntValue(10)));
     252
     253      Parameters.Add(new ValueParameter<IntValue>("NumberOfStrata", "", new IntValue(2)));
     254
    217255      RandomCreator randomCreator = new RandomCreator();
     256      VariableCreator variableCreator = new VariableCreator();
     257      Placeholder mdlIterationPlaceholder = new Placeholder();
     258      ILASOperator ilasOperator = new ILASOperator();
     259      InitializeDiscretizersOperator initializeDiscretizers = new InitializeDiscretizersOperator();
    218260      SolutionsCreator solutionsCreator = new SolutionsCreator();
    219261      SubScopesCounter subScopesCounter = new SubScopesCounter();
     
    227269      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
    228270      randomCreator.SetSeedRandomlyParameter.Value = null;
    229       randomCreator.Successor = solutionsCreator;
     271      randomCreator.Successor = variableCreator;
     272
     273      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GAssistMainLoop expects this to be called Generations
     274      variableCreator.Successor = mdlIterationPlaceholder;
     275
     276      mdlIterationPlaceholder.Name = "MDL Iteration Operator";
     277      mdlIterationPlaceholder.OperatorParameter.ActualName = MDLIterationOperatorParameter.Name;
     278      mdlIterationPlaceholder.Successor = ilasOperator;
     279
     280      ilasOperator.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
     281      ilasOperator.NumberOfStrataParameter.ActualName = NumberOfStrataParameter.Name;
     282      ilasOperator.Successor = initializeDiscretizers;
     283
     284      initializeDiscretizers.DiscretizersParameter.ActualName = DiscretizersParameter.Name;
     285      initializeDiscretizers.Successor = solutionsCreator;
    230286
    231287      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
     
    240296      resultsCollector.Successor = mainLoop;
    241297
     298      mainLoop.MDLIterationParameter.ActualName = MDLIterationOperatorParameter.Name;
    242299      mainLoop.DefaultRuleParameter.ActualName = DefaultRuleParameter.Name;
    243300      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
     
    348405      ParameterizeStochasticOperator(Problem.SolutionCreator);
    349406      ParameterizeStochasticOperator(Problem.Evaluator);
    350       foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
     407      ParameterizeMDLOperator(Problem.Evaluator);
     408      ParameterizeIterationBasedOperators(Problem.Evaluator);
     409      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) {
     410        ParameterizeStochasticOperator(op);
     411      }
    351412      ParameterizeSolutionsCreator();
    352413      ParameterizeGeneticAlgorithmMainLoop();
     414      ParameterizeMDL();
    353415      ParameterizeSelectors();
    354416      ParameterizeAnalyzers();
     
    359421      UpdateAnalyzers();
    360422      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     423      ILASOperator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     424      InitializeDiscretizers.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    361425      base.OnProblemChanged();
     426    }
     427
     428    private void ParameterizeMDL() {
     429      MDLIterationOperatorParameter.Value.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
     430      //change
     431      MDLIterationOperatorParameter.Value.IndividualParameter.ActualName = "DecisionList";
     432      MDLIterationOperatorParameter.Value.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     433      MDLIterationOperatorParameter.Value.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     434
     435      MDLIterationOperatorParameter.Value.InitialTheoryLengthRatioParameter.ActualName = InitialTheoryLengthRatioParameter.Name;
     436      MDLIterationOperatorParameter.Value.MDLActivationIterationParameter.ActualName = MDLActivationIterationParameter.Name;
     437      MDLIterationOperatorParameter.Value.WeightAdaptionIterationsParameter.ActualName = WeightAdaptionIterationsParameter.Name;
     438      MDLIterationOperatorParameter.Value.WeightRelaxFactorParameter.ActualName = WeightRelaxFactorParameter.Name;
     439      MDLIterationOperatorParameter.Value.IterationsParameter.ActualName = "Generations";
    362440    }
    363441
     
    374452      ParameterizeAnalyzers();
    375453      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     454      Problem.Evaluator.StrataParameter.ActualName = ILASOperator.StrataParameter.ActualName;
    376455      base.Problem_EvaluatorChanged(sender, e);
    377456    }
     
    433512        stochasticOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    434513        stochasticOp.RandomParameter.Hidden = true;
     514      }
     515    }
     516    private void ParameterizeMDLOperator(IOperator op) {
     517      IMDLCalculatorBasedOperator stochasticOp = op as IMDLCalculatorBasedOperator;
     518      if (stochasticOp != null) {
     519        stochasticOp.MDLCalculatorParameter.ActualName = MDLIterationOperatorParameter.Value.MDLCalculatorParameter.ActualName;
    435520      }
    436521    }
     
    469554      }
    470555    }
     556    private void ParameterizeIterationBasedOperators(IOperator op) {
     557      IIterationBasedOperator iterationOp = op as IIterationBasedOperator;
     558      if (iterationOp != null) {
     559        ParameterizeIterationBasedOperators(iterationOp);
     560      }
     561    }
     562    private void ParameterizeIterationBasedOperators(IIterationBasedOperator op) {
     563      op.IterationsParameter.ActualName = "Generations";
     564      op.IterationsParameter.Hidden = true;
     565      op.MaximumIterationsParameter.ActualName = "MaximumGenerations";
     566      op.MaximumIterationsParameter.Hidden = true;
     567    }
    471568    private void ParameterizeIterationBasedOperators() {
    472569      if (Problem != null) {
    473570        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
    474           op.IterationsParameter.ActualName = "Generations";
    475           op.IterationsParameter.Hidden = true;
    476           op.MaximumIterationsParameter.ActualName = "MaximumGenerations";
    477           op.MaximumIterationsParameter.Hidden = true;
     571          ParameterizeIterationBasedOperators(op);
    478572        }
    479573      }
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/GAssistMainLoop.cs

    r9352 r9392  
    6161    public ValueLookupParameter<IOperator> MutatorParameter {
    6262      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
     63    }
     64    public ValueLookupParameter<IOperator> MDLIterationParameter {
     65      get { return (ValueLookupParameter<IOperator>)Parameters["MDLIteration"]; }
    6366    }
    6467    public ValueLookupParameter<IOperator> DefaultRuleParameter {
     
    134137      Parameters.Add(new ValueLookupParameter<IOperator>("ReinitializationProbabilityOperator", ""));
    135138      Parameters.Add(new ValueLookupParameter<IOperator>("DefaultRule", ""));
     139      Parameters.Add(new ValueLookupParameter<IOperator>("MDLIteration", ""));
    136140      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
    137141      #endregion
    138142
    139143      #region Create operators
    140       VariableCreator variableCreator = new VariableCreator();
    141144      ResultsCollector resultsCollector1 = new ResultsCollector();
    142145      Placeholder analyzer1 = new Placeholder();
     146      Placeholder mdlIterationOperator = new Placeholder();
     147      Placeholder defaultRuleOperator = new Placeholder();
    143148      Placeholder reinitializationProbabilityOperator = new Placeholder();
    144       Placeholder defaultRuleOperator = new Placeholder();
    145149      Placeholder selector = new Placeholder();
    146150      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
     
    167171      ConditionalBranch conditionalBranch = new ConditionalBranch();
    168172
    169       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations
    170 
    171173      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    172174      resultsCollector1.ResultsParameter.ActualName = "Results";
     
    174176      analyzer1.Name = "Analyzer";
    175177      analyzer1.OperatorParameter.ActualName = "Analyzer";
     178
     179      mdlIterationOperator.Name = "MDL Iteration Operator";
     180      mdlIterationOperator.OperatorParameter.ActualName = MDLIterationParameter.Name;
    176181
    177182      defaultRuleOperator.Name = "Default Rule Operator";
     
    234239
    235240      #region Create operator graph
    236       OperatorGraph.InitialOperator = variableCreator;
    237       variableCreator.Successor = resultsCollector1;
     241      OperatorGraph.InitialOperator = resultsCollector1;
    238242      resultsCollector1.Successor = analyzer1;
    239       analyzer1.Successor = defaultRuleOperator;
     243      analyzer1.Successor = mdlIterationOperator;
     244      mdlIterationOperator.Successor = defaultRuleOperator;
    240245      defaultRuleOperator.Successor = reinitializationProbabilityOperator;
    241246      reinitializationProbabilityOperator.Successor = selector;
     
    272277      comparator.Successor = analyzer2;
    273278      analyzer2.Successor = conditionalBranch;
    274       conditionalBranch.FalseBranch = defaultRuleOperator;
     279      conditionalBranch.FalseBranch = mdlIterationOperator;
    275280      conditionalBranch.TrueBranch = null;
    276281      conditionalBranch.Successor = null;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3

    • Property svn:ignore
      •  

        old new  
        11*.user
        22Plugin.cs
         3obj
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionList.cs

    r9352 r9392  
    8080
    8181    // for convenience
    82     public IEnumerable<IAction> Evaluate(IEnumerable<DecisionListInput> input) {
    83       int numberOfAliveRules;
    84       return Evaluate(input, out numberOfAliveRules);
     82    public IEnumerable<IAction> Evaluate(IEnumerable<IGAssistInput> input) {
     83      ItemSet<Rule> aliveRules;
     84      return Evaluate(input, out aliveRules);
    8585    }
    8686    // for convenience
    87     public IEnumerable<IAction> Evaluate(IEnumerable<DecisionListInput> input, out int numberOfAliveRules) {
     87    public IEnumerable<IAction> Evaluate(IEnumerable<IGAssistInput> input, out ItemSet<Rule> aliveRules) {
    8888      double theoryLengtgh;
    89       return Evaluate(input, out numberOfAliveRules, out theoryLengtgh);
     89      return Evaluate(input, out aliveRules, out theoryLengtgh);
    9090    }
    91     public IEnumerable<IAction> Evaluate(IEnumerable<DecisionListInput> input, out int numberOfAliveRules, out double theoryLengtgh) {
     91    public IEnumerable<IAction> Evaluate(IEnumerable<IGAssistInput> input, out ItemSet<Rule> aliveRules, out double theoryLength) {
    9292      var estimated = new List<IAction>();
    93       var activatedRules = new HashSet<Rule>();
     93      var activatedRules = new ItemSet<Rule>();
     94      int count = 0;
    9495      foreach (var dli in input) {
     96        count++;
    9597        foreach (var rule in rules) {
    9698          if (rule.MatchInput(dli)) {
     
    100102          }
    101103        }
     104        if (count > estimated.Count) {
     105          estimated.Add(defaultAction);
     106        }
    102107      }
    103       numberOfAliveRules = activatedRules.Count;
    104       theoryLengtgh = activatedRules.Sum(x => x.ComputeTheoryLength());
     108      aliveRules = activatedRules;
     109      theoryLength = activatedRules.Sum(x => x.ComputeTheoryLength());
    105110
    106111      return estimated;
     112    }
     113
     114    public void RemoveRules(IEnumerable<Rule> deadRules) {
     115      foreach (var deadRule in deadRules) {
     116        Rules.Remove(deadRule);
     117      }
    107118    }
    108119
     
    145156      }
    146157    }
     158
     159    public IGAssistSolution CreateGAssistSolution(IGAssistNichesProblemData problemData) {
     160      return new DecisionListSolution(this, problemData);
     161    }
    147162    #endregion
    148163  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListInput.cs

    r9334 r9392  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Optimization.Operators.LCS;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
     
    3132  [StorableClass]
    3233  [Item("DecisionListInput", "")]
    33   public class DecisionListInput : Item {
     34  public class DecisionListInput : Item, IGAssistInput {
    3435
    3536    [Storable]
     
    8182      return sb.ToString();
    8283    }
     84
     85    #region IGAssistInput Members
     86    public IEnumerable<string> VariableNames {
     87      get { return inputDictionary.Keys; }
     88    }
     89    public string GetVariableValue(string variableName) {
     90      return inputDictionary[variableName];
     91    }
     92    #endregion
    8393  }
    8494}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListSolution.cs

    r9334 r9392  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Optimization;
     29using HeuristicLab.Optimization.Operators.LCS;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3031
     
    3839    private const string TestAccuracyResultName = "Accuracy (test)";
    3940    private const string TrainingNumberOfAliveRulesName = "Number of alive rules (training)";
     41    private const string TrainingAliveRulesName = "Alive Rules (training)";
    4042    //private const string TestNumberOfAliveRules = "Number of alive rules (test)";
    4143    private const string TrainingTheoryLengthName = "Theory Length (training)";
     
    5456      private set { ((IntValue)this[TrainingNumberOfAliveRulesName].Value).Value = value; }
    5557    }
     58    public ItemSet<Rule> TrainingAliveRules {
     59      get { return (ItemSet<Rule>)this[TrainingAliveRulesName].Value; }
     60      private set { this[TrainingAliveRulesName].Value = value; }
     61    }
    5662    public double TrainingTheoryLength {
    5763      get { return ((DoubleValue)this[TrainingTheoryLengthName].Value).Value; }
     
    6167      get { return ((DoubleValue)this[TrainingExceptionsLengthName].Value).Value; }
    6268      private set { ((DoubleValue)this[TrainingExceptionsLengthName].Value).Value = value; }
     69    }
     70
     71    public int Classes {
     72      get { return ProblemData.Classes; }
    6373    }
    6474
     
    7989    }
    8090
    81     public IDecisionListClassificationProblemData ProblemData {
    82       get { return (IDecisionListClassificationProblemData)this[ProblemDataResultName].Value; }
     91    public IGAssistNichesProblemData ProblemData {
     92      get { return (IGAssistNichesProblemData)this[ProblemDataResultName].Value; }
    8393      set {
    8494        if (this[ProblemDataResultName].Value != value) {
     
    100110      description = original.Description;
    101111    }
    102     public DecisionListSolution(DecisionList model, IDecisionListClassificationProblemData problemData)
     112    public DecisionListSolution(DecisionList model, IGAssistNichesProblemData problemData)
    103113      : base() {
    104114      name = ItemName;
     
    109119      Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue()));
    110120      Add(new Result(TrainingNumberOfAliveRulesName, "", new IntValue()));
     121      Add(new Result(TrainingAliveRulesName, "", new ItemSet<Rule>()));
    111122      Add(new Result(TrainingTheoryLengthName, "", new DoubleValue()));
    112123      Add(new Result(TrainingExceptionsLengthName, "", new DoubleValue()));
     
    123134      var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices);
    124135      var originalTestCondition = ProblemData.FetchInput(ProblemData.TestIndices);
    125       int numberOfAliveRules;
     136      ItemSet<Rule> aliveRules;
    126137      double theoryLength;
    127       var estimatedTraining = Model.Evaluate(originalTrainingCondition, out numberOfAliveRules, out theoryLength);
    128       TrainingNumberOfAliveRules = numberOfAliveRules;
     138      var estimatedTraining = Model.Evaluate(originalTrainingCondition, out aliveRules, out theoryLength);
     139      TrainingNumberOfAliveRules = aliveRules.Count;
     140      TrainingAliveRules = aliveRules;
    129141      TrainingTheoryLength = theoryLength;
    130142      var estimatedTest = Model.Evaluate(originalTestCondition);
     
    139151    }
    140152
    141     private double CalculateAccuracy(IEnumerable<IAction> original, IEnumerable<IAction> estimated) {
     153    public static double CalculateAccuracy(IEnumerable<IGAssistNiche> original, IEnumerable<IGAssistNiche> estimated) {
    142154      double correctClassified = 0;
    143155
     
    147159
    148160      while (originalEnumerator.MoveNext() && estimatedActionEnumerator.MoveNext()) {
    149         if (originalEnumerator.Current.Match(estimatedActionEnumerator.Current)) {
     161        if (originalEnumerator.Current != null && estimatedActionEnumerator.Current != null
     162          && originalEnumerator.Current.SameNiche(estimatedActionEnumerator.Current)) {
    150163          correctClassified++;
    151164        }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs

    r9334 r9392  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.Data;
     27using HeuristicLab.Operators;
     28using HeuristicLab.Optimization;
     29using HeuristicLab.Optimization.Operators.LCS;
    2530using HeuristicLab.Parameters;
    2631using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2934  [Item("MDLEvaluator", "Description missing")]
    3035  [StorableClass]
    31   public class MDLEvaluator : DecisionListEvaluator {
     36  public class MDLEvaluator : SingleSuccessorOperator, IDecisionListEvaluator, IDecisionListOperator, IMDLCalculatorBasedOperator, IIterationBasedOperator, IStochasticOperator {
    3237
    33     public IValueLookupParameter<MDLCalculator> MDLCalculatorParameter {
    34       get { return (IValueLookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; }
     38    #region Parameter Properties
     39    public ILookupParameter<IRandom> RandomParameter {
     40      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     41    }
     42    public ILookupParameter<DecisionList> DecisionListParameter {
     43      get { return (ILookupParameter<DecisionList>)Parameters["DecisionList"]; }
     44    }
     45    public IValueLookupParameter<IntValue> SizePenaltyMinRulesParameter {
     46      get { return (IValueLookupParameter<IntValue>)Parameters["SizePenaltyMinRules"]; }
     47    }
     48    public ILookupParameter<DoubleValue> QualityParameter {
     49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     50    }
     51    public IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter {
     52      get { return (IValueLookupParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; }
     53    }
     54
     55    public ILookupParameter<MDLCalculator> MDLCalculatorParameter {
     56      get { return (ILookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; }
     57    }
     58    public ILookupParameter<IntValue> IterationsParameter {
     59      get { return (ILookupParameter<IntValue>)Parameters["Iterations"]; }
     60    }
     61    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     62      get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
     63    }
     64
     65    public IValueLookupParameter<IntValue> IterationRuleDeletionParameter {
     66      get { return (IValueLookupParameter<IntValue>)Parameters["IterationRuleDeletion"]; }
     67    }
     68    public IValueLookupParameter<IntValue> RuleDeletionMinRulesParameter {
     69      get { return (IValueLookupParameter<IntValue>)Parameters["RuleDeletionMinRules"]; }
     70    }
     71
     72    public ILookupParameter<ItemList<ItemList<IntValue>>> StrataParameter {
     73      get { return (ILookupParameter<ItemList<ItemList<IntValue>>>)Parameters["Strata"]; }
     74    }
     75    #endregion
     76
     77    public IRandom Random {
     78      get { return RandomParameter.ActualValue; }
    3579    }
    3680
     
    4286    public MDLEvaluator()
    4387      : base() {
    44       Parameters.Add(new ValueLookupParameter<MDLCalculator>("MDLCalculator", ""));
     88      Parameters.Add(new LookupParameter<IRandom>("Random", "The random generator to use."));
     89      Parameters.Add(new LookupParameter<DecisionList>("DecisionList", ""));
     90      Parameters.Add(new ValueLookupParameter<IntValue>("SizePenaltyMinRules", ""));
     91      Parameters.Add(new LookupParameter<DoubleValue>("Quality", ""));
     92      Parameters.Add(new ValueLookupParameter<IDecisionListClassificationProblemData>("ProblemData", ""));
     93      Parameters.Add(new LookupParameter<MDLCalculator>("MDLCalculator", ""));
     94      Parameters.Add(new LookupParameter<IntValue>("Iterations", ""));
     95      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", ""));
     96      Parameters.Add(new ValueLookupParameter<IntValue>("IterationRuleDeletion", "", new IntValue(5)));
     97      Parameters.Add(new ValueLookupParameter<IntValue>("RuleDeletionMinRules", "", new IntValue(12)));
     98      Parameters.Add(new ValueLookupParameter<ItemList<ItemList<IntValue>>>("Strata", ""));
    4599    }
    46100    public override IDeepCloneable Clone(Cloner cloner) {
     
    51105      double penalty = 1;
    52106
    53       var dls = new DecisionListSolution(DecisionListParameter.ActualValue, ProblemDataParameter.ActualValue);
     107      var strata = StrataParameter.ActualValue;
     108      int iteration = IterationsParameter.ActualValue.Value;
     109      int numberOfStrata = strata.Count;
     110      var dl = DecisionListParameter.ActualValue;
     111      var problemData = ProblemDataParameter.ActualValue;
     112      bool lastIteration = iteration == MaximumIterationsParameter.ActualValue.Value - 1;
     113      IEnumerable<int> rows;
     114      if (lastIteration) {
     115        rows = from s in strata
     116               from row in s
     117               select row.Value;
     118      } else {
     119        rows = strata[iteration % numberOfStrata].Select(x => x.Value);
     120      }
     121      var input = problemData.FetchInput(rows);
     122      var actions = problemData.FetchAction(rows);
     123      ItemSet<Rule> aliveRules;
     124      double theoryLength;
     125      var estimated = dl.Evaluate(input, out aliveRules, out theoryLength);
    54126
    55       if (dls.TrainingNumberOfAliveRules < SizePenaltyMinRulesParameter.ActualValue.Value) {
    56         penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - dls.TrainingNumberOfAliveRules));
     127      if (aliveRules.Count < SizePenaltyMinRulesParameter.ActualValue.Value) {
     128        penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - aliveRules.Count));
    57129        if (penalty <= 0) penalty = 0.01;
    58130        penalty *= penalty;
    59131      }
    60132
    61       QualityParameter.ActualValue = new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(dls) / penalty);
     133      double accuracy = DecisionListSolution.CalculateAccuracy(actions, estimated);
     134      QualityParameter.ActualValue = new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(theoryLength, accuracy) / penalty);
     135
     136      if (iteration >= IterationRuleDeletionParameter.ActualValue.Value) {
     137        if (lastIteration) {
     138          DoRuleDeletion(dl, aliveRules, 1);
     139        } else {
     140          DoRuleDeletion(dl, aliveRules, RuleDeletionMinRulesParameter.ActualValue.Value);
     141        }
     142      }
    62143      return base.Apply();
     144    }
     145
     146    // default rule cannot be deleted, but it has to be considered in the rule set size
     147    private void DoRuleDeletion(DecisionList dl, ItemSet<Rule> aliveRules, int minRules) {
     148      int ruleSetSize = dl.RuleSetSize;
     149      if (ruleSetSize <= minRules) { return; }
     150
     151      var deadRules = dl.Rules.Except(aliveRules).ToList();
     152      int numberOfDeadRules = deadRules.Count();
     153
     154      int keepRules = minRules - (ruleSetSize - numberOfDeadRules);
     155
     156      if (keepRules > 0) {
     157        for (int i = 0; i < keepRules; i++) {
     158          int pos = Random.Next(deadRules.Count);
     159          deadRules.RemoveAt(pos);
     160        }
     161      }
     162
     163      dl.RemoveRules(deadRules);
    63164    }
    64165  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/HeuristicLab.Encodings.DecisionList-3.3.csproj

    r9352 r9392  
    100100    <Compile Include="DecisionListNicheComparer.cs" />
    101101    <Compile Include="DecisionListSolution.cs" />
    102     <Compile Include="Evaluator\DecisionListEvaluator.cs" />
    103     <Compile Include="Evaluator\MDLCalculator.cs" />
    104102    <Compile Include="Evaluator\MDLEvaluator.cs" />
    105     <Compile Include="Evaluator\MDLIterationOperator.cs" />
    106103    <Compile Include="Interfaces\IDecisionListClassificationProblem.cs" />
    107104    <Compile Include="Interfaces\IDecisionListClassificationProblemData.cs" />
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListClassificationProblemData.cs

    r9352 r9392  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using HeuristicLab.Core;
    25 using HeuristicLab.Data;
    2623using HeuristicLab.Optimization.Operators.LCS;
    27 using HeuristicLab.Problems.DataAnalysis;
    2824
    2925namespace HeuristicLab.Encodings.DecisionList {
    3026  public interface IDecisionListClassificationProblemData : IGAssistNichesProblemData {
    31     Dataset Dataset { get; }
    32     ICheckedItemList<StringValue> ConditionVariables { get; }
    33     StringValue TargetVariable { get; }
    34     IEnumerable<string> AllowedConditionVariables { get; }
    35     //IEnumerable<string> AllowedTargetVariables { get; }
    36 
    37     IntRange TrainingPartition { get; }
    38     IntRange TestPartition { get; }
    39 
    40     IEnumerable<int> TrainingIndices { get; }
    41     IEnumerable<int> TestIndices { get; }
    42 
    43     bool IsTrainingSample(int index);
    44     bool IsTestSample(int index);
    45 
    46     int Classes { get; }
    47 
    4827    IValueParameter<Rule> SampleRuleParameter { get; }
    49 
    50     DecisionListInput FetchInput(int row);
    51     IEnumerable<DecisionListInput> FetchInput(IEnumerable<int> row);
    52 
    53     IEnumerable<IAction> FetchAction(IEnumerable<int> rows);
    54     IAction FetchAction(int rows);
    55 
    56     event EventHandler Changed;
    5728  }
    5829}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListEvaluator.cs

    r9334 r9392  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
    24 using HeuristicLab.Optimization;
     24using HeuristicLab.Optimization.Operators.LCS;
    2525
    2626namespace HeuristicLab.Encodings.DecisionList {
    27   public interface IDecisionListEvaluator : ISingleObjectiveEvaluator {
     27  public interface IDecisionListEvaluator : IStrataSingleObjectiveEvaluator {
    2828    ILookupParameter<DecisionList> DecisionListParameter { get; }
    29     IValueLookupParameter<IntRange> EvaluationPartitionParameter { get; }
    30     IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { get; }
    3129    IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { get; }
    3230    IValueLookupParameter<IntValue> SizePenaltyMinRulesParameter { get; }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListSolution.cs

    r9334 r9392  
    2020#endregion
    2121
     22using System;
     23using HeuristicLab.Optimization.Operators.LCS;
    2224
    23 using System;
    2425namespace HeuristicLab.Encodings.DecisionList {
    25   public interface IDecisionListSolution {
     26  public interface IDecisionListSolution : IGAssistSolution {
    2627    DecisionList Model { get; }
    27     IDecisionListClassificationProblemData ProblemData { get; set; }
     28    //IDecisionListClassificationProblemData ProblemData { get; set; }
    2829
    2930    event EventHandler ModelChanged;
    3031    event EventHandler ProblemDataChanged;
    31 
    32     double TrainingAccuracy { get; }
    33     double TestAccuracy { get; }
    34     int TrainingNumberOfAliveRules { get; }
    35     double TrainingTheoryLength { get; }
    36     double TrainingExceptionsLength { get; }
    3732  }
    3833}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Properties/AssemblyInfo.cs

    r9352 r9392  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.7.9342")]
     57[assembly: AssemblyFileVersion("3.3.7.9352")]
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Rule.cs

    r9352 r9392  
    8888    }
    8989
    90     public bool MatchInput(DecisionListInput target) {
     90    public bool MatchInput(IGAssistInput target) {
    9191      foreach (var variable in variables) {
    92         if (!target.InputDictionary.ContainsKey(variable.Key)) { throw new ArgumentException("Input doesn't contain variable"); }
    93         if (!variable.Value.Match(target.InputDictionary[variable.Key])) { return false; }
     92        if (!target.VariableNames.Contains(variable.Key)) { throw new ArgumentException("Input doesn't contain variable"); }
     93        if (!variable.Value.Match(target.GetVariableValue(variable.Key))) { return false; }
    9494      }
    9595      return true;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/DoubleVariable.cs

    r9342 r9392  
    4646    protected DoubleVariable(DoubleVariable original, Cloner cloner)
    4747      : base(original, cloner) {
    48       discretizer = (IDiscretizer)original.discretizer.Clone();
    49       curIntervals = new List<int>(original.curIntervals);
     48      if (original.discretizer != null) {
     49        discretizer = (IDiscretizer)original.discretizer.Clone();
     50        curIntervals = new List<int>(original.curIntervals);
     51      }
    5052      maxIntervals = original.maxIntervals;
    5153    }
     
    6870
    6971      attributes = new List<bool>(numberOfIntervals);
    70       var curIntervals = new List<int>(numberOfIntervals);
     72      curIntervals = new List<int>(numberOfIntervals);
    7173
    7274      for (int i = 0; i < numberOfIntervals - 1; i++) {
     
    7476        microIntervals -= microInt;
    7577        curIntervals.Add(microInt);
    76         attributes[i] = random.NextDouble() < onePercentage;
     78        attributes.Add(random.NextDouble() < onePercentage);
    7779      }
    7880      // add last interval
    7981      curIntervals.Add(microIntervals);
    80       attributes[numberOfIntervals - 1] = random.NextDouble() < onePercentage;
     82      attributes.Add(random.NextDouble() < onePercentage);
    8183    }
    8284
     
    114116    }
    115117
    116     private IList<double> GetValuesToCutPoints(IEnumerable<double> cutpoints, IEnumerable<int> microIntervals) {
     118    private IList<double> GetValuesToCutPoints(IEnumerable<double> cutpoints, IList<int> microIntervals) {
    117119      var intervalValues = new List<double>();
    118120      var cutpointList = cutpoints.ToList();
    119       int cur = 0;
    120       foreach (var microInterval in microIntervals) {
    121         cur += microInterval;
     121      int cur = -1;
     122      for (int i = 0; i < microIntervals.Count - 1; i++) {
     123        cur += microIntervals[i];
    122124        intervalValues.Add(cutpointList[cur]);
    123125      }
     126      intervalValues.Add(Double.PositiveInfinity);
    124127      return intervalValues;
    125128    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Crossover/SinglePointCrossover.cs

    r9242 r9392  
    6262      IList<IVariable> newCondition = new List<IVariable>(parent1Condition.VariableDictionary.Count);
    6363
    64       var keyEnumerator = parent1Condition.Order.GetEnumerator();
     64      var keyEnumerator = parent1Condition.VariableDictionary.Keys.GetEnumerator();
    6565
    6666      int index = 0;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs

    r9242 r9392  
    5454        throw new ArgumentOutOfRangeException();
    5555      }
    56       var keyEnumerator = condition.Order.GetEnumerator();
     56      var keyEnumerator = condition.VariableDictionary.Keys.GetEnumerator();
    5757      int count = 0;
    5858      keyEnumerator.MoveNext();
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs

    r9242 r9392  
    130130      var targetCast = target as DoubleVariable;
    131131      if (targetCast == null) { return false; }
    132       if (variableName != targetCast.variableName || currentCenter.IsAlmost(targetCast.currentCenter)
    133         || currentSpread.IsAlmost(targetCast.currentSpread) || max.IsAlmost(targetCast.max)
    134         || min.IsAlmost(targetCast.min)) { return false; }
     132      if (variableName != targetCast.variableName || !currentCenter.IsAlmost(targetCast.currentCenter)
     133        || !currentSpread.IsAlmost(targetCast.currentSpread) || !max.IsAlmost(targetCast.max)
     134        || !min.IsAlmost(targetCast.min)) { return false; }
    135135
    136136      return true;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs

    r9242 r9392  
    133133        || currentValue != targetCast.currentValue) { return false; }
    134134
    135       if (possibleFeatures.Except(targetCast.possibleFeatures).Count() != 0
    136         || targetCast.possibleFeatures.Except(possibleFeatures).Count() != 0) { return false; }
     135      var thisEnumerator = possibleFeatures.GetEnumerator();
     136      var castEnumerator = targetCast.possibleFeatures.GetEnumerator();
     137      while (thisEnumerator.MoveNext() && castEnumerator.MoveNext()) {
     138        if (thisEnumerator.Current != castEnumerator.Current)
     139          return false;
     140      }
    137141
    138       return true;
     142      return !thisEnumerator.MoveNext() && !castEnumerator.MoveNext();
    139143    }
    140144
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs

    r9242 r9392  
    8787      featureMapping = new Dictionary<int, string>();
    8888      var distinctValuesEnumerator = variableValues.Distinct().GetEnumerator();
    89       possibleFeatures = Enumerable.Range(0, featureMapping.Count());
     89      possibleFeatures = Enumerable.Range(0, variableValues.Count());
    9090      var possibleFeaturesEnumerator = possibleFeatures.GetEnumerator();
    9191      while (possibleFeaturesEnumerator.MoveNext() && distinctValuesEnumerator.MoveNext()) {
     
    178178        || currentValue != targetCast.currentValue) { return false; }
    179179
    180       if (featureMapping.Keys.Except(targetCast.featureMapping.Keys).Count() != 0
    181         || targetCast.featureMapping.Keys.Except(featureMapping.Keys).Count() != 0) { return false; }
    182 
    183       foreach (var keyValuePair in targetCast.featureMapping) {
    184         if (!featureMapping[keyValuePair.Key].Equals(keyValuePair.Value)) { return false; }
    185       }
    186 
    187       return true;
     180      var thisEnumerator = featureMapping.GetEnumerator();
     181      var castEnumerator = targetCast.featureMapping.GetEnumerator();
     182      while (thisEnumerator.MoveNext() && castEnumerator.MoveNext()) {
     183        if (thisEnumerator.Current.Key != castEnumerator.Current.Key ||
     184          thisEnumerator.Current.Value != castEnumerator.Current.Value)
     185          return false;
     186      }
     187
     188      return !thisEnumerator.MoveNext() && !castEnumerator.MoveNext();
    188189    }
    189190
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorActionComparer.cs

    r9242 r9392  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4342
    4443    public bool Equals(VariableVectorAction x, VariableVectorAction y) {
    45       if (!x.Order.SequenceEqual(y.Order)) return false;
    46       foreach (var key in x.VariableDictionary.Keys) {
    47         if (!x.VariableDictionary[key].Identical(y.VariableDictionary[key])) {
    48           return false;
     44      //if (!x.Order.SequenceEqual(y.Order)) return false;
     45      var xEnumerator = x.VariableDictionary.Keys.GetEnumerator();
     46      var yEnumerator = y.VariableDictionary.Keys.GetEnumerator();
     47      while (xEnumerator.MoveNext() && yEnumerator.MoveNext())
     48        foreach (var key in x.VariableDictionary.Keys) {
     49          if (xEnumerator.Current != yEnumerator.Current ||
     50            !x.VariableDictionary[xEnumerator.Current].Identical(y.VariableDictionary[yEnumerator.Current])) {
     51            return false;
     52          }
    4953        }
    50       }
    51       return true;
     54      return !xEnumerator.MoveNext() && !yEnumerator.MoveNext();
    5255    }
    5356
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorCondition.cs

    r9242 r9392  
    3939      protected set { variableDictionary = value; }
    4040    }
    41 
    42     public IOrderedEnumerable<string> Order { get { return VariableDictionary.Keys.OrderBy(x => x); } }
    4341
    4442    public int VirtualLength { get { return VariableDictionary.Values.Sum(x => x.VirtualLength); } }
     
    110108
    111109    public bool Identical(VariableVectorCondition target) {
    112       if (!this.Order.SequenceEqual(target.Order)) { return false; }
    113       foreach (var keyValuePair in target.VariableDictionary) {
    114         if (!VariableDictionary[keyValuePair.Key].Identical(keyValuePair.Value)) {
     110      var thisEnumerator = VariableDictionary.GetEnumerator();
     111      var targetEnumerator = target.VariableDictionary.GetEnumerator();
     112
     113      while (thisEnumerator.MoveNext() && targetEnumerator.MoveNext()) {
     114        if (thisEnumerator.Current.Key != targetEnumerator.Current.Key ||
     115          !thisEnumerator.Current.Value.Identical(targetEnumerator.Current.Value)) {
    115116          return false;
    116117        }
    117118      }
    118       return true;
     119
     120      return !thisEnumerator.MoveNext() && !targetEnumerator.MoveNext();
    119121    }
    120122  }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Discretizer/IDiscretizer.cs

    r9342 r9392  
    2525namespace HeuristicLab.Optimization.Operators.LCS {
    2626  public interface IDiscretizer : IItem {
     27    IEnumerable<double> DiscretizeValues(string attribute, IEnumerable<double> values);
    2728    int NumberOfMicroIntervals(string attribute);
    2829    IEnumerable<double> GetCutPoints(string attribute);
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Discretizer/UniformWidthDiscretizer.cs

    r9342 r9392  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    4241    protected UniformWidthDiscretizer(UniformWidthDiscretizer original, Cloner cloner)
    4342      : base(original, cloner) {
     43      this.bins = original.bins;
     44      this.variableMicroItervals = new Dictionary<string, IList<double>>(original.variableMicroItervals);
    4445    }
    4546    public UniformWidthDiscretizer()
    46       : base() {
    47       bins = 5;
     47      : this(5) {
    4848    }
    4949    public UniformWidthDiscretizer(int bins)
     
    6060    }
    6161
    62     public IEnumerable<double> discretizeValues(string attribute, IEnumerable<double> values) {
    63       if (variableMicroItervals.ContainsKey(attribute)) {
    64         throw new ArgumentException("Values of attribute " + attribute + " are already set.");
    65       }
    66 
     62    public IEnumerable<double> DiscretizeValues(string attribute, IEnumerable<double> values) {
    6763      double min = values.Min();
    6864      double max = values.Max();
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/IGAssistNichesProblemData.cs

    r9352 r9392  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Core;
     25using HeuristicLab.Data;
     26using HeuristicLab.Problems.DataAnalysis;
    2427
    2528namespace HeuristicLab.Optimization.Operators.LCS {
    2629  public interface IGAssistNichesProblemData : INamedItem {
     30    Dataset Dataset { get; }
     31    ICheckedItemList<StringValue> ConditionVariables { get; }
     32    StringValue TargetVariable { get; }
     33    IEnumerable<string> AllowedConditionVariables { get; }
     34    //IEnumerable<string> AllowedTargetVariables { get; }
     35
     36    IntRange TrainingPartition { get; }
     37    IntRange TestPartition { get; }
     38
     39    IEnumerable<int> TrainingIndices { get; }
     40    IEnumerable<int> TestIndices { get; }
     41
     42    bool IsTrainingSample(int index);
     43    bool IsTestSample(int index);
     44
     45    int Classes { get; }
     46
     47    IGAssistInput FetchInput(int row);
     48    IEnumerable<IGAssistInput> FetchInput(IEnumerable<int> row);
     49
     50    IEnumerable<IGAssistNiche> FetchAction(IEnumerable<int> rows);
     51    IGAssistNiche FetchAction(int rows);
     52
     53    event EventHandler Changed;
     54
    2755    IEnumerable<IGAssistNiche> GetPossibleNiches();
    2856  }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/IGAssistProblem.cs

    r9352 r9392  
    2121
    2222using HeuristicLab.Core;
     23
    2324namespace HeuristicLab.Optimization.Operators.LCS {
    2425  public interface IGAssistProblem : ISingleObjectiveHeuristicOptimizationProblem {
     26    new IStrataSingleObjectiveEvaluator Evaluator { get; }
     27
    2528    IParameter ProblemDataParameter { get; }
    2629    string NichingParameterName { get; }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Interfaces/IGAssistIndividual.cs

    r9352 r9392  
    3030    void ApplyMerge(IRandom random, double probability);
    3131    void ApplyReinitialize(IRandom random, double probability, double oneProbability, IEnumerable<IDiscretizer> discretizers);
     32
     33    IGAssistSolution CreateGAssistSolution(IGAssistNichesProblemData problemData);
    3234  }
    3335}
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/HeuristicLab.Optimization.Operators.LCS-3.3.csproj

    r9352 r9392  
    8989  <ItemGroup>
    9090    <Compile Include="DefaultRule\AutoDefaultRule.cs" />
     91    <Compile Include="Discretizer\InitializeDiscretizersOperator.cs" />
    9192    <Compile Include="GAssist\IGAssistNichesProblemData.cs" />
    9293    <Compile Include="DefaultRule\MajorDefaultRule.cs" />
     
    9899    <Compile Include="Discretizer\IDiscretizer.cs" />
    99100    <Compile Include="GAssist\IGAssistProblem.cs" />
     101    <Compile Include="GAssist\ILAS\ILASOperator.cs" />
    100102    <Compile Include="GAssist\Interfaces\IGAssistIndividual.cs" />
    101103    <Compile Include="GAssist\Interfaces\IGAssistIndividualCreator.cs" />
     104    <Compile Include="GAssist\Interfaces\IGAssistInput.cs" />
    102105    <Compile Include="GAssist\Interfaces\IGAssistNiche.cs" />
    103106    <Compile Include="GAssist\Interfaces\IGAssistNicheEqualityComparer.cs" />
     107    <Compile Include="GAssist\Interfaces\IGAssistSolution.cs" />
    104108    <Compile Include="GAssist\Interfaces\IGAssistSpecialStage.cs" />
     109    <Compile Include="GAssist\Interfaces\IStrataSingleObjectiveEvaluator.cs" />
     110    <Compile Include="GAssist\MDL\IMDLCalculatorBasedOperator.cs" />
     111    <Compile Include="GAssist\MDL\MDLCalculator.cs" />
     112    <Compile Include="GAssist\MDL\MDLIterationOperator.cs" />
    105113    <Compile Include="GAssist\SpecialStage\GAssistSpecialStageMultiOperator.cs" />
    106114    <Compile Include="GAssist\SpecialStage\GAssistSpecialStageOperator.cs" />
     
    124132      <Name>HeuristicLab.Core-3.3</Name>
    125133    </ProjectReference>
     134    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
     135      <Project>{df87c13e-a889-46ff-8153-66dcaa8c5674}</Project>
     136      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
     137    </ProjectReference>
    126138  </ItemGroup>
    127139  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs

    r9352 r9392  
    8888
    8989      int parentsPerChild = ParentsPerChildParameter.ActualValue.Value;
    90       var possibleNiches = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().ToList();
    91       var selectPerNiche = new Dictionary<IGAssistNiche, int>(possibleNiches.First().Comparer);
     90      var nicheComparer = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().First().Comparer;
     91      var selectPerNiche = new Dictionary<IGAssistNiche, int>(nicheComparer);
     92      var nicheScope = new Dictionary<IGAssistNiche, List<int>>(nicheComparer);
    9293
    93       var nicheScope = new Dictionary<IGAssistNiche, List<int>>(possibleNiches.First().Comparer);
    94       foreach (var niche in possibleNiches) {
    95         nicheScope.Add(niche, new List<int>());
    96         selectPerNiche.Add(niche, count / possibleNiches.Count);
     94      for (int i = 0; i < individuals.Count; i++) {
     95        if (!nicheScope.ContainsKey(individuals[i].Niche)) {
     96          nicheScope.Add(individuals[i].Niche, new List<int>());
     97        }
     98        nicheScope[individuals[i].Niche].Add(i);
    9799      }
    98100
    99       for (int i = 0; i < individuals.Count; i++) {
    100         nicheScope[individuals[i].Niche].Add(i);
     101      var possibleNiches = nicheScope.Keys.ToList();
     102      foreach (var niche in possibleNiches) {
     103        selectPerNiche.Add(niche, count / possibleNiches.Count);
    101104      }
    102105
     
    144147    }
    145148
    146     private IGAssistNiche GetNiche(IRandom random, Dictionary<IGAssistNiche, int> nicheScope, List<IGAssistNiche> possibleNiches) {
    147       int sum = nicheScope.Values.Sum();
     149    private IGAssistNiche GetNiche(IRandom random, Dictionary<IGAssistNiche, int> selectPerNiche, List<IGAssistNiche> possibleNiches) {
     150      int sum = selectPerNiche.Values.Sum();
    148151      if (sum <= 0) { return possibleNiches[random.Next(possibleNiches.Count)]; }
    149152      int pos = random.Next(sum);
    150153      int total = 0;
    151       IGAssistNiche niche = nicheScope.Keys.First();
    152       foreach (var item in nicheScope) {
     154      IGAssistNiche niche = selectPerNiche.Keys.First();
     155      foreach (var item in selectPerNiche) {
    153156        total += item.Value;
    154157        niche = item.Key;
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/ConditionActionClassificationProblemData.cs

    r9352 r9392  
    126126      if (allowedConditionVariables == null) throw new ArgumentNullException("The allowedActionVariables must not be null.");
    127127
    128       if (allowedActionVariables.Except(dataset.DoubleVariables).Any())
    129         throw new ArgumentException("All allowed action variables must be present in the dataset and of type double.");
    130       if (allowedConditionVariables.Except(dataset.DoubleVariables).Any())
    131         throw new ArgumentException("All allowed condition variables must be present in the dataset and of type double.");
    132 
    133       var actionVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x)));
     128      var actionVariables = new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x)));
    134129      var conditionVariables = new CheckedItemList<StringValue>(actionVariables);
    135130      foreach (StringValue x in actionVariables) {
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblem.cs

    r9352 r9392  
    6262      get { return (IFixedValueParameter<IntValue>)Parameters["SizePenaltyMinRules"]; }
    6363    }
    64     public IFixedValueParameter<IntValue> ActivationIterationParameter {
    65       get { return (IFixedValueParameter<IntValue>)Parameters["ActivationIteration"]; }
    66     }
    6764    public IFixedValueParameter<DoubleValue> InitialTheoryLengthRatioParameter {
    6865      get { return (IFixedValueParameter<DoubleValue>)Parameters["InitialTheoryLengthRatio"]; }
     
    8885    }
    8986
     87    IStrataSingleObjectiveEvaluator IGAssistProblem.Evaluator {
     88      get { return Evaluator; }
     89    }
    9090    IDecisionListEvaluator IDecisionListClassificationProblem.Evaluator {
    9191      get { return Evaluator; }
     
    101101      : base(original, cloner) {
    102102    }
     103    public override IDeepCloneable Clone(Cloner cloner) {
     104      return new DecisionListClassificationProblem(this, cloner);
     105    }
    103106
    104107    public DecisionListClassificationProblem()
     
    113116      Parameters.Add(new FixedValueParameter<DoubleValue>("BestKnownQuality", "", new DoubleValue(0.5)));
    114117      Parameters.Add(new FixedValueParameter<IntValue>("SizePenaltyMinRules", "", new IntValue(4)));
    115       Parameters.Add(new FixedValueParameter<IntValue>("ActivationIteration", "", new IntValue(25)));
    116       Parameters.Add(new FixedValueParameter<DoubleValue>("InitialTheoryLengthRatio", "", new DoubleValue(0.075)));
    117       Parameters.Add(new FixedValueParameter<DoubleValue>("WeightRelaxFactor", "", new DoubleValue(0.9)));
    118118      Parameters.Add(new FixedValueParameter<PercentValue>("ActionMutationProbability", "", new PercentValue(0.1)));
    119119
    120120      Evaluator.SizePenaltyMinRulesParameter.ActualName = "SizePenaltyMinRules";
    121       // do differently
    122       ((MDLEvaluator)Evaluator).MDLCalculatorParameter.Value = new MDLCalculator(ActivationIterationParameter.Value.Value, InitialTheoryLengthRatioParameter.Value.Value, WeightRelaxFactorParameter.Value.Value);
    123121
    124122      InitializeOperators();
     
    169167      }
    170168    }
    171     public override IDeepCloneable Clone(Cloner cloner) {
    172       return new DecisionListClassificationProblem(this, cloner);
    173     }
    174169
    175170    IParameter IGAssistProblem.ProblemDataParameter {
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs

    r9352 r9392  
    214214    }
    215215
    216     public IEnumerable<DecisionListInput> FetchInput(IEnumerable<int> rows) {
     216    public IEnumerable<IGAssistInput> FetchInput(IEnumerable<int> rows) {
    217217      foreach (var row in rows) {
    218218        yield return FetchInput(row);
     
    221221
    222222    protected IDictionary<int, DecisionListInput> fetchInputCache = new Dictionary<int, DecisionListInput>();
    223     public DecisionListInput FetchInput(int row) {
     223    public IGAssistInput FetchInput(int row) {
    224224      if (!fetchInputCache.ContainsKey(row)) {
    225225        DecisionListInput input = new DecisionListInput();
     
    234234    }
    235235
    236     public IEnumerable<IAction> FetchAction(IEnumerable<int> rows) {
     236    public IEnumerable<IGAssistNiche> FetchAction(IEnumerable<int> rows) {
    237237      foreach (var row in rows) {
    238238        yield return FetchAction(row);
     
    240240    }
    241241    protected IDictionary<int, IAction> fetchActionCache = new Dictionary<int, IAction>();
    242     public IAction FetchAction(int row) {
     242    public IGAssistNiche FetchAction(int row) {
    243243      if (!fetchActionCache.ContainsKey(row)) {
    244244        var action = (IAction)SampleRuleParameter.Value.Action.Clone();
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs

    r9352 r9392  
    8989        } else if (variableValues is List<double>) {
    9090          var doubleValues = (variableValues as List<double>).Distinct();
    91           if (doubleValues.All(x => x % 1 == 0)) {
     91          if (doubleValues.All(x => x % 1 == 0 || Double.IsNaN(x))) {
    9292            // ToList call is necessary, because otherwise it wouldn't be possible to serialize it
    9393            variable = new IntVariable(variableName, doubleValues.Select(x => Convert.ToInt32(x)).ToList());
  • branches/LearningClassifierSystems/LearningClassifierSystem.sln

    r9352 r9392  
    184184    HideSolutionNode = FALSE
    185185  EndGlobalSection
     186  GlobalSection(Performance) = preSolution
     187    HasPerformanceSessions = true
     188  EndGlobalSection
    186189EndGlobal
Note: See TracChangeset for help on using the changeset viewer.