Changeset 9352 for branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule
- Timestamp:
- 04/10/13 15:15:13 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3
-
Property
svn:ignore
set to
obj
Plugin.cs
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule/AutoDefaultRule.cs
r9342 r9352 44 44 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Quality"]; } 45 45 } 46 public ILookupParameter<ItemArray<IGAssistIndividual>> IndividualParameter {47 get { return (ILookupParameter<ItemArray<IGAssistIndividual>>)Parameters["Individual"]; }48 }49 46 public IValueLookupParameter<IntValue> AccuraciesCountParameter { 50 47 get { return (IValueLookupParameter<IntValue>)Parameters["AccuraciesCount"]; } … … 70 67 Parameters.Add(new ValueLookupParameter<ItemDictionary<IGAssistNiche, ItemList<DoubleValue>>>("AverageAccuracies")); 71 68 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality")); 72 Parameters.Add(new ScopeTreeLookupParameter<IGAssistIndividual>("Individual"));73 69 Parameters.Add(new LookupParameter<IRandom>("Random")); 74 Parameters.Add(new ValueLookupParameter<IntValue>("AccuraciesCount" ));70 Parameters.Add(new ValueLookupParameter<IntValue>("AccuraciesCount", new IntValue(15))); 75 71 Parameters.Add(new ValueLookupParameter<IGAssistNicheEqualityComparer>("NicheComparer")); 76 Parameters.Add(new ValueLookupParameter<DoubleValue>("NicheStandardDeviation" ));72 Parameters.Add(new ValueLookupParameter<DoubleValue>("NicheStandardDeviation", new DoubleValue(0.005))); 77 73 } 78 74 public override IDeepCloneable Clone(Cloner cloner) { … … 82 78 public override IOperation Apply() { 83 79 if (NichingParameter.ActualValue == null) { 80 IList<IGAssistNiche> niches = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().ToList(); 84 81 NichingParameter.ActualValue = new BoolValue(true); 85 NichesParameter.ActualValue = new IntValue( PossibleDefaultClassesParameter.ActualValue.Count);86 AverageAccuraciesParameter.ActualValue = new ItemDictionary<IGAssistNiche, ItemList<DoubleValue>>(NicheComparerParameter.ActualValue );87 foreach (var niche in PossibleDefaultClassesParameter.ActualValue) {82 NichesParameter.ActualValue = new IntValue(niches.Count); 83 AverageAccuraciesParameter.ActualValue = new ItemDictionary<IGAssistNiche, ItemList<DoubleValue>>(NicheComparerParameter.ActualValue as IEqualityComparer<IGAssistNiche>); 84 foreach (var niche in GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches()) { 88 85 AverageAccuracies.Add(niche, new ItemList<DoubleValue>(AccuraciesCount)); 89 86 } 87 88 int i = 0; 89 foreach (var individual in IndividualParameter.ActualValue) { 90 individual.SetNiche(RandomParameter.ActualValue, niches[i]); 91 i++; 92 i %= niches.Count; 93 } 94 95 OperationCollection next = new OperationCollection(); 96 next.Add(EvaluateSubScopes()); 97 next.Add(base.Apply()); 98 return next; 90 99 } else { 91 100 var nicheFitness = new Dictionary<IGAssistNiche, double>(NicheComparerParameter.ActualValue); 92 foreach (var niche in PossibleDefaultClassesParameter.ActualValue) {101 foreach (var niche in GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches()) { 93 102 nicheFitness[niche] = 0.0; 94 103 while (AverageAccuracies[niche].Count >= AccuraciesCount) { … … 105 114 } 106 115 107 foreach (var niche in PossibleDefaultClassesParameter.ActualValue) {116 foreach (var niche in GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches()) { 108 117 AverageAccuracies[niche].Insert(0, new DoubleValue(nicheFitness[niche])); 109 118 } 110 119 111 var averages = new List<double>( PossibleDefaultClassesParameter.ActualValue.Count);120 var averages = new List<double>(GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().Count()); 112 121 if (AverageAccuracies.Values.First().Count >= AccuraciesCount) { 113 122 foreach (var averageAccuracy in AverageAccuracies.Values) { -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule/DefaultRuleOperator.cs
r9342 r9352 42 42 get { return (IValueLookupParameter<IGAssistNiche>)Parameters["DefaultClass"]; } 43 43 } 44 public ILookupParameter<ItemCollection<IGAssistNiche>> PossibleDefaultClassesParameter { 45 get { return (ILookupParameter<ItemCollection<IGAssistNiche>>)Parameters["PossibleDefaultClasses"]; } 44 public ILookupParameter<IGAssistNichesProblemData> GAssistNichesProblemDataParameter { 45 get { return (ILookupParameter<IGAssistNichesProblemData>)Parameters["GAssistNichesProblemData"]; } 46 } 47 public ILookupParameter<ItemArray<IGAssistIndividual>> IndividualParameter { 48 get { return (ILookupParameter<ItemArray<IGAssistIndividual>>)Parameters["Individual"]; } 49 } 50 public IValueLookupParameter<IOperator> EvaluatorParameter { 51 get { return (IValueLookupParameter<IOperator>)Parameters["Evaluator"]; } 46 52 } 47 53 #endregion … … 57 63 Parameters.Add(new ValueLookupParameter<IntValue>("Niches")); 58 64 Parameters.Add(new ValueLookupParameter<IGAssistNiche>("DefaultClass")); 59 Parameters.Add(new LookupParameter<ItemCollection<IGAssistNiche>>("PossibleDefaultClasses")); 65 Parameters.Add(new LookupParameter<IGAssistNichesProblemData>("GAssistNichesProblemData")); 66 Parameters.Add(new ScopeTreeLookupParameter<IGAssistIndividual>("Individual")); 67 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator")); 68 } 69 70 protected OperationCollection EvaluateSubScopes() { 71 IOperator evaluator = EvaluatorParameter.ActualValue; 72 OperationCollection evaluation = new OperationCollection(); 73 if (evaluator != null) { 74 foreach (var subScope in ExecutionContext.Scope.SubScopes) { 75 evaluation.Add(ExecutionContext.CreateOperation(evaluator, subScope)); 76 } 77 } 78 return evaluation; 60 79 } 61 80 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule/IDefaultRuleOperator.cs
r9342 r9352 26 26 public interface IDefaultRuleOperator : IOperator { 27 27 IValueLookupParameter<BoolValue> NichingParameter { get; } 28 ILookupParameter<IntValue> NichesParameter { get; } 29 IValueLookupParameter<Item> DefaultClassParameter { get; } 30 ILookupParameter<ItemCollection<IGAssistNiche>> PossibleDefaultClassesParameter { get; } 28 IValueLookupParameter<IntValue> NichesParameter { get; } 29 IValueLookupParameter<IGAssistNiche> DefaultClassParameter { get; } 30 ILookupParameter<IGAssistNichesProblemData> GAssistNichesProblemDataParameter { get; } 31 ILookupParameter<ItemArray<IGAssistIndividual>> IndividualParameter { get; } 32 IValueLookupParameter<IOperator> EvaluatorParameter { get; } 31 33 } 32 34 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule/MajorDefaultRule.cs
r9342 r9352 77 77 index = indices[0]; 78 78 } 79 DefaultClassParameter.ActualValue = PossibleDefaultClassesParameter.ActualValue.ElementAt(index); 79 IGAssistNiche niche = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().ElementAt(index); 80 DefaultClassParameter.ActualValue = niche; 81 82 foreach (var individual in IndividualParameter.ActualValue) { 83 individual.SetNiche(RandomParameter.ActualValue, niche); 84 } 85 86 OperationCollection next = new OperationCollection(); 87 next.Add(EvaluateSubScopes()); 88 next.Add(base.Apply()); 89 return next; 80 90 } 81 91 return base.Apply(); -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/DefaultRule/MinorDefaultRule.cs
r9342 r9352 77 77 index = indices[0]; 78 78 } 79 DefaultClassParameter.ActualValue = PossibleDefaultClassesParameter.ActualValue.ElementAt(index); 79 IGAssistNiche niche = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().ElementAt(index); 80 DefaultClassParameter.ActualValue = niche; 81 82 foreach (var individual in IndividualParameter.ActualValue) { 83 individual.SetNiche(RandomParameter.ActualValue, niche); 84 } 85 86 OperationCollection next = new OperationCollection(); 87 next.Add(EvaluateSubScopes()); 88 next.Add(base.Apply()); 89 return next; 80 90 } 81 91 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.