mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
InputException.h
1 /***************************************************************************
2  SRC/mixmod/Utilities/exceptions/InputException.h description
3  copyright : (C) MIXMOD Team - 2001-2016
4  email : contact@mixmod.org
5  ***************************************************************************/
6 
7 /***************************************************************************
8  This file is part of MIXMOD
9 
10  MIXMOD is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MIXMOD is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with MIXMOD. If not, see <http://www.gnu.org/licenses/>.
22 
23  All informations available on : http://www.mixmod.org
24 ***************************************************************************/
30 #ifndef XEM_INPUTEXCEPTION_H
31 #define XEM_INPUTEXCEPTION_H
32 
33 #include <string>
34 #include "mixmod/Utilities/exceptions/Exception.h"
35 
36 namespace XEM {
37 
38 class InputException : public Exception {
39 
40 public:
41 
42  Exception * clone() throw ();
43  InputException(std::string, int, InputError) throw ();
44  InputException(InputError) throw ();
45  InputException(const InputException & inputException);
46  virtual const char* what() const throw ();
47  virtual bool operator==(const Exception&) const throw ();
48  virtual void run(std::ostream & flux = std::cout) const throw ();
49 
50  virtual ~InputException() throw () {
51  }
52 
53  static std::map<InputError, const char*> create_map()
54  {
55  std::map<InputError, const char*> m;
56 
57  m.insert(std::make_pair(noError, "No error"));
58  m.insert(std::make_pair(nbLinesTooLarge, "Number of lines too large"));
59  m.insert(std::make_pair(nbLinesTooSmall, "Number of lines too small"));
60  m.insert(std::make_pair(pbDimensionTooLarge, "Dimension size too large"));
61  m.insert(std::make_pair(pbDimensionTooSmall, "Dimension size too small"));
62  m.insert(std::make_pair(nbCriterionTooLarge, "Number of criterion too large"));
63  m.insert(std::make_pair(nbCriterionTooSmall, "Number of criterion too small"));
64  m.insert(std::make_pair(wrongCriterionName, "Wrong criterion name/type"));
65  m.insert(std::make_pair(nbNbClusterTooLarge, "List of number of clusters too large"));
66  m.insert(std::make_pair(nbNbClusterTooSmall, "List of number of clusters too small"));
67  m.insert(std::make_pair(nbModelTypeTooLarge, "Number of models too large"));
68  m.insert(std::make_pair(nbModelTypeTooSmall, "Number of models too small"));
69  m.insert(std::make_pair(wrongModelType, "Wrong model name/type"));
70  m.insert(std::make_pair(wrongCVinitType, "Wrong CVinitType"));
71  m.insert(std::make_pair(wrongDCVinitType, "Wrong DCVinitType"));
72  m.insert(std::make_pair(nbStrategyTypeTooLarge, "Number of strategies too large"));
73  m.insert(std::make_pair(nbStrategyTypeTooSmall, "Number of strategies too small"));
74  m.insert(std::make_pair(wrongStrategyInitName, "Wrong strategy initialization name"));
75  m.insert(std::make_pair(badNbParameterInInit, "Bad parameter number in Init"));
76  m.insert(std::make_pair(badNbPartitionInInit, "Bad partition number in Init"));
77  m.insert(std::make_pair(errorInitParameter, "Error with USER initialization"));
78  m.insert(std::make_pair(nbAlgoTooLarge, "Number of algorithms too large"));
79  m.insert(std::make_pair(nbAlgoTooSmall, "Number of algorithms too small"));
80  m.insert(std::make_pair(wrongAlgoType, "Wrong algorithm type"));
81  m.insert(std::make_pair(nbIterationTooLarge, "Number of iterations too large"));
82  m.insert(std::make_pair(nbIterationTooSmall, "Number of iterations too small"));
83  m.insert(std::make_pair(epsilonTooSmall, "Value of epsilon too small"));
84  m.insert(std::make_pair(epsilonTooLarge, "Value of epsilon too large"));
85  m.insert(std::make_pair(wrongDataFileName, "Wrong data file name"));
86  m.insert(std::make_pair(wrongLabelFileName, "Wrong label file name"));
87  m.insert(std::make_pair(wrongWeightFileName, "Wrong weight file name"));
88  m.insert(std::make_pair(wrongParamFileName, "Wrong parameter file name"));
89  m.insert(std::make_pair(wrongPartitionFileName, "Wrong label file name"));
90  m.insert(std::make_pair(wrongAlgoStopName, "Wrong stopping rules for algorithm"));
91  m.insert(std::make_pair(wrongOutputType, "Wrong output mode type"));
92  m.insert(std::make_pair(wrongInputFileName, "Wrong input file name"));
93  m.insert(std::make_pair(wrongXEMNbParam, "Wrong number of paramaters for Mixmod call"));
94  m.insert(std::make_pair(errorNbLines, "Bad writing \"NbLines\" key word"));
95  m.insert(std::make_pair(errorPbDimension, "Bad writing \"PbDimension\" key word"));
96  m.insert(std::make_pair(errorNbCriterion, "Bad writing \"NbCriterion\" key word"));
97  m.insert(std::make_pair(errorListCriterion, "Bad writing \"ListCriterion\" key word"));
98  m.insert(std::make_pair(errorNbNbCluster, "Bad writing \"NbNbCluster\" key word"));
99  m.insert(std::make_pair(errorListNbCluster, "Bad writing \"ListNbCluster\" key word"));
100  m.insert(std::make_pair(errorNbModel, "Bad writing \"NbModel\" key word"));
101  m.insert(std::make_pair(errorListModel, "Bad writing \"ListModel\" key word"));
102  m.insert(std::make_pair(errorNbStrategy, "Bad writing \"NbStrategy\" key word"));
103  m.insert(std::make_pair(errorInitType, "Bad writing \"InitType\" key word"));
104  m.insert(std::make_pair(errorInitFile, "Bad writing \"InitFile\" key word"));
105  m.insert(std::make_pair(errorNbAlgo, "Bad writing \"NbAlgorithm\" key word"));
106  m.insert(std::make_pair(errorAlgo, "Bad writing \"Algorithm\" key word"));
107  m.insert(std::make_pair(errorStopRule, "Bad writing \"StopRule\" key word"));
108  m.insert(std::make_pair(errorStopRuleValue, "Bad writing \"StopRuleValue\" key word"));
109  m.insert(std::make_pair(errorDataFile, "Bad writing \"DataFile\" key word"));
110  m.insert(std::make_pair(nbAlgoTypeTooSmall, "number of algoType too small"));
111  m.insert(std::make_pair(badStrategyInitName, "strategyInitName incompatible with algoType"));
112  m.insert(std::make_pair(errorOpenFile, "Error when opening a output file"));
113  m.insert(std::make_pair(errorNbModality, "Minimum number of modality is 2"));
114  m.insert(std::make_pair(knownPartitionNeeded, "known partition is needed for M algorithm"));
115  m.insert(std::make_pair(badKnownPartition, "bad known partition"));
116  m.insert(std::make_pair(endDataFileReach, "the end of data file has been reached before reading all samples] verify nbSample or data file"));
117  m.insert(std::make_pair(wrongNbKnownPartition, "Error : wrong number of known Partition in input object"));
118  m.insert(std::make_pair(SubDimensionFreeTooLarge, "SubDimensionFree is too large"));
119  m.insert(std::make_pair(SubDimensionFreeTooSmall, "SubDimensionFree is too small"));
120  m.insert(std::make_pair(SubDimensionEqualTooLarge, "SubDimensionEqual is too large"));
121  m.insert(std::make_pair(SubDimensionEqualTooSmall, "SubDimensionEqual is too small"));
122  m.insert(std::make_pair(weightTotalIsNotAnInteger, "Error : weightTotal must be an integer"));
123  m.insert(std::make_pair(ungivenSubDimension, "Error : sub dimensions are not given for one or several models"));
124  m.insert(std::make_pair(wrongNbAlgoWhenMorMAP, "Error : wrong number of algortihms if M or MAP are used"));
125  m.insert(std::make_pair(BadInitialsationWhenM, "Error : USER_PARTITION must be the initialisation if M is used"));
126  m.insert(std::make_pair(BadInitialsationWhenMAP, "Error : USER must be the initialisation if MAP is used"));
127  m.insert(std::make_pair(partitionMustBeComplete, "Error : partition must be complete"));
128  m.insert(std::make_pair(inputNotFinalized, "Error : input is not finalized"));
129  m.insert(std::make_pair(algorithmMustBeM, "Error : algorithm must be M"));
130  m.insert(std::make_pair(knownPartitionAndInitPartitionMustBeEqual, "Error : knownLabel And InitLabel must be equal"));
131  m.insert(std::make_pair(nbStrategyMustBe1, "Error : nbStrategy must be equal to 1"));
132  m.insert(std::make_pair(wrongNbKnownPartitionOrInitPartition, "Error : wrong number of knownLabel or InitLabel"));
133  m.insert(std::make_pair(tooManySampleInInitPartitionAndTooManyClusterNotRepresented, "Error : error in USER_PARTITION initialization : Too many sample in InitPartition and too many cluster not repented"));
134  m.insert(std::make_pair(notAvailableForPrediction, "Not available for prediction"));
135  m.insert(std::make_pair(wrongValueInMultinomialCase, "wrong value in data set : use 1,2...nbModality"));
136  m.insert(std::make_pair(errorInPartitionInput, "Error in partition file : there is not enough lines in the file (nbSample is required)"));
137  m.insert(std::make_pair(badNumberOfValuesInLabelInput, "Error in label file : the number of values bust be nbSample"));
138  m.insert(std::make_pair(notEnoughValuesInProbaInput, "Error in proba file : there is not enough values in the file (nbSample*nbCluster is required)"));
139  m.insert(std::make_pair(badValueInLabelInput, "Error in label file : label must be between 1 and nbCluster"));
140  m.insert(std::make_pair(ColumnTypeNotValid, "Bad Format"));
141  m.insert(std::make_pair(badStopNameWithSEMAlgo, "Error : bad stop type with SEM : this algortihm must be stopped after a predefined number of iterations"));
142  m.insert(std::make_pair(badAlgorithmInHDContext, "Error : bad algorithm in HD context : only M or MAP is available"));
143  m.insert(std::make_pair(differentSubDimensionsWithMAP, "Error : given subDimensions in init file and input file are different"));
144  m.insert(std::make_pair(wrongSubDimension, "Error : Wrong sub dimension type for given model"));
145  m.insert(std::make_pair(missingRequiredInputs, "Error : Missing required inputs (data, nbSample, pbDimension, tabNbCluster, nbNbCluster)"));
146  m.insert(std::make_pair(wrongCriterionPositionInSet, "Wrong criterion position in set"));
147  m.insert(std::make_pair(wrongCriterionPositionInGet, "Wrong criterion position in get"));
148  m.insert(std::make_pair(wrongCriterionPositionInInsert, "Wrong criterion position in insert"));
149  m.insert(std::make_pair(wrongCriterionPositionInRemove, "Wrong criterion position in remove"));
150  m.insert(std::make_pair(wrongModelPositionInSet, "Wrong model position in set"));
151  m.insert(std::make_pair(wrongModelPositionInGet, "Wrong model position in get"));
152  m.insert(std::make_pair(wrongModelPositionInInsert, "Wrong model position in insert"));
153  m.insert(std::make_pair(wrongModelPositionInRemove, "Wrong model position in remove"));
154  m.insert(std::make_pair(wrongModelPositionInSetSubDimensionEqual, "Wrong model position in set sub dimension equal"));
155  m.insert(std::make_pair(wrongModelPositionInSetSubDimensionFree, "Wrong model position in set sub dimension free"));
156  m.insert(std::make_pair(wrongModelInSetSubDimensionEqual, "SetSubDimensionEqual could not be called with this model"));
157  m.insert(std::make_pair(wrongModelInSetSubDimensionFree, "SetSubDimensionFree could not be called with this model"));
158  m.insert(std::make_pair(badSetKnownPartition, "Error in setKnownPartition (impossible if nbNbCluster>1)"));
159  m.insert(std::make_pair(wrongStrategyPositionInSetOrGetMethod, "Wrong strategy position in set or get method"));
160  m.insert(std::make_pair(badInitPart, "Bad Initialization Partition"));
161  m.insert(std::make_pair(nbTryInStrategyTooSmall, "Number of tries in strategy too small"));
162  m.insert(std::make_pair(nbTryInStrategyTooLarge, "Number of tries in strategy too large"));
163  m.insert(std::make_pair(nbTryInInitTooSmall, "Number of tries in init too small"));
164  m.insert(std::make_pair(nbTryInInitTooLarge, "Number of tries in init too large"));
165  m.insert(std::make_pair(nbIterationInInitTooSmall, "Number of iterations in init too small"));
166  m.insert(std::make_pair(nbIterationInInitTooLarge, "Number of iterations in init too large"));
167  m.insert(std::make_pair(epsilonInInitTooSmall, "Epsilon in init too small"));
168  m.insert(std::make_pair(epsilonInInitTooLarge, "Epsilon in init too large"));
169  m.insert(std::make_pair(wrongNbStrategyTryValue, "Wrong number of tries in strategy"));
170  m.insert(std::make_pair(badSetNbTry, "Number of tries in strategy could not change"));
171  m.insert(std::make_pair(badSetNbTryInInit, "Number of tries in init could not change"));
172  m.insert(std::make_pair(badSetNbIterationInInit, "Number of iterations in init could not change"));
173  m.insert(std::make_pair(badSetEpsilonInInit, "Epsilon in init could not change"));
174  m.insert(std::make_pair(badSetStopNameInInit, "Stop name could not change in this context"));
175  m.insert(std::make_pair(badCriterion, "Bad Criterion"));
176  m.insert(std::make_pair(badAlgo, "Bad Algorithm"));
177  m.insert(std::make_pair(badAlgoStop, "Bad Algorithm Stop Name"));
178  m.insert(std::make_pair(DAInput, "XEMDAInput not implemented"));
179  m.insert(std::make_pair(wrongModelName, "Wrong model Name"));
180  m.insert(std::make_pair(knownPartitionNotAvailable, "known Partition is not available"));
181  m.insert(std::make_pair(tooManyWeightColumnDescription, "Too many WeightColumnDescription"));
182  m.insert(std::make_pair(badDataDescription, "Bad Data Description"));
183  m.insert(std::make_pair(badLabelDescription, "Bad Label Description"));
184  m.insert(std::make_pair(errorInColumnDescription, "Bad size of Column Description"));
185  m.insert(std::make_pair(errorInXEMInputSelector, "Bad size of Column Description"));
186  m.insert(std::make_pair(wrongIndexInGetMethod, "wrong index in get method"));
187  m.insert(std::make_pair(badInputType, "Bad Input type"));
188  m.insert(std::make_pair(wrongKnownPartitionPositionInSet, "wrong known partition position in set"));
189  m.insert(std::make_pair(wrongKnownPartitionPositionInRemove, "wrong known partition position in remove"));
190  m.insert(std::make_pair(HDModelsAreNotAvailableInClusteringContext, "HD Models Are Not Available In Clustering Context"));
191 
192  return m;
193  }
194 
195  static std::map<InputError, const char*> mapErrorMsg;
196 
197 protected:
198 
199  InputError _errorType;
200 };
201 
202 }
203 
204 #endif /* XEMINPUTEXCEPTION_H_ */
Definition: InputException.h:38
Definition: Exception.h:42
virtual const char * what() const
Definition: InputException.cpp:52
virtual bool operator==(const Exception &) const
Definition: InputException.cpp:56
virtual void run(std::ostream &flux=std::cout) const
Definition: InputException.cpp:62