BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
registry.h
Go to the documentation of this file.
1 /* registry.h
2  *
3  * Copyright (C) 2009 Marcel Schumann
4  *
5  * This file is part of QuEasy -- A Toolbox for Automated QSAR Model
6  * Construction and Validation.
7  * QuEasy 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 (at
10  * your option) any later version.
11  *
12  * QuEasy is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef QSAR_REGISTRY
22 #define QSAR_REGISTRY
23 
24 #ifndef MODEL_FACTORY_H
25 #include <BALL/QSAR/modelFactory.h>
26 #endif
27 
28 #include <map>
29 
30 #ifdef BALL_HAS_LIBSVM
31 # include <BALL/QSAR/libsvmModel.h>
32 #endif
33 
34 namespace BALL
35 {
36  namespace QSAR
37  {
38  class QSARData;
39 
40  typedef Model* (*CreateMethod) (const QSARData& q);
41  typedef Model* (*CreateKernel1) (const QSARData& q, int k, double p1, double p2);
42  typedef Model* (*CreateKernel2) (const QSARData& q, String s1, String s2);
43 
44  class Registry;
45 
47  {
48  public:
49 
54  RegistryEntry(bool k, bool r, String n, String ab, CreateMethod c0);
55 
60  RegistryEntry(bool k, bool r, String n, String ab, CreateKernel1 c1, CreateKernel2 c2);
61 
62  RegistryEntry(const RegistryEntry& entry);
63 
64  ~RegistryEntry();
65 
66  const std::map<uint,String>* getStatistics();
67  String getStatName(int s);
68 
69  bool kernel;
70  bool regression; // regression or classification?!
71  bool latent_variables; // is this a latent variable model?!
72  std::multiset<int> optimizableParameters;
73  //bool optimizable;
74  String name; // name of the Model
79  vector<String> parameterNames;
80  vector<double> parameterDefaults;
81  Registry* getRegistry();
82 
83  private:
85 
86  friend class Registry;
87  };
88 
89 
90  typedef std::map<int,RegistryEntry>::iterator RegistryEntryIterator;
91 
93  {
94  public:
95  Registry();
96 
97  ~Registry();
98 
101 
104 
107 
110 
113 
116 
119 
122 
125 
131 
132  void addEntry(RegistryEntry entry, int uniqueID);
133 
135  RegistryEntry* getEntry(String model_name);
136 
138  RegistryEntry* getEntry(int ID);
139 
141  int getModelNo(String model_name);
142 
143  String getClassificationStatisticName(uint no);
144  String getRegressionStatisticName(uint no);
145  String getFeatureSelectionName(uint no);
146  String getValidationName(uint no);
147  const std::map<uint,String>* getClassificationStatistics();
148  const std::map<uint,String>* getRegressionStatistics();
149 
151  RegistryEntryIterator beginEntry();
152 
154  RegistryEntryIterator endEntry();
155 
156 
157  private:
158  std::map<int,RegistryEntry> registered_models;
159 
161  std::map<String,int> model_map;
162 
163  std::map<uint,String> classification_statistics;
164  std::map<uint,String> regression_statistics;
165  std::map<uint,String> feature_selection_names;
166  std::map<uint,String> validation_names;
167 
168  friend class RegistryEntry;
169  };
170 
171 
172  }
173 }
174 
175 #endif // QSAR_REGISTRY