Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Ensemble/ConditionActionEnsembleProblemData.cs @ 12075

Last change on this file since 12075 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.2 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.Encodings.ConditionActionEncoding {
33  [StorableClass]
34  [Item("ConditionActionEnsembleProblemData", "")]
35  public class ConditionActionEnsembleProblemData : ParameterizedNamedItem, IConditionActionEnsembleProblemData {
36    public IValueParameter<IConditionActionProblemData> ProblemDataParameter {
37      get { return (IValueParameter<IConditionActionProblemData>)Parameters["ProblemData"]; }
38    }
39
40    public bool IsTrainingSample(int index) {
41      return index >= 0 && index < Dataset.Rows &&
42             TrainingPartition.Start <= index && index < TrainingPartition.End;
43    }
44
45    public bool IsTestSample(int index) {
46      return index >= 0 && index < Dataset.Rows &&
47             TestPartition.Start <= index && index < TestPartition.End;
48    }
49    public IEnumerable<int> TrainingIndices {
50      get {
51        return Enumerable.Range(TrainingPartition.Start, Math.Max(0, TrainingPartition.End - TrainingPartition.Start))
52                         .Where(IsTrainingSample);
53      }
54    }
55    public IEnumerable<int> TestIndices {
56      get {
57        return Enumerable.Range(TestPartition.Start, Math.Max(0, TestPartition.End - TestPartition.Start))
58           .Where(IsTestSample);
59      }
60    }
61
62    [Storable]
63    private IConditionActionProblemData problemData;
64
65    [StorableConstructor]
66    protected ConditionActionEnsembleProblemData(bool deserializing) : base(deserializing) { }
67    protected ConditionActionEnsembleProblemData(ConditionActionEnsembleProblemData original, Cloner cloner)
68      : base(original, cloner) {
69      problemData = (IConditionActionProblemData)original.problemData.Clone();
70    }
71
72    public ConditionActionEnsembleProblemData()
73      : base() {
74      Parameters.Add(new ValueParameter<IConditionActionProblemData>("ProblemData", ""));
75    }
76    public ConditionActionEnsembleProblemData(IConditionActionProblemData problemData)
77      : base() {
78      this.problemData = problemData;
79      Parameters.Add(new ValueParameter<IConditionActionProblemData>("ProblemData", "", problemData));
80    }
81    public override IDeepCloneable Clone(Cloner cloner) {
82      return new ConditionActionEnsembleProblemData(this, cloner);
83    }
84
85    public IConditionActionProblemData GetConditionActionProblemData() {
86      return (IConditionActionProblemData)problemData.Clone();
87    }
88
89    #region IConditionActionProblemData Members
90    public ICheckedItemList<StringValue> ConditionVariables {
91      get { return problemData.ConditionVariables; }
92    }
93    public IEnumerable<string> AllowedConditionVariables {
94      get { return problemData.AllowedConditionVariables; }
95    }
96    public IInput FetchInput(int row) {
97      return problemData.FetchInput(row);
98    }
99    public IEnumerable<IInput> FetchInput(IEnumerable<int> rows) {
100      return problemData.FetchInput(rows);
101    }
102    public IEnumerable<IAction> FetchAction(IEnumerable<int> rows) {
103      return problemData.FetchAction(rows);
104    }
105    public IAction FetchAction(int rows) {
106      return problemData.FetchAction(rows);
107    }
108    public ICheckedItemList<StringValue> ActionVariables {
109      get { return problemData.ActionVariables; }
110    }
111    public IEnumerable<string> AllowedActionVariables {
112      get { return problemData.AllowedActionVariables; }
113    }
114    public IClassifierComparer ClassifierComparer {
115      get { return problemData.ClassifierComparer; }
116    }
117    #endregion
118
119    #region IDataAnalysisProblemData Members
120    public bool IsEmpty {
121      get { return problemData.IsEmpty; }
122    }
123    public Dataset Dataset {
124      get { return problemData.Dataset; }
125    }
126    public ICheckedItemList<StringValue> InputVariables {
127      get { return problemData.InputVariables; }
128    }
129    public IEnumerable<string> AllowedInputVariables {
130      get { return problemData.AllowedInputVariables; }
131    }
132    public IntRange TrainingPartition {
133      get { return problemData.TrainingPartition; }
134    }
135    public IntRange TestPartition {
136      get { return problemData.TestPartition; }
137    }
138    public event System.EventHandler Changed;
139    #endregion
140  }
141}
Note: See TracBrowser for help on using the repository browser.