Changeset 9605 for branches/LearningClassifierSystems
- Timestamp:
- 06/11/13 13:32:32 (11 years ago)
- 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 37 37 [PluginDependency("HeuristicLab.Core", "3.3")] 38 38 [PluginDependency("HeuristicLab.Data", "3.3")] 39 [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")] 39 40 [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")] 40 41 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 41 42 [PluginDependency("HeuristicLab.Operators", "3.3")] 42 43 [PluginDependency("HeuristicLab.Optimization", "3.3")] 44 [PluginDependency("HeuristicLab.Optimization.Operators.LCS", "3.3")] 43 45 [PluginDependency("HeuristicLab.Parameters", "3.3")] 44 46 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/GAssist.cs
r9411 r9605 201 201 get { return (VariableCreator)RandomCreator.Successor; } 202 202 } 203 private Placeholder InitialDefaultRuleExecution { 204 get { return (Placeholder)VariableCreator.Successor; } 205 } 203 206 private Placeholder MDLIterationPlaceholder { 204 get { return (Placeholder) VariableCreator.Successor; }207 get { return (Placeholder)InitialDefaultRuleExecution.Successor; } 205 208 } 206 209 private ILASOperator ILASOperator { … … 210 213 get { return (InitializeDiscretizersOperator)ILASOperator.Successor; } 211 214 } 212 private SolutionsCreator SolutionsCreator {213 get { return ( SolutionsCreator)InitializeDiscretizers.Successor; }215 private NicheSolutionCreator SolutionsCreator { 216 get { return (NicheSolutionCreator)InitializeDiscretizers.Successor; } 214 217 } 215 218 private GAssistMainLoop GeneticAlgorithmMainLoop { … … 255 258 RandomCreator randomCreator = new RandomCreator(); 256 259 VariableCreator variableCreator = new VariableCreator(); 260 Placeholder initialDefaultRuleExecution = new Placeholder(); 257 261 Placeholder mdlIterationPlaceholder = new Placeholder(); 258 262 ILASOperator ilasOperator = new ILASOperator(); 259 263 InitializeDiscretizersOperator initializeDiscretizers = new InitializeDiscretizersOperator(); 260 SolutionsCreator solutionsCreator = new SolutionsCreator();264 NicheSolutionCreator solutionsCreator = new NicheSolutionCreator(); 261 265 SubScopesCounter subScopesCounter = new SubScopesCounter(); 262 266 ResultsCollector resultsCollector = new ResultsCollector(); … … 272 276 273 277 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; 275 283 276 284 mdlIterationPlaceholder.Name = "MDL Iteration Operator"; … … 315 323 foreach (INichingSingleObjectiveSelector selector in ApplicationManager.Manager.GetInstances<INichingSingleObjectiveSelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) 316 324 SelectorParameter.ValidValues.Add(selector); 317 //INichingSingleObjectiveSelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector")); 318 //if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector; 325 319 326 ParameterizeSelectors(); 320 327 … … 369 376 SpecialStages.Operators.Clear(); 370 377 var splitOperator = new SplitOperator(); 371 splitOperator.ProbabilityParameter.ActualName = "SplitProbability";378 splitOperator.ProbabilityParameter.ActualName = SplitProbabilityParameter.Name; 372 379 //change 373 380 splitOperator.IndividualParameter.ActualName = "DecisionList"; 374 381 SpecialStages.Operators.Add(splitOperator); 375 382 var mergeOperator = new MergeOperator(); 376 mergeOperator.ProbabilityParameter.ActualName = "MergeProbability";383 mergeOperator.ProbabilityParameter.ActualName = MergeProbabilityParameter.Name; 377 384 //change 378 385 mergeOperator.IndividualParameter.ActualName = "DecisionList"; … … 381 388 reinitializeOperator.ProbabilityParameter.ActualName = "ReinitializeProbability"; 382 389 reinitializeOperator.DiscretizersParameter.ActualName = "Discretizers"; 383 reinitializeOperator.OneProbabilityParameter.ActualName = "OneProbability";390 reinitializeOperator.OneProbabilityParameter.ActualName = OneProbabilityParameter.Name; 384 391 //change 385 392 reinitializeOperator.IndividualParameter.ActualName = "DecisionList"; … … 508 515 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 509 516 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 517 SolutionsCreator.GAssistNichesProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 510 518 // change! 511 ((IGAssist IndividualCreator)Problem.SolutionCreatorParameter.ActualValue).DiscretizersParameter.ActualName = "Discretizers";519 ((IGAssistSolutionCreator)Problem.SolutionCreatorParameter.ActualValue).DiscretizersParameter.ActualName = "Discretizers"; 512 520 } 513 521 private void ParameterizeGeneticAlgorithmMainLoop() { … … 536 544 selector.ParentsPerChildParameter.Value = new IntValue(2); 537 545 ParameterizeStochasticOperator(selector); 546 ParameterizeIterationBasedOperators(selector); 538 547 } 539 548 if (Problem != null) { 540 foreach (INichingSingleObjectiveSelector selector in SelectorParameter.ValidValues .OfType<INichingSingleObjectiveSelector>()) {549 foreach (INichingSingleObjectiveSelector selector in SelectorParameter.ValidValues) { 541 550 selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 542 551 selector.MaximizationParameter.Hidden = true; … … 547 556 //change 548 557 selector.IndividualParameter.ActualName = "DecisionList"; 558 } 559 foreach (IHierarchicalSingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<IHierarchicalSingleObjectiveSelector>()) { 560 selector.LengthParameter.ActualName = Problem.Evaluator.LengthParameter.ActualName; 549 561 } 550 562 } … … 595 607 else oldDefaultRule = null; 596 608 } 597 if (oldDefaultRule == null && defaultdefaultRule != null) 609 if (oldDefaultRule == null && defaultdefaultRule != null) { 598 610 DefaultRuleParameter.Value = defaultdefaultRule; 611 SolutionsCreator.NichingParameter.ActualName = defaultdefaultRule.NichingParameter.ActualName; 612 } 599 613 } 600 614 private void UpdateCrossovers() { -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.GAssist/3.3/Plugin.cs.frame
r9334 r9605 25 25 [Plugin("HeuristicLab.Algorithms.GAssist", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Algorithms.GAssist-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Analysis", "3.3")] 27 28 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 29 [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")] 30 37 [PluginDependency("HeuristicLab.Persistence", "3.3")] 38 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 39 [PluginDependency("HeuristicLab.Random", "3.3")] 40 [PluginDependency("HeuristicLab.Selection", "3.3")] 31 41 public class HeuristicLabAlgorithmsGAssistPlugin : PluginBase { 32 42 } -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/Plugin.cs.frame
r8941 r9605 24 24 namespace HeuristicLab.Algorithms.LearningClassifierSystems { 25 25 [Plugin("HeuristicLab.Algorithms.LearningClassifierSystems", "3.3.7.$WCREV$")] 26 [PluginDependency("HeuristicLab.Analysis", "3.3")] 26 27 [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")] 29 31 [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")] 37 41 public class HeuristicLabAlgorithmsLearningClassifierSystemsPlugin : PluginBase { 38 42 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Plugin.cs.frame
r8941 r9605 25 25 [Plugin("HeuristicLab.Encodings.CombinedIntegerVectorEncoding", "3.3.7.$WCREV$")] 26 26 [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")] 29 30 [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")] 33 37 [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")]37 38 public class HeuristicLabEncodingsCombinedIntegerVectorEncodingPlugin : PluginBase { 38 39 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Plugin.cs.frame
r9089 r9605 25 25 [Plugin("HeuristicLab.Encodings.ConditionActionEncoding", "3.3.7.$WCREV$")] 26 26 [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")] 27 30 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 31 [PluginDependency("HeuristicLab.Core", "3.3")] 28 32 [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")] 29 39 public class HeuristicLabEncodingsConditionActionEncodingPlugin : PluginBase { 30 40 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/IAction.cs
r9352 r9605 34 34 bool Match(IAction action); 35 35 void SetTo(string value); 36 void SetTo(IGAssistNiche action); 36 37 37 38 IEnumerable<int> GetPossibleActionPositions(); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/IntAction.cs
r9411 r9605 117 117 118 118 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); 120 126 } 121 127 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Action/StringAction.cs
r9411 r9605 122 122 123 123 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); 125 131 } 126 132 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Creators/UniformRandomDecisionListCreator.cs
r9352 r9605 43 43 } 44 44 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) { 46 46 List<Rule> rules = new List<Rule>(); 47 47 for (int i = 0; i < initialNumberOfRules; i++) { 48 48 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 } 50 54 rules.Add(newRule); 51 55 } 52 56 53 return new DecisionList(rules); 57 if (niche != null) { 58 return new DecisionList(rules, niche); 59 } else { 60 return new DecisionList(rules); 61 } 54 62 } 55 63 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Crossover/SinglePointCrossover.cs
r9352 r9605 48 48 49 49 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!"); } 51 52 52 53 int rulesP1 = random.Next(0, parent1.Rules.Count()); … … 64 65 } 65 66 67 if (parent1.DefaultAction == null) { 68 return new DecisionList(rules); 69 } 66 70 return new DecisionList(rules, parent1.DefaultAction); 67 71 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionList.cs
r9411 r9605 44 44 } 45 45 46 public double Length { 47 get { return 1 + rules.Sum(r => r.Length); } 48 } 49 46 50 // default rule (action) is part of the rule set size 47 51 public int RuleSetSize { … … 53 57 protected DecisionList(DecisionList original, Cloner cloner) 54 58 : base(original, cloner) { 55 defaultAction = original.DefaultAction;59 defaultAction = cloner.Clone(original.DefaultAction); 56 60 rules = new List<Rule>(original.rules.Count); 57 61 foreach (var rule in original.Rules) { … … 124 128 } 125 129 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 141 130 public void ApplySplit(IRandom random, double probability) { 142 131 foreach (var rule in rules) { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListCreator.cs
r9352 r9605 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 52 53 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 53 54 } 55 public ILookupParameter<IGAssistNiche> GAssistNicheParameter { 56 get { return (ILookupParameter<IGAssistNiche>)Parameters["GAssistNiche"]; } 57 } 54 58 #endregion 55 59 … … 67 71 Parameters.Add(new LookupParameter<DecisionList>("DecisionList", "")); 68 72 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", "")); 70 74 } 71 75 72 76 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); 74 84 return base.Apply(); 75 85 } 76 86 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); 78 88 } 79 89 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs
r9475 r9605 49 49 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 50 50 } 51 public ILookupParameter<DoubleValue> LengthParameter { 52 get { return (ILookupParameter<DoubleValue>)Parameters["Length"]; } 53 } 51 54 public IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { 52 55 get { return (IValueLookupParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; } 53 56 } 54 57 58 public IValueLookupParameter<BoolValue> UseMDLParameter { 59 get { return (IValueLookupParameter<BoolValue>)Parameters["UseMDL"]; } 60 } 55 61 public ILookupParameter<MDLCalculator> MDLCalculatorParameter { 56 62 get { return (ILookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; } … … 73 79 get { return (ILookupParameter<ItemList<ItemList<IntValue>>>)Parameters["Strata"]; } 74 80 } 81 public IValueLookupParameter<BoolValue> MaximizationParameter { 82 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 83 } 75 84 #endregion 76 85 … … 90 99 Parameters.Add(new ValueLookupParameter<IntValue>("SizePenaltyMinRules", "")); 91 100 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "")); 101 Parameters.Add(new LookupParameter<DoubleValue>("Length", "")); 92 102 Parameters.Add(new ValueLookupParameter<IDecisionListClassificationProblemData>("ProblemData", "")); 103 Parameters.Add(new ValueLookupParameter<BoolValue>("UseMDL", "", new BoolValue(true))); 93 104 Parameters.Add(new LookupParameter<MDLCalculator>("MDLCalculator", "")); 94 105 Parameters.Add(new LookupParameter<IntValue>("Iterations", "")); … … 97 108 Parameters.Add(new ValueLookupParameter<IntValue>("RuleDeletionMinRules", "", new IntValue(12))); 98 109 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; 99 117 } 100 118 public override IDeepCloneable Clone(Cloner cloner) { … … 103 121 104 122 public override IOperation Apply() { 105 double penalty = 1;106 107 123 var strata = StrataParameter.ActualValue; 108 124 int iteration = IterationsParameter.ActualValue.Value; … … 125 141 var estimated = dl.Evaluate(input, out aliveRules, out theoryLength); 126 142 143 double penalty = 1; 127 144 if (aliveRules.Count < SizePenaltyMinRulesParameter.ActualValue.Value) { 128 145 penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - aliveRules.Count)); … … 132 149 133 150 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 } 135 157 136 158 if (iteration >= IterationRuleDeletionParameter.ActualValue.Value) { … … 141 163 } 142 164 } 165 166 LengthParameter.ActualValue = new DoubleValue(dl.Length * aliveRules.Count / dl.RuleSetSize); 143 167 return base.Apply(); 144 168 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/HeuristicLab.Encodings.DecisionList-3.3.csproj
r9411 r9605 93 93 <Compile Include="Action\IntAction.cs" /> 94 94 <Compile Include="Analyzer\BestTrainingDecisionListAnalyzer.cs" /> 95 <Compile Include="Creators\SmartDecisionListCreator.cs" /> 95 96 <Compile Include="Creators\UniformRandomDecisionListCreator.cs" /> 96 97 <Compile Include="Crossover\SinglePointCrossover.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListCreator.cs
r9352 r9605 26 26 27 27 namespace HeuristicLab.Encodings.DecisionList { 28 public interface IDecisionListCreator : IDecisionListOperator, ISolutionCreator, IStochasticOperator, IGAssist IndividualCreator {28 public interface IDecisionListCreator : IDecisionListOperator, ISolutionCreator, IStochasticOperator, IGAssistSolutionCreator { 29 29 IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { get; } 30 30 ILookupParameter<DecisionList> DecisionListParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Interfaces/IDecisionListEvaluator.cs
r9392 r9605 25 25 26 26 namespace HeuristicLab.Encodings.DecisionList { 27 public interface IDecisionListEvaluator : I StrataSingleObjectiveEvaluator {27 public interface IDecisionListEvaluator : IGAssistObjectiveEvaluator { 28 28 ILookupParameter<DecisionList> DecisionListParameter { get; } 29 29 IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Plugin.cs.frame
r9334 r9605 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 28 [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")] 30 35 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 31 37 public class HeuristicLabEncodingsDecisionListPlugin : PluginBase { 32 38 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Rule.cs
r9392 r9605 43 43 public IAction Action { get { return action; } } 44 44 45 public double Length { 46 get { return variables.Values.Sum(x => x.Length); } 47 } 48 45 49 [StorableConstructor] 46 50 protected Rule(bool deserializing) : base(deserializing) { } … … 77 81 } 78 82 79 public void Randomize(IRandom random, double oneP ercentage, IEnumerable<IDiscretizer> discretizer) {83 public void Randomize(IRandom random, double oneProbability, IEnumerable<IDiscretizer> discretizers, IEnumerable<IAction> exceptActions = null) { 80 84 foreach (var variable in variables.Values) { 81 variable.Randomize(random, oneP ercentage, discretizer);85 variable.Randomize(random, oneProbability, discretizers); 82 86 } 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 } 84 101 } 85 102 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/DoubleVariable.cs
r9392 r9605 191 191 public override void Reinitialize(IRandom random, double onePercentage, IEnumerable<IDiscretizer> descretizers) { 192 192 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; 194 203 } 195 204 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/IVariable.cs
r9342 r9605 27 27 namespace HeuristicLab.Encodings.DecisionList { 28 28 public interface IVariable : IItem { 29 double Length { get; } 29 30 string VariableName { get; } 30 31 Type VariableType { get; } … … 43 44 44 45 void Split(IRandom Random); 46 47 void SetToMatch(string variableValue); 45 48 } 46 49 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/IntVariable.cs
r9334 r9605 68 68 return attributes[possibleFeatures.IndexOf(input)]; 69 69 } 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 } 70 77 } 71 78 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/StringVariable.cs
r9334 r9605 64 64 return attributes[possibleFeatures.IndexOf(input)]; 65 65 } 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 } 66 73 } 67 74 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Variable/Variable.cs
r9352 r9605 38 38 } 39 39 40 public double Length { 41 get { return attributes.Count; } 42 } 43 40 44 [Storable] 41 45 protected string variableName; … … 72 76 public abstract bool Match(string input); 73 77 78 public abstract void SetToMatch(string variableValue); 79 74 80 public virtual string ToFullString() { throw new NotImplementedException(); } 75 81 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Plugin.cs.frame
r9194 r9605 25 25 [Plugin("HeuristicLab.Encodings.VariableVector", "3.3.7.$WCREV$")] 26 26 [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")] 28 30 [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")] 29 37 public class HeuristicLabEncodingsVariableVectorPlugin : PluginBase { 30 38 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Interfaces/IGAssistIndividual.cs
r9411 r9605 25 25 namespace HeuristicLab.Optimization.Operators.LCS { 26 26 public interface IGAssistIndividual : IGAssistModel { 27 double Length { get; } 27 28 IGAssistNiche Niche { get; } 28 void SetNiche(IRandom random, IGAssistNiche niche);29 29 void ApplySplit(IRandom random, double probability); 30 30 void ApplyMerge(IRandom random, double probability); -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Interfaces/IGAssistProblem.cs
r9411 r9605 24 24 namespace HeuristicLab.Optimization.Operators.LCS { 25 25 public interface IGAssistProblem : ISingleObjectiveHeuristicOptimizationProblem, IDataAnalysisProblem { 26 new I StrataSingleObjectiveEvaluator Evaluator { get; }26 new IGAssistObjectiveEvaluator Evaluator { get; } 27 27 string NichingParameterName { get; } 28 28 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/HeuristicLab.Optimization.Operators.LCS-3.3.csproj
r9411 r9605 92 92 </ItemGroup> 93 93 <ItemGroup> 94 <Compile Include=" DefaultRule\AutoDefaultRule.cs" />94 <Compile Include="GAssist\DefaultRule\AutoDefaultRule.cs" /> 95 95 <Compile Include="Discretizer\InitializeDiscretizersOperator.cs" /> 96 96 <Compile Include="GAssist\GAssistNicheComparer.cs" /> … … 100 100 <Compile Include="GAssist\Interfaces\IGAssistEnsembleProblemData.cs" /> 101 101 <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" /> 107 107 <Compile Include="Discretizer\UniformWidthDiscretizer.cs" /> 108 108 <Compile Include="Discretizer\IDiscretizer.cs" /> … … 112 112 <Compile Include="GAssist\Interfaces\IGAssistEnsembleSolution.cs" /> 113 113 <Compile Include="GAssist\Interfaces\IGAssistIndividual.cs" /> 114 <Compile Include="GAssist\Interfaces\IGAssistIndividualCreator.cs" />115 114 <Compile Include="GAssist\Interfaces\IGAssistInput.cs" /> 116 115 <Compile Include="GAssist\Interfaces\IGAssistModel.cs" /> … … 118 117 <Compile Include="GAssist\Interfaces\IGAssistNicheEqualityComparer.cs" /> 119 118 <Compile Include="GAssist\Interfaces\IGAssistSolution.cs" /> 119 <Compile Include="GAssist\Interfaces\IGAssistSolutionCreator.cs" /> 120 120 <Compile Include="GAssist\Interfaces\IGAssistSpecialStage.cs" /> 121 <Compile Include="GAssist\Interfaces\I StrataSingleObjectiveEvaluator.cs" />121 <Compile Include="GAssist\Interfaces\IGAssistObjectiveEvaluator.cs" /> 122 122 <Compile Include="GAssist\MDL\IMDLCalculatorBasedOperator.cs" /> 123 123 <Compile Include="GAssist\MDL\MDLCalculator.cs" /> 124 124 <Compile Include="GAssist\MDL\MDLIterationOperator.cs" /> 125 <Compile Include="GAssist\NicheSolutionCreator.cs" /> 125 126 <Compile Include="GAssist\SpecialStage\GAssistSpecialStageMultiOperator.cs" /> 126 127 <Compile Include="GAssist\SpecialStage\GAssistSpecialStageOperator.cs" /> … … 129 130 <Compile Include="GAssist\SpecialStage\SplitOperator.cs" /> 130 131 <Compile Include="Plugin.cs" /> 132 <Compile Include="Selection\IHierarchicalSingleObjectiveEvaluator.cs" /> 133 <Compile Include="Selection\IHierarchicalSingleObjectiveSelector.cs" /> 131 134 <Compile Include="Selection\INichingSingleObjectiveSelector.cs" /> 132 135 <Compile Include="Selection\NichingTournamentSelector.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Plugin.cs.frame
r9342 r9605 25 25 [Plugin("HeuristicLab.Optimization.Operators.LCS", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Optimization.Operators.LCS-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 [PluginDependency("HeuristicLab.Common", "3.3")] 27 29 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 30 [PluginDependency("HeuristicLab.Core", "3.3")] 28 31 [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")] 29 38 public class HeuristicLabOptimizationOperatorsLCSPlugin : PluginBase { 30 39 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs
r9475 r9605 33 33 [Item("NichingTournamentSelector", "Description missing")] 34 34 [StorableClass] 35 public class NichingTournamentSelector : StochasticSingleObjectiveSelector, INichingSingleObjectiveSelector {35 public class NichingTournamentSelector : StochasticSingleObjectiveSelector, INichingSingleObjectiveSelector, IHierarchicalSingleObjectiveSelector { 36 36 37 37 #region Parameter Properties … … 50 50 public ILookupParameter<ItemArray<IGAssistIndividual>> IndividualParameter { 51 51 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"]; } 52 68 } 53 69 #endregion … … 65 81 Parameters.Add(new ValueLookupParameter<IntValue>("ParentsPerChild", "")); 66 82 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", "")); 67 88 } 68 89 public override IDeepCloneable Clone(Cloner cloner) { … … 76 97 bool maximization = MaximizationParameter.ActualValue.Value; 77 98 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; 78 102 List<IGAssistIndividual> individuals = IndividualParameter.ActualValue.ToList(); 79 103 int groupSize = GroupSizeParameter.ActualValue.Value; … … 83 107 //check if list with indexes is as long as the original scope list 84 108 //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)) { 86 110 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 87 111 } 88 112 89 113 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); 116 125 int index; 117 if (doNiching) {118 best = nicheScope[niche][random.Next(nicheScope[niche].Count)];119 }120 126 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)) { 128 129 best = index; 129 130 } 130 131 } 131 132 132 niche = individuals[best].Niche;133 134 133 if (copy) 135 selected[ curCount] = (IScope)scopes[best].Clone();134 selected[i] = (IScope)scopes[best].Clone(); 136 135 else { 137 selected[ curCount] = scopes[best];136 selected[i] = scopes[best]; 138 137 scopes.RemoveAt(best); 139 138 qualities.RemoveAt(best); 140 139 } 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 } 143 195 } 144 196 } 145 197 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])); 146 212 } 147 213 -
branches/LearningClassifierSystems/HeuristicLab.Problems.CombinedIntegerVectorClassification/3.3/Plugin.cs.frame
r9226 r9605 25 25 [Plugin("HeuristicLab.Problems.CombinedIntegerVectorClassification", "3.3.7.$WCREV$")] 26 26 [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")] 28 30 [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")] 29 38 public class HeuristicLabProblemsCombinedIntegerVectorClassificationPlugin : PluginBase { 30 39 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Plugin.cs.frame
r9089 r9605 25 25 [Plugin("HeuristicLab.Problems.ConditionActionClassification", "3.3.7.$WCREV$")] 26 26 [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")] 28 30 [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")] 29 37 public class HeuristicLabProblemsConditionActionClassificationPlugin : PluginBase { 30 38 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblem.cs
r9411 r9605 44 44 45 45 #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"]; } 48 48 } 49 49 IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter { … … 85 85 } 86 86 87 I StrataSingleObjectiveEvaluator IGAssistProblem.Evaluator {87 IGAssistObjectiveEvaluator IGAssistProblem.Evaluator { 88 88 get { return Evaluator; } 89 89 } … … 108 108 : this(new DecisionListClassificationProblemData(new Dataset(DecisionListClassificationProblemData.defaultVariableNames, DecisionListClassificationProblemData.defaultData), 109 109 DecisionListClassificationProblemData.defaultVariableNames.Take(DecisionListClassificationProblemData.defaultVariableNames.Length - 1), DecisionListClassificationProblemData.defaultVariableNames.Last()), 110 new MDLEvaluator(), new UniformRandomDecisionListCreator()) { }110 new MDLEvaluator(), new SmartDecisionListCreator()) { } 111 111 112 112 public DecisionListClassificationProblem(IDecisionListClassificationProblemData problemData, IDecisionListEvaluator decisionlistEvaluator, IDecisionListCreator decisionListCreator) … … 118 118 Parameters.Add(new FixedValueParameter<PercentValue>("ActionMutationProbability", "", new PercentValue(0.1))); 119 119 120 MaximizationParameter.Value.Value = Evaluator.MaximizationParameter.Value.Value; 121 Evaluator.MaximizationParameter.Value.ValueChanged += MaximizationParameter_ValueChanged; 120 122 Evaluator.SizePenaltyMinRulesParameter.ActualName = "SizePenaltyMinRules"; 121 123 122 124 InitializeOperators(); 125 } 126 127 private void MaximizationParameter_ValueChanged(object sender, System.EventArgs e) { 128 MaximizationParameter.Value.Value = Evaluator.MaximizationParameter.Value.Value; 123 129 } 124 130 … … 143 149 144 150 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(); 146 152 autoDefaultRule.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 147 153 autoDefaultRule.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name; … … 149 155 foreach (IDefaultRuleOperator op in Operators.OfType<IDefaultRuleOperator>()) { 150 156 op.IndividualParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName; 151 op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;152 157 op.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name; 153 158 op.GAssistNichesProblemDataParameter.Hidden = true; -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs
r9470 r9605 44 44 {0,1,1,1,0,0,0}, 45 45 {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}, 46 50 {1,0,1,0,1,1,0} 47 51 }; -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/HeuristicLab.Problems.DecisionListClassification-3.3.csproj
r9352 r9605 95 95 </ItemGroup> 96 96 <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>101 97 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 102 98 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/Plugin.cs.frame
r9334 r9605 25 25 [Plugin("HeuristicLab.Problems.DecisionListClassification", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.DecisionListClassification-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 [PluginDependency("HeuristicLab.Common", "3.3")] 27 29 [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")] 28 38 public class HeuristicLabProblemsDecisionListClassificationPlugin : PluginBase { 29 39 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.Instances.LCS/3.3/Plugin.cs.frame
r9352 r9605 25 25 [Plugin("HeuristicLab.Problems.Instances.LCS", "3.3.7.$WCREV$")] 26 26 [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")] 27 31 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 32 [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")] 33 [PluginDependency("HeuristicLab.Problems.VariableVectorClassification", "3.3")] 28 34 public class HeuristicLabProblemsInstancesLCSPlugin : PluginBase { 29 35 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.LCS.Views/3.3/Plugin.cs.frame
r9352 r9605 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 28 [PluginDependency("HeuristicLab.Common", "3.3")] 29 [PluginDependency("HeuristicLab.Common.Resources", "3.3")]30 [PluginDependency("HeuristicLab.Core", "3.3")]31 29 [PluginDependency("HeuristicLab.Data", "3.3")] 32 30 [PluginDependency("HeuristicLab.Encodings.ConditionActionEncoding", "3.3")] 31 [PluginDependency("HeuristicLab.Encodings.DecisionList", "3.3")] 33 32 [PluginDependency("HeuristicLab.MainForm", "3.3")] 34 33 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/Plugin.cs.frame
r9352 r9605 25 25 [Plugin("HeuristicLab.Problems.VariableVectorClassification", "3.3.7.$WCREV$")] 26 26 [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")] 28 30 [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")] 29 38 public class HeuristicLabProblemsVariableVectorClassificationPlugin : PluginBase { 30 39 }
Note: See TracChangeset
for help on using the changeset viewer.