Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/11/13 13:32:32 (11 years ago)
Author:
sforsten
Message:

#1980:

  • set plugin dependencies
  • added smart initialization
  • added hierarchical selection
  • fixed major and minor default rule
  • fixed several smaller bugs
  • some refactoring has been done
Location:
branches/LearningClassifierSystems
Files:
13 added
2 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame

    r9359 r9605  
    3737  [PluginDependency("HeuristicLab.Core", "3.3")]
    3838  [PluginDependency("HeuristicLab.Data", "3.3")]
     39  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
    3940  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
    4041  [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
    4142  [PluginDependency("HeuristicLab.Operators", "3.3")]
    4243  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     44  [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")]
    4345  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4446  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/GAssist.cs

    r9411 r9605  
    201201      get { return (VariableCreator)RandomCreator.Successor; }
    202202    }
     203    private Placeholder InitialDefaultRuleExecution {
     204      get { return (Placeholder)VariableCreator.Successor; }
     205    }
    203206    private Placeholder MDLIterationPlaceholder {
    204       get { return (Placeholder)VariableCreator.Successor; }
     207      get { return (Placeholder)InitialDefaultRuleExecution.Successor; }
    205208    }
    206209    private ILASOperator ILASOperator {
     
    210213      get { return (InitializeDiscretizersOperator)ILASOperator.Successor; }
    211214    }
    212     private SolutionsCreator SolutionsCreator {
    213       get { return (SolutionsCreator)InitializeDiscretizers.Successor; }
     215    private NicheSolutionCreator SolutionsCreator {
     216      get { return (NicheSolutionCreator)InitializeDiscretizers.Successor; }
    214217    }
    215218    private GAssistMainLoop GeneticAlgorithmMainLoop {
     
    255258      RandomCreator randomCreator = new RandomCreator();
    256259      VariableCreator variableCreator = new VariableCreator();
     260      Placeholder initialDefaultRuleExecution = new Placeholder();
    257261      Placeholder mdlIterationPlaceholder = new Placeholder();
    258262      ILASOperator ilasOperator = new ILASOperator();
    259263      InitializeDiscretizersOperator initializeDiscretizers = new InitializeDiscretizersOperator();
    260       SolutionsCreator solutionsCreator = new SolutionsCreator();
     264      NicheSolutionCreator solutionsCreator = new NicheSolutionCreator();
    261265      SubScopesCounter subScopesCounter = new SubScopesCounter();
    262266      ResultsCollector resultsCollector = new ResultsCollector();
     
    272276
    273277      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GAssistMainLoop expects this to be called Generations
    274       variableCreator.Successor = mdlIterationPlaceholder;
     278      variableCreator.Successor = initialDefaultRuleExecution;
     279
     280      initialDefaultRuleExecution.Name = "Initial Default Rule Execution";
     281      initialDefaultRuleExecution.OperatorParameter.ActualName = DefaultRuleParameter.Name;
     282      initialDefaultRuleExecution.Successor = mdlIterationPlaceholder;
    275283
    276284      mdlIterationPlaceholder.Name = "MDL Iteration Operator";
     
    315323      foreach (INichingSingleObjectiveSelector selector in ApplicationManager.Manager.GetInstances<INichingSingleObjectiveSelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
    316324        SelectorParameter.ValidValues.Add(selector);
    317       //INichingSingleObjectiveSelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
    318       //if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
     325
    319326      ParameterizeSelectors();
    320327
     
    369376      SpecialStages.Operators.Clear();
    370377      var splitOperator = new SplitOperator();
    371       splitOperator.ProbabilityParameter.ActualName = "SplitProbability";
     378      splitOperator.ProbabilityParameter.ActualName = SplitProbabilityParameter.Name;
    372379      //change
    373380      splitOperator.IndividualParameter.ActualName = "DecisionList";
    374381      SpecialStages.Operators.Add(splitOperator);
    375382      var mergeOperator = new MergeOperator();
    376       mergeOperator.ProbabilityParameter.ActualName = "MergeProbability";
     383      mergeOperator.ProbabilityParameter.ActualName = MergeProbabilityParameter.Name;
    377384      //change
    378385      mergeOperator.IndividualParameter.ActualName = "DecisionList";
     
    381388      reinitializeOperator.ProbabilityParameter.ActualName = "ReinitializeProbability";
    382389      reinitializeOperator.DiscretizersParameter.ActualName = "Discretizers";
    383       reinitializeOperator.OneProbabilityParameter.ActualName = "OneProbability";
     390      reinitializeOperator.OneProbabilityParameter.ActualName = OneProbabilityParameter.Name;
    384391      //change
    385392      reinitializeOperator.IndividualParameter.ActualName = "DecisionList";
     
    508515      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    509516      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     517      SolutionsCreator.GAssistNichesProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    510518      // change!
    511       ((IGAssistIndividualCreator)Problem.SolutionCreatorParameter.ActualValue).DiscretizersParameter.ActualName = "Discretizers";
     519      ((IGAssistSolutionCreator)Problem.SolutionCreatorParameter.ActualValue).DiscretizersParameter.ActualName = "Discretizers";
    512520    }
    513521    private void ParameterizeGeneticAlgorithmMainLoop() {
     
    536544        selector.ParentsPerChildParameter.Value = new IntValue(2);
    537545        ParameterizeStochasticOperator(selector);
     546        ParameterizeIterationBasedOperators(selector);
    538547      }
    539548      if (Problem != null) {
    540         foreach (INichingSingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<INichingSingleObjectiveSelector>()) {
     549        foreach (INichingSingleObjectiveSelector selector in SelectorParameter.ValidValues) {
    541550          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    542551          selector.MaximizationParameter.Hidden = true;
     
    547556          //change
    548557          selector.IndividualParameter.ActualName = "DecisionList";
     558        }
     559        foreach (IHierarchicalSingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<IHierarchicalSingleObjectiveSelector>()) {
     560          selector.LengthParameter.ActualName = Problem.Evaluator.LengthParameter.ActualName;
    549561        }
    550562      }
     
    595607        else oldDefaultRule = null;
    596608      }
    597       if (oldDefaultRule == null && defaultdefaultRule != null)
     609      if (oldDefaultRule == null && defaultdefaultRule != null) {
    598610        DefaultRuleParameter.Value = defaultdefaultRule;
     611        SolutionsCreator.NichingParameter.ActualName = defaultdefaultRule.NichingParameter.ActualName;
     612      }
    599613    }
    600614    private void UpdateCrossovers() {
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/Plugin.cs.frame

    r9334 r9605  
    2525  [Plugin("HeuristicLab.Algorithms.GAssist", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Algorithms.GAssist-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    2728  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2829  [PluginDependency("HeuristicLab.Common", "3.3")]
    29   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     30  [PluginDependency("HeuristicLab.Core", "3.3")]
     31  [PluginDependency("HeuristicLab.Data", "3.3")]
     32  [PluginDependency("HeuristicLab.Operators", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     34  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
     35  [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")]
     36  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3037  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     38  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     39  [PluginDependency("HeuristicLab.Random", "3.3")]
     40  [PluginDependency("HeuristicLab.Selection", "3.3")]
    3141  public class HeuristicLabAlgorithmsGAssistPlugin : PluginBase {
    3242  }
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/Plugin.cs.frame

    r8941 r9605  
    2424namespace HeuristicLab.Algorithms.LearningClassifierSystems {
    2525  [Plugin("HeuristicLab.Algorithms.LearningClassifierSystems", "3.3.7.$WCREV$")]
     26  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    2627  [PluginFile("HeuristicLab.Algorithms.LearningClassifierSystems-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    28   [PluginDependency("HeuristicLab.Core.Views", "3.3")]
     28  [PluginDependency("HeuristicLab.Collections", "3.3")]
     29  [PluginDependency("HeuristicLab.Common", "3.3")]
     30  [PluginDependency("HeuristicLab.Core", "3.3")]
    2931  [PluginDependency("HeuristicLab.Data", "3.3")]
    30   [PluginDependency("HeuristicLab.Data.Views", "3.3")]
    31   [PluginDependency("HeuristicLab.MainForm", "3.3")]
    32   [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    33   [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    34   [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    35   [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
    36   [PluginDependency("HeuristicLab.Problems.Instances.Views", "3.3")]
     32  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     33  [PluginDependency("HeuristicLab.Operators", "3.3")]
     34  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     35  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
     36  [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")]
     37  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     38  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     39  [PluginDependency("HeuristicLab.Random", "3.3")]
     40  [PluginDependency("HeuristicLab.Selection", "3.3")]
    3741  public class HeuristicLabAlgorithmsLearningClassifierSystemsPlugin : PluginBase {
    3842  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Plugin.cs.frame

    r8941 r9605  
    2525  [Plugin("HeuristicLab.Encodings.CombinedIntegerVectorEncoding", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    28   [PluginDependency("HeuristicLab.Core.Views", "3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
    2930  [PluginDependency("HeuristicLab.Data", "3.3")]
    30   [PluginDependency("HeuristicLab.Data.Views", "3.3")]
    31   [PluginDependency("HeuristicLab.MainForm", "3.3")]
    32   [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     32  [PluginDependency("HeuristicLab.Encodings.IntegerVectorEncoding", "3.3")]
     33  [PluginDependency("HeuristicLab.Operators", "3.3")]
     34  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     35  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     36  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3337  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    34   [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    35   [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
    36   [PluginDependency("HeuristicLab.Problems.Instances.Views", "3.3")]
    3738  public class HeuristicLabEncodingsCombinedIntegerVectorEncodingPlugin : PluginBase {
    3839  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Plugin.cs.frame

    r9089 r9605  
    2525  [Plugin("HeuristicLab.Encodings.ConditionActionEncoding", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Encodings.ConditionActionEncoding-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Analysis", "3.3")]
     28  [PluginDependency("HeuristicLab.Collections", "3.3")]
     29  [PluginDependency("HeuristicLab.Common", "3.3")]
    2730  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     31  [PluginDependency("HeuristicLab.Core", "3.3")]
    2832  [PluginDependency("HeuristicLab.Data", "3.3")]
     33  [PluginDependency("HeuristicLab.Operators", "3.3")]
     34  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     35  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     36  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     37  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     38  [PluginDependency("HeuristicLab.Selection", "3.3")]
    2939  public class HeuristicLabEncodingsConditionActionEncodingPlugin : PluginBase {
    3040  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/IAction.cs

    r9352 r9605  
    3434    bool Match(IAction action);
    3535    void SetTo(string value);
     36    void SetTo(IGAssistNiche action);
    3637
    3738    IEnumerable<int> GetPossibleActionPositions();
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/IntAction.cs

    r9411 r9605  
    117117
    118118    public void SetTo(string value) {
    119       currentAction = int.Parse(value);
     119      SetToPosition(int.Parse(value));
     120    }
     121
     122    public void SetTo(IGAssistNiche action) {
     123      var castAction = action as IntAction;
     124      if (castAction == null) throw new ArgumentException("action has to be IntAction");
     125      SetToPosition(castAction.CurrentAction);
    120126    }
    121127
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/StringAction.cs

    r9411 r9605  
    122122
    123123    public void SetTo(string value) {
    124       currentActionIndex = possibleFeatures.IndexOf(value);
     124      SetToPosition(possibleFeatures.IndexOf(value));
     125    }
     126
     127    public void SetTo(IGAssistNiche action) {
     128      var castAction = action as StringAction;
     129      if (castAction == null) throw new ArgumentException("action has to be IntAction");
     130      SetToPosition(castAction.CurrentPosition);
    125131    }
    126132
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Creators/UniformRandomDecisionListCreator.cs

    r9352 r9605  
    4343    }
    4444
    45     protected override DecisionList Create(IRandom random, Rule sampleRule, int initialNumberOfRules, double oneProbability, ItemCollection<IDiscretizer> discretizers) {
     45    protected override DecisionList Create(IRandom random, Rule sampleRule, int initialNumberOfRules, double oneProbability, ItemCollection<IDiscretizer> discretizers, IAction niche) {
    4646      List<Rule> rules = new List<Rule>();
    4747      for (int i = 0; i < initialNumberOfRules; i++) {
    4848        var newRule = (Rule)sampleRule.Clone();
    49         newRule.Randomize(random, oneProbability, discretizers);
     49        if (niche != null) {
     50          newRule.Randomize(random, oneProbability, discretizers, new List<IAction>() { niche });
     51        } else {
     52          newRule.Randomize(random, oneProbability, discretizers);
     53        }
    5054        rules.Add(newRule);
    5155      }
    5256
    53       return new DecisionList(rules);
     57      if (niche != null) {
     58        return new DecisionList(rules, niche);
     59      } else {
     60        return new DecisionList(rules);
     61      }
    5462    }
    5563  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Crossover/SinglePointCrossover.cs

    r9352 r9605  
    4848
    4949    public static DecisionList Apply(IRandom random, DecisionList parent1, DecisionList parent2) {
    50       if (!parent1.DefaultAction.Match(parent2.DefaultAction)) { throw new ArgumentException("Default action of parents have to match!"); }
     50      if (parent1 == null && parent1 != parent2) { throw new ArgumentException("Either both parents have a default action or none does."); }
     51      if (parent1.DefaultAction != null && !parent1.DefaultAction.Match(parent2.DefaultAction)) { throw new ArgumentException("Default action of parents have to match!"); }
    5152
    5253      int rulesP1 = random.Next(0, parent1.Rules.Count());
     
    6465      }
    6566
     67      if (parent1.DefaultAction == null) {
     68        return new DecisionList(rules);
     69      }
    6670      return new DecisionList(rules, parent1.DefaultAction);
    6771    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionList.cs

    r9411 r9605  
    4444    }
    4545
     46    public double Length {
     47      get { return 1 + rules.Sum(r => r.Length); }
     48    }
     49
    4650    // default rule (action) is part of the rule set size
    4751    public int RuleSetSize {
     
    5357    protected DecisionList(DecisionList original, Cloner cloner)
    5458      : base(original, cloner) {
    55       defaultAction = original.DefaultAction;
     59      defaultAction = cloner.Clone(original.DefaultAction);
    5660      rules = new List<Rule>(original.rules.Count);
    5761      foreach (var rule in original.Rules) {
     
    124128    }
    125129
    126     public void SetNiche(IRandom random, IGAssistNiche niche) {
    127       var action = niche as IAction;
    128       if (action == null) {
    129         throw new ArgumentException("Niche has to be an action");
    130       }
    131       if (Niche != null) {
    132         throw new ArgumentException("Niche has already been set. It cannot be set again.");
    133       }
    134       defaultAction = action;
    135       var except = new List<IAction>() { action };
    136       foreach (var rule in rules.Where(x => x.Action.SameNiche(niche))) {
    137         rule.Action.Randomize(random, except);
    138       }
    139     }
    140 
    141130    public void ApplySplit(IRandom random, double probability) {
    142131      foreach (var rule in rules) {
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListCreator.cs

    r9352 r9605  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    5253      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    5354    }
     55    public ILookupParameter<IGAssistNiche> GAssistNicheParameter {
     56      get { return (ILookupParameter<IGAssistNiche>)Parameters["GAssistNiche"]; }
     57    }
    5458    #endregion
    5559
     
    6771      Parameters.Add(new LookupParameter<DecisionList>("DecisionList", ""));
    6872      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    69       Parameters.Add(new ValueLookupParameter<IAction>("DefaultAction", ""));
     73      Parameters.Add(new LookupParameter<IGAssistNiche>("GAssistNiche", ""));
    7074    }
    7175
    7276    public override IOperation Apply() {
    73       DecisionListParameter.ActualValue = Create(RandomParameter.ActualValue, ProblemDataParameter.ActualValue.SampleRuleParameter.Value, InitialNumberOfRulesParameter.ActualValue.Value, OneProbabilityParameter.ActualValue.Value, DiscretizersParameter.ActualValue);
     77      if (GAssistNicheParameter.ActualValue != null && !(GAssistNicheParameter.ActualValue is IAction)) throw new ArgumentException("GAssistNiche has to be a IAction.");
     78      DecisionListParameter.ActualValue = Create(RandomParameter.ActualValue,
     79                                              ProblemDataParameter.ActualValue.SampleRuleParameter.Value,
     80                                              InitialNumberOfRulesParameter.ActualValue.Value,
     81                                              OneProbabilityParameter.ActualValue.Value,
     82                                              DiscretizersParameter.ActualValue,
     83                                              (IAction)GAssistNicheParameter.ActualValue);
    7484      return base.Apply();
    7585    }
    7686
    77     protected abstract DecisionList Create(IRandom random, Rule sampleRule, int initialNumberOfRules, double oneProbability, ItemCollection<IDiscretizer> discretizers);
     87    protected abstract DecisionList Create(IRandom random, Rule sampleRule, int initialNumberOfRules, double oneProbability, ItemCollection<IDiscretizer> discretizers, IAction niche);
    7888  }
    7989}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs

    r9475 r9605  
    4949      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    5050    }
     51    public ILookupParameter<DoubleValue> LengthParameter {
     52      get { return (ILookupParameter<DoubleValue>)Parameters["Length"]; }
     53    }
    5154    public IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter {
    5255      get { return (IValueLookupParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; }
    5356    }
    5457
     58    public IValueLookupParameter<BoolValue> UseMDLParameter {
     59      get { return (IValueLookupParameter<BoolValue>)Parameters["UseMDL"]; }
     60    }
    5561    public ILookupParameter<MDLCalculator> MDLCalculatorParameter {
    5662      get { return (ILookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; }
     
    7379      get { return (ILookupParameter<ItemList<ItemList<IntValue>>>)Parameters["Strata"]; }
    7480    }
     81    public IValueLookupParameter<BoolValue> MaximizationParameter {
     82      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     83    }
    7584    #endregion
    7685
     
    9099      Parameters.Add(new ValueLookupParameter<IntValue>("SizePenaltyMinRules", ""));
    91100      Parameters.Add(new LookupParameter<DoubleValue>("Quality", ""));
     101      Parameters.Add(new LookupParameter<DoubleValue>("Length", ""));
    92102      Parameters.Add(new ValueLookupParameter<IDecisionListClassificationProblemData>("ProblemData", ""));
     103      Parameters.Add(new ValueLookupParameter<BoolValue>("UseMDL", "", new BoolValue(true)));
    93104      Parameters.Add(new LookupParameter<MDLCalculator>("MDLCalculator", ""));
    94105      Parameters.Add(new LookupParameter<IntValue>("Iterations", ""));
     
    97108      Parameters.Add(new ValueLookupParameter<IntValue>("RuleDeletionMinRules", "", new IntValue(12)));
    98109      Parameters.Add(new ValueLookupParameter<ItemList<ItemList<IntValue>>>("Strata", ""));
     110      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "", new BoolValue(false)));
     111
     112      UseMDLParameter.Value.ValueChanged += UseMDLParameter_ValueChanged;
     113    }
     114
     115    private void UseMDLParameter_ValueChanged(object sender, System.EventArgs e) {
     116      MaximizationParameter.Value.Value = !UseMDLParameter.Value.Value;
    99117    }
    100118    public override IDeepCloneable Clone(Cloner cloner) {
     
    103121
    104122    public override IOperation Apply() {
    105       double penalty = 1;
    106 
    107123      var strata = StrataParameter.ActualValue;
    108124      int iteration = IterationsParameter.ActualValue.Value;
     
    125141      var estimated = dl.Evaluate(input, out aliveRules, out theoryLength);
    126142
     143      double penalty = 1;
    127144      if (aliveRules.Count < SizePenaltyMinRulesParameter.ActualValue.Value) {
    128145        penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - aliveRules.Count));
     
    132149
    133150      double accuracy = DecisionListSolution.CalculateAccuracy(actions, estimated);
    134       QualityParameter.ActualValue = new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(theoryLength, accuracy) / penalty);
     151      if (UseMDLParameter.ActualValue.Value) {
     152        QualityParameter.ActualValue =
     153          new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(theoryLength, accuracy) / penalty);
     154      } else {
     155        QualityParameter.ActualValue = new DoubleValue(accuracy * accuracy * penalty);
     156      }
    135157
    136158      if (iteration >= IterationRuleDeletionParameter.ActualValue.Value) {
     
    141163        }
    142164      }
     165
     166      LengthParameter.ActualValue = new DoubleValue(dl.Length * aliveRules.Count / dl.RuleSetSize);
    143167      return base.Apply();
    144168    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/HeuristicLab.Encodings.DecisionList-3.3.csproj

    r9411 r9605  
    9393    <Compile Include="Action\IntAction.cs" />
    9494    <Compile Include="Analyzer\BestTrainingDecisionListAnalyzer.cs" />
     95    <Compile Include="Creators\SmartDecisionListCreator.cs" />
    9596    <Compile Include="Creators\UniformRandomDecisionListCreator.cs" />
    9697    <Compile Include="Crossover\SinglePointCrossover.cs" />
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListCreator.cs

    r9352 r9605  
    2626
    2727namespace HeuristicLab.Encodings.DecisionList {
    28   public interface IDecisionListCreator : IDecisionListOperator, ISolutionCreator, IStochasticOperator, IGAssistIndividualCreator {
     28  public interface IDecisionListCreator : IDecisionListOperator, ISolutionCreator, IStochasticOperator, IGAssistSolutionCreator {
    2929    IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { get; }
    3030    ILookupParameter<DecisionList> DecisionListParameter { get; }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListEvaluator.cs

    r9392 r9605  
    2525
    2626namespace HeuristicLab.Encodings.DecisionList {
    27   public interface IDecisionListEvaluator : IStrataSingleObjectiveEvaluator {
     27  public interface IDecisionListEvaluator : IGAssistObjectiveEvaluator {
    2828    ILookupParameter<DecisionList> DecisionListParameter { get; }
    2929    IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { get; }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Plugin.cs.frame

    r9334 r9605  
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2828  [PluginDependency("HeuristicLab.Common", "3.3")]
    29   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
     30  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Operators", "3.3")]
     32  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3035  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    3137  public class HeuristicLabEncodingsDecisionListPlugin : PluginBase {
    3238  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Rule.cs

    r9392 r9605  
    4343    public IAction Action { get { return action; } }
    4444
     45    public double Length {
     46      get { return variables.Values.Sum(x => x.Length); }
     47    }
     48
    4549    [StorableConstructor]
    4650    protected Rule(bool deserializing) : base(deserializing) { }
     
    7781    }
    7882
    79     public void Randomize(IRandom random, double onePercentage, IEnumerable<IDiscretizer> discretizer) {
     83    public void Randomize(IRandom random, double oneProbability, IEnumerable<IDiscretizer> discretizers, IEnumerable<IAction> exceptActions = null) {
    8084      foreach (var variable in variables.Values) {
    81         variable.Randomize(random, onePercentage, discretizer);
     85        variable.Randomize(random, oneProbability, discretizers);
    8286      }
    83       action.Randomize(random);
     87      if (exceptActions == null) {
     88        action.Randomize(random);
     89      } else {
     90        action.Randomize(random, exceptActions);
     91      }
     92    }
     93
     94    public void SetToMatchInput(IGAssistInput input) {
     95      foreach (var variable in variables) {
     96        if (!input.VariableNames.Contains(variable.Key)) {
     97          throw new ArgumentException("input does not contain variable name of rule");
     98        }
     99        variable.Value.SetToMatch(input.GetVariableValue(variable.Key));
     100      }
    84101    }
    85102
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/DoubleVariable.cs

    r9392 r9605  
    191191    public override void Reinitialize(IRandom random, double onePercentage, IEnumerable<IDiscretizer> descretizers) {
    192192      Randomize(random, onePercentage, descretizers);
    193       return;
     193    }
     194
     195    public override void SetToMatch(string variableValue) {
     196      var value = double.Parse(variableValue);
     197      var realCutpoints = GetValuesToCutPoints(discretizer.GetCutPoints(variableName), curIntervals);
     198      int pos = 0;
     199      while (value >= realCutpoints[pos]) {
     200        pos++;
     201      }
     202      attributes[pos] = true;
    194203    }
    195204  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/IVariable.cs

    r9342 r9605  
    2727namespace HeuristicLab.Encodings.DecisionList {
    2828  public interface IVariable : IItem {
     29    double Length { get; }
    2930    string VariableName { get; }
    3031    Type VariableType { get; }
     
    4344
    4445    void Split(IRandom Random);
     46
     47    void SetToMatch(string variableValue);
    4548  }
    4649}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/IntVariable.cs

    r9334 r9605  
    6868      return attributes[possibleFeatures.IndexOf(input)];
    6969    }
     70
     71    public override void SetToMatch(string variableValue) {
     72      var value = int.Parse(variableValue);
     73      if (!possibleFeatures.Contains(value)) throw new ArgumentException("variableValue " + variableValue + " is not a possible value of variable " + variableName);
     74
     75      attributes[possibleFeatures.IndexOf(value)] = true;
     76    }
    7077  }
    7178}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/StringVariable.cs

    r9334 r9605  
    6464      return attributes[possibleFeatures.IndexOf(input)];
    6565    }
     66
     67    public override void SetToMatch(string variableValue) {
     68      var valueIndex = possibleFeatures.IndexOf(variableValue);
     69      if (valueIndex == -1) throw new ArgumentException("variableValue " + variableValue + " is not a possible value of variable " + variableName);
     70
     71      attributes[valueIndex] = true;
     72    }
    6673  }
    6774}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/Variable.cs

    r9352 r9605  
    3838    }
    3939
     40    public double Length {
     41      get { return attributes.Count; }
     42    }
     43
    4044    [Storable]
    4145    protected string variableName;
     
    7276    public abstract bool Match(string input);
    7377
     78    public abstract void SetToMatch(string variableValue);
     79
    7480    public virtual string ToFullString() { throw new NotImplementedException(); }
    7581
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Plugin.cs.frame

    r9194 r9605  
    2525  [Plugin("HeuristicLab.Encodings.VariableVector", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Encodings.VariableVector-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
    2830  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     32  [PluginDependency("HeuristicLab.Operators", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     35  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    2937  public class HeuristicLabEncodingsVariableVectorPlugin : PluginBase {
    3038  }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Interfaces/IGAssistIndividual.cs

    r9411 r9605  
    2525namespace HeuristicLab.Optimization.Operators.LCS {
    2626  public interface IGAssistIndividual : IGAssistModel {
     27    double Length { get; }
    2728    IGAssistNiche Niche { get; }
    28     void SetNiche(IRandom random, IGAssistNiche niche);
    2929    void ApplySplit(IRandom random, double probability);
    3030    void ApplyMerge(IRandom random, double probability);
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Interfaces/IGAssistProblem.cs

    r9411 r9605  
    2424namespace HeuristicLab.Optimization.Operators.LCS {
    2525  public interface IGAssistProblem : ISingleObjectiveHeuristicOptimizationProblem, IDataAnalysisProblem {
    26     new IStrataSingleObjectiveEvaluator Evaluator { get; }
     26    new IGAssistObjectiveEvaluator Evaluator { get; }
    2727    string NichingParameterName { get; }
    2828  }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/HeuristicLab.Optimization.Operators.LCS-3.3.csproj

    r9411 r9605  
    9292  </ItemGroup>
    9393  <ItemGroup>
    94     <Compile Include="DefaultRule\AutoDefaultRule.cs" />
     94    <Compile Include="GAssist\DefaultRule\AutoDefaultRule.cs" />
    9595    <Compile Include="Discretizer\InitializeDiscretizersOperator.cs" />
    9696    <Compile Include="GAssist\GAssistNicheComparer.cs" />
     
    100100    <Compile Include="GAssist\Interfaces\IGAssistEnsembleProblemData.cs" />
    101101    <Compile Include="GAssist\Interfaces\IGAssistProblemData.cs" />
    102     <Compile Include="DefaultRule\MajorDefaultRule.cs" />
    103     <Compile Include="DefaultRule\DefaultRuleOperator.cs" />
    104     <Compile Include="DefaultRule\DisabledDefaultRule.cs" />
    105     <Compile Include="DefaultRule\IDefaultRuleOperator.cs" />
    106     <Compile Include="DefaultRule\MinorDefaultRule.cs" />
     102    <Compile Include="GAssist\DefaultRule\MajorDefaultRule.cs" />
     103    <Compile Include="GAssist\DefaultRule\DefaultRuleOperator.cs" />
     104    <Compile Include="GAssist\DefaultRule\DisabledDefaultRule.cs" />
     105    <Compile Include="GAssist\DefaultRule\IDefaultRuleOperator.cs" />
     106    <Compile Include="GAssist\DefaultRule\MinorDefaultRule.cs" />
    107107    <Compile Include="Discretizer\UniformWidthDiscretizer.cs" />
    108108    <Compile Include="Discretizer\IDiscretizer.cs" />
     
    112112    <Compile Include="GAssist\Interfaces\IGAssistEnsembleSolution.cs" />
    113113    <Compile Include="GAssist\Interfaces\IGAssistIndividual.cs" />
    114     <Compile Include="GAssist\Interfaces\IGAssistIndividualCreator.cs" />
    115114    <Compile Include="GAssist\Interfaces\IGAssistInput.cs" />
    116115    <Compile Include="GAssist\Interfaces\IGAssistModel.cs" />
     
    118117    <Compile Include="GAssist\Interfaces\IGAssistNicheEqualityComparer.cs" />
    119118    <Compile Include="GAssist\Interfaces\IGAssistSolution.cs" />
     119    <Compile Include="GAssist\Interfaces\IGAssistSolutionCreator.cs" />
    120120    <Compile Include="GAssist\Interfaces\IGAssistSpecialStage.cs" />
    121     <Compile Include="GAssist\Interfaces\IStrataSingleObjectiveEvaluator.cs" />
     121    <Compile Include="GAssist\Interfaces\IGAssistObjectiveEvaluator.cs" />
    122122    <Compile Include="GAssist\MDL\IMDLCalculatorBasedOperator.cs" />
    123123    <Compile Include="GAssist\MDL\MDLCalculator.cs" />
    124124    <Compile Include="GAssist\MDL\MDLIterationOperator.cs" />
     125    <Compile Include="GAssist\NicheSolutionCreator.cs" />
    125126    <Compile Include="GAssist\SpecialStage\GAssistSpecialStageMultiOperator.cs" />
    126127    <Compile Include="GAssist\SpecialStage\GAssistSpecialStageOperator.cs" />
     
    129130    <Compile Include="GAssist\SpecialStage\SplitOperator.cs" />
    130131    <Compile Include="Plugin.cs" />
     132    <Compile Include="Selection\IHierarchicalSingleObjectiveEvaluator.cs" />
     133    <Compile Include="Selection\IHierarchicalSingleObjectiveSelector.cs" />
    131134    <Compile Include="Selection\INichingSingleObjectiveSelector.cs" />
    132135    <Compile Include="Selection\NichingTournamentSelector.cs" />
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Plugin.cs.frame

    r9342 r9605  
    2525  [Plugin("HeuristicLab.Optimization.Operators.LCS", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Optimization.Operators.LCS-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
    2729  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     30  [PluginDependency("HeuristicLab.Core", "3.3")]
    2831  [PluginDependency("HeuristicLab.Data", "3.3")]
     32  [PluginDependency("HeuristicLab.Operators", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     35  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     37  [PluginDependency("HeuristicLab.Selection", "3.3")]
    2938  public class HeuristicLabOptimizationOperatorsLCSPlugin : PluginBase {
    3039  }
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs

    r9475 r9605  
    3333  [Item("NichingTournamentSelector", "Description missing")]
    3434  [StorableClass]
    35   public class NichingTournamentSelector : StochasticSingleObjectiveSelector, INichingSingleObjectiveSelector {
     35  public class NichingTournamentSelector : StochasticSingleObjectiveSelector, INichingSingleObjectiveSelector, IHierarchicalSingleObjectiveSelector {
    3636
    3737    #region Parameter Properties
     
    5050    public ILookupParameter<ItemArray<IGAssistIndividual>> IndividualParameter {
    5151      get { return (ILookupParameter<ItemArray<IGAssistIndividual>>)Parameters["Individual"]; }
     52    }
     53    public ILookupParameter<ItemArray<DoubleValue>> LengthParameter {
     54      get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Length"]; }
     55    }
     56    public IValueLookupParameter<DoubleValue> LengthThresholdParameter {
     57      get { return (IValueLookupParameter<DoubleValue>)Parameters["LengthThreshold"]; }
     58    }
     59    public IValueLookupParameter<IntValue> IterationHirachicalSelectionParameter {
     60      get { return (IValueLookupParameter<IntValue>)Parameters["IterationHirachicalSelection"]; }
     61    }
     62
     63    public ILookupParameter<IntValue> IterationsParameter {
     64      get { return (ILookupParameter<IntValue>)Parameters["Iterations"]; }
     65    }
     66    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     67      get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
    5268    }
    5369    #endregion
     
    6581      Parameters.Add(new ValueLookupParameter<IntValue>("ParentsPerChild", ""));
    6682      Parameters.Add(new ScopeTreeLookupParameter<IGAssistIndividual>("Individual", ""));
     83      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Length", "The length value contained in each sub-scope which is used for selection."));
     84      Parameters.Add(new ValueLookupParameter<DoubleValue>("LengthThreshold", "", new DoubleValue(0.000001)));
     85      Parameters.Add(new ValueLookupParameter<IntValue>("IterationHirachicalSelection", "", new IntValue(24)));
     86      Parameters.Add(new LookupParameter<IntValue>("Iterations", ""));
     87      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", ""));
    6788    }
    6889    public override IDeepCloneable Clone(Cloner cloner) {
     
    7697      bool maximization = MaximizationParameter.ActualValue.Value;
    7798      List<double> qualities = QualityParameter.ActualValue.Where(x => IsValidQuality(x.Value)).Select(x => x.Value).ToList();
     99      List<double> lengths = LengthParameter.ActualValue.Select(x => x.Value).ToList();
     100      bool useLength = lengths.Count > 0;
     101      double lengtThreshold = LengthThresholdParameter.ActualValue.Value;
    78102      List<IGAssistIndividual> individuals = IndividualParameter.ActualValue.ToList();
    79103      int groupSize = GroupSizeParameter.ActualValue.Value;
     
    83107      //check if list with indexes is as long as the original scope list
    84108      //otherwise invalid quality values were filtered
    85       if (qualities.Count != scopes.Count || individuals.Count != scopes.Count) {
     109      if (qualities.Count != scopes.Count || individuals.Count != scopes.Count || (useLength && lengths.Count != scopes.Count)) {
    86110        throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate.");
    87111      }
    88112
    89113      int parentsPerChild = ParentsPerChildParameter.ActualValue.Value;
    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);
    93 
    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);
    99       }
    100 
    101       var possibleNiches = nicheScope.Keys.ToList();
    102       foreach (var niche in possibleNiches) {
    103         selectPerNiche.Add(niche, count / possibleNiches.Count);
    104       }
    105 
    106       int curCount = 0;
    107       while (curCount < count) {
    108         IGAssistNiche niche = null;
    109         int best = -1;
    110         if (doNiching) {
    111           niche = GetNiche(random, selectPerNiche, possibleNiches);
    112         } else {
    113           best = random.Next(scopes.Count);
    114         }
    115         for (int i = 0; i < parentsPerChild; i++) {
     114
     115      if (individuals.Any(x => x.Niche == null) && individuals.Any(x => x.Niche != null)) {
     116        throw new ArgumentException("Either all individuals have a default action or none.");
     117      }
     118
     119      //null cannot be a key in a dictionary (nicheScope), therefore torunament selection has to be done differently
     120      //to keep it a little maintainable, the case that no default rule is used has been separated
     121      if (individuals.Any(x => x.Niche == null)) {
     122        //normal tournament selection
     123        for (int i = 0; i < count; i++) {
     124          int best = random.Next(scopes.Count);
    116125          int index;
    117           if (doNiching) {
    118             best = nicheScope[niche][random.Next(nicheScope[niche].Count)];
    119           }
    120126          for (int j = 1; j < groupSize; j++) {
    121             if (niche != null) {
    122               index = nicheScope[niche][random.Next(nicheScope[niche].Count)];
    123             } else {
    124               index = random.Next(scopes.Count);
    125             }
    126             if (((maximization) && (qualities[index] > qualities[best])) ||
    127                 ((!maximization) && (qualities[index] < qualities[best]))) {
     127            index = random.Next(scopes.Count);
     128            if (IsBetterHirachical(index, best, qualities, lengths, lengtThreshold, useLength, maximization)) {
    128129              best = index;
    129130            }
    130131          }
    131132
    132           niche = individuals[best].Niche;
    133 
    134133          if (copy)
    135             selected[curCount] = (IScope)scopes[best].Clone();
     134            selected[i] = (IScope)scopes[best].Clone();
    136135          else {
    137             selected[curCount] = scopes[best];
     136            selected[i] = scopes[best];
    138137            scopes.RemoveAt(best);
    139138            qualities.RemoveAt(best);
    140139          }
    141           selectPerNiche[niche]--;
    142           curCount++;
     140        }
     141      } else {
     142        var nicheComparer = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().First().Comparer;
     143        var selectPerNiche = new Dictionary<IGAssistNiche, int>(nicheComparer);
     144        var nicheScope = new Dictionary<IGAssistNiche, List<int>>(nicheComparer);
     145        //niching tournament selection
     146        for (int i = 0; i < individuals.Count; i++) {
     147          if (!nicheScope.ContainsKey(individuals[i].Niche)) {
     148            nicheScope.Add(individuals[i].Niche, new List<int>());
     149          }
     150          nicheScope[individuals[i].Niche].Add(i);
     151        }
     152
     153        var possibleNiches = nicheScope.Keys.ToList();
     154        foreach (var niche in possibleNiches) {
     155          selectPerNiche.Add(niche, count / possibleNiches.Count);
     156        }
     157
     158        int curCount = 0;
     159        while (curCount < count) {
     160          IGAssistNiche niche = null;
     161          int best = -1;
     162          if (doNiching) {
     163            niche = GetNiche(random, selectPerNiche, possibleNiches);
     164          } else {
     165            best = random.Next(scopes.Count);
     166          }
     167          for (int i = 0; i < parentsPerChild; i++) {
     168            int index;
     169            if (doNiching) {
     170              best = nicheScope[niche][random.Next(nicheScope[niche].Count)];
     171            }
     172            for (int j = 1; j < groupSize; j++) {
     173              if (niche != null) {
     174                index = nicheScope[niche][random.Next(nicheScope[niche].Count)];
     175              } else {
     176                index = random.Next(scopes.Count);
     177              }
     178              if (IsBetterHirachical(index, best, qualities, lengths, lengtThreshold, useLength, maximization)) {
     179                best = index;
     180              }
     181            }
     182
     183            niche = individuals[best].Niche;
     184
     185            if (copy)
     186              selected[curCount] = (IScope)scopes[best].Clone();
     187            else {
     188              selected[curCount] = scopes[best];
     189              scopes.RemoveAt(best);
     190              qualities.RemoveAt(best);
     191            }
     192            selectPerNiche[niche]--;
     193            curCount++;
     194          }
    143195        }
    144196      }
    145197      return selected;
     198    }
     199
     200    private bool IsBetterHirachical(int indexTrue, int indexFalse, IList<double> qualities, IList<double> length, double hierarchicalThreshold, bool useLength, bool maximization) {
     201      if (useLength && IterationsParameter.ActualValue.Value >= IterationHirachicalSelectionParameter.ActualValue.Value
     202        && Math.Abs(qualities[indexTrue] - qualities[indexFalse]) <= hierarchicalThreshold
     203        && length[indexTrue] != length[indexFalse]) {
     204        return length[indexTrue] < length[indexFalse];
     205      }
     206      return IsBetter(indexTrue, indexFalse, qualities, maximization);
     207    }
     208
     209    private bool IsBetter(int indexTrue, int indexFalse, IList<double> qualities, bool maximization) {
     210      return ((maximization) && (qualities[indexTrue] > qualities[indexFalse])) ||
     211             ((!maximization) && (qualities[indexTrue] < qualities[indexFalse]));
    146212    }
    147213
  • branches/LearningClassifierSystems/HeuristicLab.Problems.CombinedIntegerVectorClassification/3.3/Plugin.cs.frame

    r9226 r9605  
    2525  [Plugin("HeuristicLab.Problems.CombinedIntegerVectorClassification", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.CombinedIntegerVectorClassification-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
    2830  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.CombinedIntegerVectorEncoding", "3.3")]
     32  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     35  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.ConditionActionClassification", "3.3")]
     37  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    2938  public class HeuristicLabProblemsCombinedIntegerVectorClassificationPlugin : PluginBase {
    3039  }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Plugin.cs.frame

    r9089 r9605  
    2525  [Plugin("HeuristicLab.Problems.ConditionActionClassification", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.ConditionActionClassification-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
    2830  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     32  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     33  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     34  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     35  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     36  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    2937  public class HeuristicLabProblemsConditionActionClassificationPlugin : PluginBase {
    3038  }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblem.cs

    r9411 r9605  
    4444
    4545    #region parameter properties
    46     public IFixedValueParameter<BoolValue> MaximizationParameter {
    47       get { return (IFixedValueParameter<BoolValue>)Parameters["Maximization"]; }
     46    public FixedValueParameter<BoolValue> MaximizationParameter {
     47      get { return (FixedValueParameter<BoolValue>)Parameters["Maximization"]; }
    4848    }
    4949    IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
     
    8585    }
    8686
    87     IStrataSingleObjectiveEvaluator IGAssistProblem.Evaluator {
     87    IGAssistObjectiveEvaluator IGAssistProblem.Evaluator {
    8888      get { return Evaluator; }
    8989    }
     
    108108      : this(new DecisionListClassificationProblemData(new Dataset(DecisionListClassificationProblemData.defaultVariableNames, DecisionListClassificationProblemData.defaultData),
    109109        DecisionListClassificationProblemData.defaultVariableNames.Take(DecisionListClassificationProblemData.defaultVariableNames.Length - 1), DecisionListClassificationProblemData.defaultVariableNames.Last()),
    110         new MDLEvaluator(), new UniformRandomDecisionListCreator()) { }
     110        new MDLEvaluator(), new SmartDecisionListCreator()) { }
    111111
    112112    public DecisionListClassificationProblem(IDecisionListClassificationProblemData problemData, IDecisionListEvaluator decisionlistEvaluator, IDecisionListCreator decisionListCreator)
     
    118118      Parameters.Add(new FixedValueParameter<PercentValue>("ActionMutationProbability", "", new PercentValue(0.1)));
    119119
     120      MaximizationParameter.Value.Value = Evaluator.MaximizationParameter.Value.Value;
     121      Evaluator.MaximizationParameter.Value.ValueChanged += MaximizationParameter_ValueChanged;
    120122      Evaluator.SizePenaltyMinRulesParameter.ActualName = "SizePenaltyMinRules";
    121123
    122124      InitializeOperators();
     125    }
     126
     127    private void MaximizationParameter_ValueChanged(object sender, System.EventArgs e) {
     128      MaximizationParameter.Value.Value = Evaluator.MaximizationParameter.Value.Value;
    123129    }
    124130
     
    143149
    144150    private void ParameterizeOperators() {
    145       var autoDefaultRule = Operators.Where(x => x is AutoDefaultRule).Select(x => x as AutoDefaultRule).First();
     151      var autoDefaultRule = Operators.OfType<AutoDefaultRule>().First();
    146152      autoDefaultRule.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    147153      autoDefaultRule.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name;
     
    149155      foreach (IDefaultRuleOperator op in Operators.OfType<IDefaultRuleOperator>()) {
    150156        op.IndividualParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName;
    151         op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    152157        op.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name;
    153158        op.GAssistNichesProblemDataParameter.Hidden = true;
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs

    r9470 r9605  
    4444      {0,1,1,1,0,0,0},
    4545      {0,0,1,0,0,0,1},
     46      {1,0,1,0,1,1,0},
     47      {0,0,1,1,0,0,0},
     48      {0,1,1,1,0,0,0},
     49      {0,0,1,0,0,0,1},
    4650      {1,0,1,0,1,1,0}
    4751    };
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/HeuristicLab.Problems.DecisionListClassification-3.3.csproj

    r9352 r9605  
    9595  </ItemGroup>
    9696  <ItemGroup>
    97     <ProjectReference Include="..\..\HeuristicLab.Algorithms.GAssist\3.3\HeuristicLab.Algorithms.GAssist-3.3.csproj">
    98       <Project>{f191a6fa-1b3c-4f82-a711-873b4d839bc0}</Project>
    99       <Name>HeuristicLab.Algorithms.GAssist-3.3</Name>
    100     </ProjectReference>
    10197    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    10298      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/Plugin.cs.frame

    r9334 r9605  
    2525  [Plugin("HeuristicLab.Problems.DecisionListClassification", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.DecisionListClassification-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
    2729  [PluginDependency("HeuristicLab.Core", "3.3")]
     30  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.DecisionList", "3.3")]
     32  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     35  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     37  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    2838  public class HeuristicLabProblemsDecisionListClassificationPlugin : PluginBase {
    2939  }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.Instances.LCS/3.3/Plugin.cs.frame

    r9352 r9605  
    2525  [Plugin("HeuristicLab.Problems.Instances.LCS", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.Instances.LCS-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     28  [PluginDependency("HeuristicLab.Problems.CombinedIntegerVectorClassification", "3.3")]
     29  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     30  [PluginDependency("HeuristicLab.Problems.DecisionListClassification", "3.3")]
    2731  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     32  [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
     33  [PluginDependency("HeuristicLab.Problems.VariableVectorClassification", "3.3")]
    2834  public class HeuristicLabProblemsInstancesLCSPlugin : PluginBase {
    2935  }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.LCS.Views/3.3/Plugin.cs.frame

    r9352 r9605  
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2828  [PluginDependency("HeuristicLab.Common", "3.3")]
    29   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    30   [PluginDependency("HeuristicLab.Core", "3.3")]
    3129  [PluginDependency("HeuristicLab.Data", "3.3")]
    3230  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.DecisionList", "3.3")]
    3332  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3433  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
  • branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/Plugin.cs.frame

    r9352 r9605  
    2525  [Plugin("HeuristicLab.Problems.VariableVectorClassification", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.VariableVectorClassification-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Core", "3.3")]
    2830  [PluginDependency("HeuristicLab.Data", "3.3")]
     31  [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")]
     32  [PluginDependency("HeuristicLab.Encodings.VariableVector", "3.3")]
     33  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     34  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     35  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     36  [PluginDependency("HeuristicLab.Problems.ConditionActionClassification", "3.3")]
     37  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    2938  public class HeuristicLabProblemsVariableVectorClassificationPlugin : PluginBase {
    3039  }
Note: See TracChangeset for help on using the changeset viewer.