Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/14/13 15:23:17 (11 years ago)
Author:
sforsten
Message:

#1980:

  • added XCSSolution, XCSModel, XCSClassifier to represent the xcs classifier
  • XCSSolution also shows the current accuracy (training and test partition has to be added)
  • added XCSSolutionAnalyzer to create a XCSSolution during the run of the algorithm
  • added XCSModelView to show the xcs model
  • fixed a bug in XCSDeletionOperator (sometimes it deleted less classifiers than it should)
  • moved some parameter from ConditionActionClassificationProblem to ConditionActionClassificationProblemData
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs

    r9110 r9154  
    7676      get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; }
    7777    }
    78     //for test purposes
    79     public IFixedValueParameter<IntValue> LengthParameter {
    80       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    81     }
    82     public IFixedValueParameter<IntValue> ActionPartLengthParameter {
    83       get { return (IFixedValueParameter<IntValue>)Parameters["ActionPartLength"]; }
    84     }
    85     public IFixedValueParameter<IntMatrix> BoundsParameter {
    86       get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }
    87     }
    8878    #endregion
    8979
     
    120110    }
    121111    IParameter IConditionActionProblem.ActionExecuterParameter { get { return ActionExecuterParameter; } }
    122     public CombinedIntegerVectorClassifierFetcher ClassifierFetcher {
     112    public ClassifierFetcher ClassifierFetcher {
    123113      get { return ClassifierFetcherParameter.Value; }
    124114    }
    125     public ValueParameter<CombinedIntegerVectorClassifierFetcher> ClassifierFetcherParameter {
    126       get { return (ValueParameter<CombinedIntegerVectorClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
     115    public ValueParameter<ClassifierFetcher> ClassifierFetcherParameter {
     116      get { return (ValueParameter<ClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
    127117    }
    128118    IClassifierFetcher IConditionActionProblem.ClassifierFetcher { get { return ClassifierFetcher; } }
     
    150140    IParameter IConditionActionProblem.CoveringSolutionCreatorParameter {
    151141      get { return CoveringSolutionCreatorParameter; }
     142    }
     143    private XCSSolutionAnalyzer XCSSolutionAnalyzer {
     144      get { return Operators.OfType<XCSSolutionAnalyzer>().FirstOrDefault(); }
    152145    }
    153146    #endregion
     
    170163    public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator, ICoveringSolutionCreator coveringSolutionCreator)
    171164      : base(evaluator, solutionCreator) {
    172       Parameters.Add(new FixedValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(7)));
    173       Parameters.Add(new FixedValueParameter<IntValue>("ActionPartLength", "The operator to create a solution.", new IntValue(1)));
    174       int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };
    175       Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "The operator to create a solution.", new IntMatrix(elements)));
    176165      Parameters.Add(new ValueParameter<ConditionActionClassificationProblemData>("ProblemData", "", problemData));
    177166      Parameters.Add(new FixedValueParameter<DoubleValue>("PositiveReward", "", new DoubleValue(1000)));
     
    182171
    183172      Parameters.Add(new ValueParameter<IActionExecuter>(ActionExecuterParameterName, "", new ActionExecuter()));
    184       Parameters.Add(new ValueParameter<CombinedIntegerVectorClassifierFetcher>(ClassifierFetcherParameterName, "", new CombinedIntegerVectorClassifierFetcher()));
     173      Parameters.Add(new ValueParameter<ClassifierFetcher>(ClassifierFetcherParameterName, "", new ClassifierFetcher()));
    185174      Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions"));
    186175      Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass"));
     
    196185      Evaluator.InitialPredictionParameter.ActualName = "InitialPrediction";
    197186
    198       SolutionCreator.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    199       SolutionCreator.LengthParameter.ActualName = LengthParameter.Name;
    200       SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
     187      SolutionCreator.ActionPartLengthParameter.ActualName = ProblemData.ActionLengthParameter.Name;
     188      SolutionCreator.LengthParameter.ActualName = ProblemData.LengthParameter.Name;
     189      SolutionCreator.BoundsParameter.ActualName = ProblemData.BoundsParameter.Name;
    201190
    202191      coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name;
     
    204193      coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector";
    205194
    206       ClassifierFetcher.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    207       ClassifierFetcher.BoundsParameter.ActualName = BoundsParameter.Name;
    208195      ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    209196
     
    217204      ThetaMinimalNumberOfActions.Value = PossibleActions.Count;
    218205
    219       BoundsParameter.ValueChanged += new System.EventHandler(BoundsParameter_ValueChanged);
    220       LengthParameter.ValueChanged += new System.EventHandler(LengthParameter_ValueChanged);
    221       ActionPartLengthParameter.ValueChanged += new System.EventHandler(ActionPartLengthParameter_ValueChanged);
    222     }
    223 
    224     #region event handler
    225     private void ActionPartLengthParameter_ValueChanged(object sender, System.EventArgs e) {
     206      InitializeOperators();
     207
     208      problemData.Changed += new System.EventHandler(problemData_Changed);
     209    }
     210
     211    private void problemData_Changed(object sender, System.EventArgs e) {
    226212      SetPossibleActions();
    227213    }
    228     private void LengthParameter_ValueChanged(object sender, System.EventArgs e) {
    229       SetPossibleActions();
    230     }
    231     private void BoundsParameter_ValueChanged(object sender, System.EventArgs e) {
    232       SetPossibleActions();
    233     }
    234     #endregion
     214
     215    private void InitializeOperators() {
     216      Operators.Add(new XCSSolutionAnalyzer());
     217
     218      ParameterizeAnalyzers();
     219    }
     220
     221    private void ParameterizeAnalyzers() {
     222      if (XCSSolutionAnalyzer != null) {
     223        XCSSolutionAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName;
     224        XCSSolutionAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName;
     225        XCSSolutionAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName;
     226        XCSSolutionAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName;
     227        XCSSolutionAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName;
     228        XCSSolutionAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName;
     229        XCSSolutionAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName;
     230        XCSSolutionAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName;
     231        XCSSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     232        XCSSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     233      }
     234    }
    235235
    236236    private void SetPossibleActions() {
    237237      //get bounds of action
    238       IntMatrix actionBounds = GetElementsOfBoundsForAction(BoundsParameter.Value, LengthParameter.Value.Value, ActionPartLengthParameter.Value.Value);
    239       int actionLength = ActionPartLengthParameter.Value.Value;
    240       int start = LengthParameter.Value.Value - actionLength;
     238      IntMatrix actionBounds = GetElementsOfBoundsForAction(ProblemData.Bounds, ProblemData.Length.Value, ProblemData.ActionLength.Value);
     239      int actionLength = ProblemData.ActionLength.Value;
     240      int start = ProblemData.Length.Value - actionLength;
    241241      int[] elements = new int[actionLength];
    242242      int[] curPos = new int[actionLength];
Note: See TracChangeset for help on using the changeset viewer.