📄 ghmm_swdiscretemodel.h
字号:
/* created: 2. April 2003 authors: Wasinee Rungsarityotin file : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_SWDiscreteModel.h,v $ $Id: GHMM_SWDiscreteModel.h,v 1.4 2004/02/27 12:55:36 wasinee Exp $ Copyright (C) 1998-2001, ZAIK/ZPR, Universit鋞 zu K鰈n This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef _GHMM_SWDISCRETEMODEL_H#define _GHMM_SWDISCRETEMODEL_H 1#include <ghmm/model.h>#include <ghmm/sdmodel.h>#include <ghmm++/GHMM_StateT.hh>#include <ghmm++/GHMM_GMLTransition.h>#include <ghmm++/GHMM_Alphabet.h>#include <ghmm++/GHMM_AbstractModelT.hh> // Template#include <ghmm++/begin_code.h>#ifdef HAVE_NAMESPACESnamespace std {#endifclass GHMM_Sequences;class GHMM_IntVector;class GHMM_DoubleVector;class GHMM_DoubleMatrix;class GHMM_Alphabet;class GHMM_GMLState;class GHMM_GMLTransition;/** Discrete HMM model (wrapper around model in C data structure). */class GHMM_SWDiscreteModel : public GHMM_AbstractModelT<GHMM_GMLState, GHMM_GMLTransition> {public: GHMM_SWDiscreteModel(GHMM_Alphabet* my_alphabet); GHMM_SWDiscreteModel(GHMM_Alphabet* my_alphabet, int no_klass); /** Constructor. */ GHMM_SWDiscreteModel( sdmodel* my_model); /** Destructor. */ ~GHMM_SWDiscreteModel(); /** Returns name of class. */ const char* toString() const; /** Writes the model in matrix format. @param file: output file */ void print(FILE *file); /** Writes transition matrix of a model. @param file: output file @param tab: format: leading tabs @param separator: format: seperator for columns @param ending: format: end of a row */ void A_print(FILE *file, char *tab, char *separator, char *ending) const; /** Writes output matrix of a model. @param file: output file @param tab: format: leading tabs @param separator: format: seperator for columns @param ending: format: end of a row */ void B_print(FILE *file, char *tab, char *separator, char *ending) const; void Pi_print(FILE *file, char *tab, char *separator, char *ending) const; /** Tests if all standardization requirements of model are fulfilled. (That is, if the sum of the probabilities is 1). @return 0 on succes; -1 on error. */ int check() const { return 0; } GHMM_SWDiscreteModel* copy(); GHMM_Sequences* generate_sequences(int seed, int global_len, long seq_number) const { return NULL; } GHMM_Sequences* generate_sequences(int seed, int global_len, long seq_number, int Tmax) const; /** Returns alphabet of model or NULL, if no such alphabet exists. */ GHMM_Alphabet* getAlphabet() const; /** Returns model type. */ GHMM_ModelType getModelType() const; /** */ int getNumberOfTransitionMatrices() const; /** */ model *create_cmodel(int kclass); /** */ void XMLIO_finishedReading(); /** Called by GHMM_Document when a start tag is received. Tag and attributes are passed to this function. */ XMLIO_Element* XMLIO_startTag(const string& tag, XMLIO_Attributes &attrs); void createTransitions(); const int XMLIO_writeContent(XMLIO_Document& writer); /* Returns state with given index. */ sdstate* getCState(int index) const; /** Forward-Algorithm. Calculates alpha[t][i], scaling factors scale[t] and log( P(O|lambda) ) for a given double sequence and a given model. @param seq: sequences @param index: index of sequence to take @param alpha: alpha[t][i] @param scale: scale factors (return value, if scale is NULL this vector will not be returned) @param log\_p: log likelihood log( P(O|lambda) ) @return NULL on error, alpha matrix on success */ GHMM_DoubleMatrix* foba_forward(GHMM_Sequences* seq, int index, GHMM_DoubleVector* scale, double *log_p) const; /** Viterbi algorithm. Calculates the Viterbi path (the optimal path trough the model) and the Viterbi probability to a given model and a given sequence. @return Viterbi path @param sequences sequences structure @param index index of sequence to take @param log_p probability of the sequence in the Viterbi path (return value). */ GHMM_IntVector* viterbi(GHMM_Sequences* sequences, int index, double* log_p = NULL); /** topological ordering with cycle detection (using in-degrees) */ void topological_sort(void); /** C Model. */ sdmodel* c_model; /** Alphabet of model. */ GHMM_Alphabet* alphabet; int no_classes;protected: typedef enum eDFSCOLORS {GRAY=0, BLACK=1, WHITE=2, NONE=-1} DFSCOLORS; /** */ bool own_alphabet; DFSCOLORS** edge_classes; void init(); void init(GHMM_Alphabet *alphabet); void init(int number_of_states, int alphabet_size, double prior=-1); void setNodeTag (const string& tag); void setTransitionTag (const string& tag); void buildCppData(); void cleanCPP(); void DFS(); void DFSVisit(int nodev, int &timevisit, int *parents, DFSCOLORS *colors);};#ifdef HAVE_NAMESPACES}#endif#include <ghmm++/close_code.h>#endif /* _GHMM_DISCRETEMODEL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -