// file: $isip/class/pr/StatisticalModelAdaptation/StatisticalModelAdaptation.h // version: $Id: StatisticalModelAdaptation.h 9470 2004-05-10 15:40:08Z gao $ // // make sure definitions are only made once // #ifndef ISIP_STATISTICAL_MODEL_ADAPTATION #define ISIP_STATISTICAL_MODEL_ADAPTATION // isip include files // #ifndef ISIP_REGRESSION_DECISION_TREE_NODE #include #endif #ifndef ISIP_REGRESSION_DECISION_TREE #include #endif #ifndef ISIP_STATISTICAL_MODEL #include #endif #ifndef ISIP_GAUSSIAN_MODEL #include #endif #ifndef ISIP_MIXTURE_MODEL #include #endif #ifndef ISIP_BIGRAPH_ARC #include #endif #ifndef ISIP_BIGRAPH_VERTEX #include #endif // forward class definitions: // we must define the RegressionDecisionTreeNode and // RegressDecisionTree class here first because the header files // might be short-circuited by the ifndef. // class RegressionDecisonTreeNode; class RegressionDecisonTree; // StatisticalModelAdaptation: a class that adapts the statistical // models by giving the regression decision tree. // class StatisticalModelAdaptation { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { MLLR = 0, MAP, DEF_ALGORITHM = MLLR }; // define the implementation choices // enum IMPLEMENTATION { MEAN = 0, VARIANCE, DEF_IMPLEMENTATION = MEAN }; // define the static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; static const String PARAM_DBGL; //---------------------------------------- // // other static constants // //---------------------------------------- //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 00100750; static const int32 ERR_UNSUPM = 00100760; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the structures // typedef BiGraphVertex RTreeNode; // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // define transformation matrix W (one row for each Gaussian // dimension) // Vector w_transform_d; // debugging parameters // DebugLevel debug_level_d; // static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods: // bool8 debug(const unichar* msg) const; // method: setDebug // bool8 setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // method: destructor // ~StatisticalModelAdaptation() { } // method: default constructor // StatisticalModelAdaptation(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION) { algorithm_d = algorithm; implementation_d = implementation; } // method: copy constructor // StatisticalModelAdaptation(const StatisticalModelAdaptation& arg) { assign(arg); } // assign methods // bool8 assign(const StatisticalModelAdaptation& arg); // method: operator= // StatisticalModelAdaptation& operator= (const StatisticalModelAdaptation& arg) { assign(arg); return *this; } // i/o methods // int32 sofSize() const; // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } bool8 read(Sof& sof, int32 tag, const String& name); // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } bool8 write(Sof& sof, int32 tag, const String& name) const; // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // equality methods // bool8 eq(const StatisticalModelAdaptation& arg) const; // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // other memory management methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setAlgorithm // bool8 setAlgorithm(ALGORITHM algorithm) { algorithm_d = algorithm; return true; } // method: setImplementation // bool8 setImplementation(IMPLEMENTATION implementation) { implementation_d = implementation; return true; } // method: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION) { algorithm_d = algorithm; implementation_d = implementation; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getAlgorithm // ALGORITHM getAlgorithm() const { return algorithm_d; } // method: getImplementation // IMPLEMENTATION getImplementation() const { return implementation_d; } // method: getDebug // bool8 getDebug(Integral::DEBUG & level) { level = debug_level_d; return true; } // method: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation) { algorithm = algorithm_d; implementation = implementation_d; return true; } // method to adapt the model // bool8 adapt(RegressionDecisionTree& rdt_a, Vector& stat_models_a); //--------------------------------------------------------------------------- // // class-specific public methods: // computational methods // //--------------------------------------------------------------------------- // method to set the parser // bool8 setParser(SofParser* parser); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // find a terminal by given a regression decision tree and node // index // BiGraphVertex* findTerminal(RTreeNode*& root_node_a, int32 index_a); }; // end of include file // #endif