Changeset 9352 for branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification
- Timestamp:
- 04/10/13 15:15:13 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3
- Property svn:ignore
-
old new 1 1 Plugin.cs 2 obj
-
- Property svn:ignore
-
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblem.cs
r9342 r9352 27 27 using HeuristicLab.Encodings.DecisionList.Interfaces; 28 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Optimization.Operators.LCS; 30 using HeuristicLab.Optimization.Operators.LCS.DefaultRule; 29 31 using HeuristicLab.Parameters; 30 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 33 using HeuristicLab.PluginInfrastructure; 32 34 using HeuristicLab.Problems.DataAnalysis; 35 using HeuristicLab.Problems.Instances; 33 36 34 37 namespace HeuristicLab.Problems.DecisionListClassification { … … 36 39 [StorableClass] 37 40 [Creatable("Problems")] 38 public class DecisionListClassificationProblem : HeuristicOptimizationProblem<IDecisionListEvaluator, IDecisionListCreator>, IDecisionListClassificationProblem { 41 public class DecisionListClassificationProblem : HeuristicOptimizationProblem<IDecisionListEvaluator, IDecisionListCreator>, 42 IDecisionListClassificationProblem, IGAssistProblem, 43 IProblemInstanceConsumer<DecisionListClassificationProblemData> { 39 44 40 45 #region parameter properties … … 105 110 : base(decisionlistEvaluator, decisionListCreator) { 106 111 Parameters.Add(new ValueParameter<IDecisionListClassificationProblemData>("ProblemData", "", problemData)); 107 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "", new BoolValue( true)));112 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "", new BoolValue(false))); 108 113 Parameters.Add(new FixedValueParameter<DoubleValue>("BestKnownQuality", "", new DoubleValue(0.5))); 109 114 Parameters.Add(new FixedValueParameter<IntValue>("SizePenaltyMinRules", "", new IntValue(4))); … … 116 121 // do differently 117 122 ((MDLEvaluator)Evaluator).MDLCalculatorParameter.Value = new MDLCalculator(ActivationIterationParameter.Value.Value, InitialTheoryLengthRatioParameter.Value.Value, WeightRelaxFactorParameter.Value.Value); 118 // do differently119 decisionListCreator.DefaultActionParameter.Value = problemData.FetchAction(0);120 123 121 124 InitializeOperators(); … … 123 126 124 127 private void InitializeOperators() { 128 foreach (var op in ApplicationManager.Manager.GetInstances<IDefaultRuleOperator>()) 129 Operators.Add(op); 125 130 foreach (var op in ApplicationManager.Manager.GetInstances<IDecisionListCrossover>()) 126 131 Operators.Add(op); … … 129 134 130 135 ParameterizeOperators(); 136 137 BestTrainingDecisionListAnalyzer analyzer = new BestTrainingDecisionListAnalyzer(); 138 analyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 139 analyzer.IndividualParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName; 140 analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 141 analyzer.ResultsParameter.ActualName = "Results"; 142 analyzer.MaximizationParameter.ActualName = MaximizationParameter.Name; 143 Operators.Add(analyzer); 131 144 } 132 145 133 146 private void ParameterizeOperators() { 147 var autoDefaultRule = Operators.Where(x => x is AutoDefaultRule).Select(x => x as AutoDefaultRule).First(); 148 autoDefaultRule.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 149 autoDefaultRule.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name; 150 autoDefaultRule.NicheComparerParameter.Value = new DecisionListNicheComparer(); 151 foreach (IDefaultRuleOperator op in Operators.OfType<IDefaultRuleOperator>()) { 152 op.IndividualParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName; 153 op.EvaluatorParameter.ActualName = EvaluatorParameter.Name; 154 op.GAssistNichesProblemDataParameter.ActualName = ProblemDataParameter.Name; 155 op.GAssistNichesProblemDataParameter.Hidden = true; 156 op.NichingParameter.ActualName = "Niching"; 157 } 134 158 foreach (IDecisionListCrossover op in Operators.OfType<IDecisionListCrossover>()) { 135 159 op.ParentsParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName; … … 148 172 return new DecisionListClassificationProblem(this, cloner); 149 173 } 174 175 IParameter IGAssistProblem.ProblemDataParameter { 176 get { return ProblemDataParameter; } 177 } 178 179 public string NichingParameterName { 180 get { return "Niching"; } 181 } 182 183 public void Load(DecisionListClassificationProblemData data) { 184 Name = data.Name; 185 Description = data.Description; 186 ProblemData = data; 187 } 150 188 } 151 189 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs
r9334 r9352 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Encodings.DecisionList; 30 using HeuristicLab.Optimization.Operators.LCS; 29 31 using HeuristicLab.Parameters; 30 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 62 64 get { return (IFixedValueParameter<IntRange>)Parameters["TestPartition"]; } 63 65 } 64 public I FixedValueParameter<Rule> SampleRuleParameter {65 get { return (I FixedValueParameter<Rule>)Parameters["SampleRule"]; }66 public IValueParameter<Rule> SampleRuleParameter { 67 get { return (IValueParameter<Rule>)Parameters["SampleRule"]; } 66 68 } 67 69 public IFixedValueParameter<IntValue> MaxIntervalsParameter { … … 118 120 #endregion 119 121 122 [StorableHook(HookType.AfterDeserialization)] 123 private void AfterDeserialization() { 124 RegisterParameterEvents(); 125 } 120 126 [StorableConstructor] 121 127 protected DecisionListClassificationProblemData(bool deserializing) : base(deserializing) { } 122 128 protected DecisionListClassificationProblemData(DecisionListClassificationProblemData original, Cloner cloner) 123 129 : base(original, cloner) { 130 RegisterParameterEvents(); 124 131 } 125 132 public DecisionListClassificationProblemData(Dataset dataset, IEnumerable<string> allowedConditionVariables, string targetVariable) { … … 150 157 Parameters.Add(new FixedValueParameter<IntRange>("TestPartition", "", new IntRange(testPartitionStart, testPartitionEnd))); 151 158 Parameters.Add(new FixedValueParameter<IntValue>("MaxIntervals", "", new IntValue(5))); 152 Parameters.Add(new FixedValueParameter<Rule>("SampleRule", "", CreateSampleRule(dataset, conditionVariables.CheckedItems.Select(x => x.Value.Value), target.Value)));159 Parameters.Add(new ValueParameter<Rule>("SampleRule", "", CreateSampleRule(dataset, conditionVariables.CheckedItems.Select(x => x.Value.Value), target.Value))); 153 160 154 161 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 162 163 RegisterParameterEvents(); 155 164 } 156 165 public override IDeepCloneable Clone(Cloner cloner) { … … 240 249 } 241 250 251 protected IList<IGAssistNiche> possibleNiches; 252 public IEnumerable<IGAssistNiche> GetPossibleNiches() { 253 if (possibleNiches == null) { 254 possibleNiches = new List<IGAssistNiche>(); 255 for (int i = 0; i < Dataset.Rows; i++) { 256 var action = FetchAction(i); 257 if (!possibleNiches.Any(x => x.SameNiche(action))) { 258 possibleNiches.Add(action); 259 } 260 } 261 } 262 return possibleNiches; 263 } 264 242 265 public event EventHandler Changed; 266 267 #region events 268 private void RegisterParameterEvents() { 269 ConditionVariablesParameter.ValueChanged += new EventHandler(VariablesChanged); 270 ConditionVariablesParameter.Value.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<StringValue>>(VariablesChanged); 271 TargetVariableParameter.ValueChanged += new EventHandler(VariablesChanged); 272 } 273 private void DeregisterParameterEvents() { 274 TargetVariableParameter.ValueChanged += new EventHandler(VariablesChanged); 275 ConditionVariablesParameter.Value.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<StringValue>>(VariablesChanged); 276 ConditionVariablesParameter.ValueChanged += new EventHandler(VariablesChanged); 277 } 278 private void Value_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> e) { 279 VariablesChanged(); 280 } 281 private void VariablesChanged(object sender, EventArgs e) { 282 VariablesChanged(); 283 } 284 285 private void VariablesChanged() { 286 SampleRuleParameter.Value = CreateSampleRule(Dataset, AllowedConditionVariables, TargetVariable.Value); 287 } 288 #endregion 243 289 } 244 290 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/HeuristicLab.Problems.DecisionListClassification-3.3.csproj
r9342 r9352 109 109 <Private>False</Private> 110 110 </ProjectReference> 111 <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators.LCS\3.3\HeuristicLab.Optimization.Operators.LCS-3.3.csproj"> 112 <Project>{f2c6d3b0-bd4f-4747-b13e-b18e53a2a09d}</Project> 113 <Name>HeuristicLab.Optimization.Operators.LCS-3.3</Name> 114 </ProjectReference> 111 115 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj"> 112 116 <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
Note: See TracChangeset
for help on using the changeset viewer.