Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/10/13 15:15:13 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added DecisionListView
  • added event handlers in *ProblemData
  • renamed project Problems.XCS.Views to Problems.lCS.Views and Problems.Instances.ConditionActionClassification to Problems.Instances.LCS
  • integrated niching in GAssist and added NichingTournamentSelector
  • minor code improvements and property changes
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  
        11Plugin.cs
         2obj
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblem.cs

    r9342 r9352  
    2727using HeuristicLab.Encodings.DecisionList.Interfaces;
    2828using HeuristicLab.Optimization;
     29using HeuristicLab.Optimization.Operators.LCS;
     30using HeuristicLab.Optimization.Operators.LCS.DefaultRule;
    2931using HeuristicLab.Parameters;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3133using HeuristicLab.PluginInfrastructure;
    3234using HeuristicLab.Problems.DataAnalysis;
     35using HeuristicLab.Problems.Instances;
    3336
    3437namespace HeuristicLab.Problems.DecisionListClassification {
     
    3639  [StorableClass]
    3740  [Creatable("Problems")]
    38   public class DecisionListClassificationProblem : HeuristicOptimizationProblem<IDecisionListEvaluator, IDecisionListCreator>, IDecisionListClassificationProblem {
     41  public class DecisionListClassificationProblem : HeuristicOptimizationProblem<IDecisionListEvaluator, IDecisionListCreator>,
     42                                                   IDecisionListClassificationProblem, IGAssistProblem,
     43                                                   IProblemInstanceConsumer<DecisionListClassificationProblemData> {
    3944
    4045    #region parameter properties
     
    105110      : base(decisionlistEvaluator, decisionListCreator) {
    106111      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)));
    108113      Parameters.Add(new FixedValueParameter<DoubleValue>("BestKnownQuality", "", new DoubleValue(0.5)));
    109114      Parameters.Add(new FixedValueParameter<IntValue>("SizePenaltyMinRules", "", new IntValue(4)));
     
    116121      // do differently
    117122      ((MDLEvaluator)Evaluator).MDLCalculatorParameter.Value = new MDLCalculator(ActivationIterationParameter.Value.Value, InitialTheoryLengthRatioParameter.Value.Value, WeightRelaxFactorParameter.Value.Value);
    118       // do differently
    119       decisionListCreator.DefaultActionParameter.Value = problemData.FetchAction(0);
    120123
    121124      InitializeOperators();
     
    123126
    124127    private void InitializeOperators() {
     128      foreach (var op in ApplicationManager.Manager.GetInstances<IDefaultRuleOperator>())
     129        Operators.Add(op);
    125130      foreach (var op in ApplicationManager.Manager.GetInstances<IDecisionListCrossover>())
    126131        Operators.Add(op);
     
    129134
    130135      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);
    131144    }
    132145
    133146    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      }
    134158      foreach (IDecisionListCrossover op in Operators.OfType<IDecisionListCrossover>()) {
    135159        op.ParentsParameter.ActualName = SolutionCreator.DecisionListParameter.ActualName;
     
    148172      return new DecisionListClassificationProblem(this, cloner);
    149173    }
     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    }
    150188  }
    151189}
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs

    r9334 r9352  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Collections;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
    2829using HeuristicLab.Encodings.DecisionList;
     30using HeuristicLab.Optimization.Operators.LCS;
    2931using HeuristicLab.Parameters;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    6264      get { return (IFixedValueParameter<IntRange>)Parameters["TestPartition"]; }
    6365    }
    64     public IFixedValueParameter<Rule> SampleRuleParameter {
    65       get { return (IFixedValueParameter<Rule>)Parameters["SampleRule"]; }
     66    public IValueParameter<Rule> SampleRuleParameter {
     67      get { return (IValueParameter<Rule>)Parameters["SampleRule"]; }
    6668    }
    6769    public IFixedValueParameter<IntValue> MaxIntervalsParameter {
     
    118120    #endregion
    119121
     122    [StorableHook(HookType.AfterDeserialization)]
     123    private void AfterDeserialization() {
     124      RegisterParameterEvents();
     125    }
    120126    [StorableConstructor]
    121127    protected DecisionListClassificationProblemData(bool deserializing) : base(deserializing) { }
    122128    protected DecisionListClassificationProblemData(DecisionListClassificationProblemData original, Cloner cloner)
    123129      : base(original, cloner) {
     130      RegisterParameterEvents();
    124131    }
    125132    public DecisionListClassificationProblemData(Dataset dataset, IEnumerable<string> allowedConditionVariables, string targetVariable) {
     
    150157      Parameters.Add(new FixedValueParameter<IntRange>("TestPartition", "", new IntRange(testPartitionStart, testPartitionEnd)));
    151158      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)));
    153160
    154161      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     162
     163      RegisterParameterEvents();
    155164    }
    156165    public override IDeepCloneable Clone(Cloner cloner) {
     
    240249    }
    241250
     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
    242265    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
    243289  }
    244290}
  • branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/HeuristicLab.Problems.DecisionListClassification-3.3.csproj

    r9342 r9352  
    109109      <Private>False</Private>
    110110    </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>
    111115    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
    112116      <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
Note: See TracChangeset for help on using the changeset viewer.