Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/Ensemble/GAssistEnsembleProblemData.cs @ 17578

Last change on this file since 17578 was 9411, checked in by sforsten, 12 years ago

#1980:

  • added multiple discretizer to GAssist
  • created ensembles for LCS problems and edited CrossValidation to use them
File size: 5.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Problems.DataAnalysis;
31
32namespace HeuristicLab.Optimization.Operators.LCS {
33  [StorableClass]
34  [Item("GAssistEnsembleProblemData", "")]
35  public class GAssistEnsembleProblemData : ParameterizedNamedItem, IGAssistEnsembleProblemData {
36
37    public IValueParameter<IGAssistProblemData> ProblemDataParameter {
38      get { return (IValueParameter<IGAssistProblemData>)Parameters["ProblemData"]; }
39    }
40
41    public bool IsTrainingSample(int index) {
42      return index >= 0 && index < Dataset.Rows &&
43             TrainingPartition.Start <= index && index < TrainingPartition.End;
44    }
45
46    public bool IsTestSample(int index) {
47      return index >= 0 && index < Dataset.Rows &&
48             TestPartition.Start <= index && index < TestPartition.End;
49    }
50    public IEnumerable<int> TrainingIndices {
51      get {
52        return Enumerable.Range(TrainingPartition.Start, Math.Max(0, TrainingPartition.End - TrainingPartition.Start))
53                         .Where(IsTrainingSample);
54      }
55    }
56    public IEnumerable<int> TestIndices {
57      get {
58        return Enumerable.Range(TestPartition.Start, Math.Max(0, TestPartition.End - TestPartition.Start))
59           .Where(IsTestSample);
60      }
61    }
62
63    [Storable]
64    private IGAssistProblemData problemData;
65
66    [StorableConstructor]
67    protected GAssistEnsembleProblemData(bool deserializing) : base(deserializing) { }
68    protected GAssistEnsembleProblemData(GAssistEnsembleProblemData original, Cloner cloner)
69      : base(original, cloner) {
70      problemData = (IGAssistProblemData)original.problemData.Clone();
71    }
72
73    public GAssistEnsembleProblemData()
74      : base() {
75      Parameters.Add(new ValueParameter<IGAssistProblemData>("ProblemData", ""));
76    }
77    public GAssistEnsembleProblemData(IGAssistProblemData problemData)
78      : base() {
79      this.problemData = problemData;
80      Parameters.Add(new ValueParameter<IGAssistProblemData>("ProblemData", "", problemData));
81    }
82    public override IDeepCloneable Clone(Cloner cloner) {
83      return new GAssistEnsembleProblemData(this, cloner);
84    }
85
86    public IGAssistProblemData GetGAssistProblemData() {
87      return (IGAssistProblemData)problemData.Clone();
88    }
89
90    #region IGAssistProblemData Members
91    public ICheckedItemList<StringValue> ConditionVariables {
92      get { return problemData.ConditionVariables; }
93    }
94    public StringValue TargetVariable {
95      get { return problemData.TargetVariable; }
96    }
97    public IEnumerable<string> AllowedConditionVariables {
98      get { return problemData.AllowedConditionVariables; }
99    }
100    public int Classes {
101      get { return problemData.Classes; }
102    }
103    public IGAssistInput FetchInput(int row) {
104      return problemData.FetchInput(row);
105    }
106    public IEnumerable<IGAssistInput> FetchInput(IEnumerable<int> rows) {
107      return problemData.FetchInput(rows);
108    }
109    public IEnumerable<IGAssistNiche> FetchAction(IEnumerable<int> rows) {
110      return problemData.FetchAction(rows);
111    }
112    public IGAssistNiche FetchAction(int rows) {
113      return problemData.FetchAction(rows);
114    }
115    public IEnumerable<IGAssistNiche> GetPossibleNiches() {
116      return problemData.GetPossibleNiches();
117    }
118    #endregion
119
120    #region IDataAnalysisProblemData Members
121    public bool IsEmpty {
122      get { return problemData.IsEmpty; }
123    }
124    public Dataset Dataset {
125      get { return problemData.Dataset; }
126    }
127    public ICheckedItemList<StringValue> InputVariables {
128      get { return problemData.InputVariables; }
129    }
130    public IEnumerable<string> AllowedInputVariables {
131      get { return problemData.AllowedInputVariables; }
132    }
133    public IntRange TrainingPartition {
134      get { return problemData.TrainingPartition; }
135    }
136    public IntRange TestPartition {
137      get { return problemData.TestPartition; }
138    }
139    public event System.EventHandler Changed;
140    #endregion
141  }
142}
Note: See TracBrowser for help on using the repository browser.