ToPS
VariableLengthMarkovChainCreator.hpp
00001 /*
00002  *       VariableLengthMarkovChainCreator.hpp
00003  *
00004  *       Copyright 2011 Andre Yoshiaki Kashiwabara <akashiwabara@usp.br>
00005  *                      Ígor Bonádio <ibonadio@ime.usp.br>
00006  *                      Vitor Onuchic <vitoronuchic@gmail.com>
00007  *                      Alan Mitchell Durham <aland@usp.br>
00008  *
00009  *       This program is free software; you can redistribute it and/or modify
00010  *       it under the terms of the GNU  General Public License as published by
00011  *       the Free Software Foundation; either version 3 of the License, or
00012  *       (at your option) any later version.
00013  *
00014  *       This program is distributed in the hope that it will be useful,
00015  *       but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *       GNU General Public License for more details.
00018  *
00019  *       You should have received a copy of the GNU General Public License
00020  *       along with this program; if not, write to the Free Software
00021  *       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022  *       MA 02110-1301, USA.
00023  */
00024 
00025 #ifndef VLMC_CREATOR_HPP
00026 #define VLMC_CREATOR_HPP
00027 
00028 #include "crossplatform.hpp"
00029 
00030 #include "ProbabilisticModelCreator.hpp"
00031 #include "ProbabilisticModel.hpp"
00032 #include "VariableLengthMarkovChain.hpp"
00033 #include <boost/shared_ptr.hpp>
00034 
00035 namespace tops {
00037   class DLLEXPORT VariableLengthMarkovChainCreator : public ProbabilisticModelCreator
00038   {
00039   public:
00040     VariableLengthMarkovChainCreator() {};
00041     virtual ~VariableLengthMarkovChainCreator(){};
00042     virtual ProbabilisticModelPtr create(ProbabilisticModelParameters & parameters) const ;
00043     virtual VariableLengthMarkovChainPtr createVLMC(ProbabilisticModelParameters & parameters) const ;
00044     virtual std::string help() const {
00045       std::stringstream out;
00046       out << "\nUSAGE: " << std::endl;
00047       out << "Mandatory parameters: " << std::endl;
00048       out << "\tprobabilities" << std::endl;
00049       out << "\talphabet" << std::endl;
00050       out << "Example: " << std::endl;
00051       out << "\tmodel_name=\"VariableLengthMarkovChain\"" << std::endl;
00052       out << "\talphabet=(\"0\", \"1\")" << std::endl;
00053       out << "probabilities= (\"0\" | \".\": 0.5;            # Pr(X_0 = 0)" << std::endl;
00054       out << "                \"1\" | \".\": 0.5;            # Pr(X_0 = 1)" << std::endl;
00055       out << "                \"0\" | \"0\": 0.1;            # Pr(X_n = 0 | X_{n-1} = 0)" << std::endl;
00056       out << "                \"1\" | \"0\": 0.9;            # Pr(X_n = 1 | X_{n-1} = 0)" << std::endl;
00057       out << "                \"0\" | \"1\": 0.5;            # Pr(X_n = 0 | X_{n-1} = 1)" << std::endl;
00058       out << "                \"1\" | \"1\": 0.5;            # Pr(X_n = 1 | X_{n-1} = 1)" << std::endl;
00059       out << "                \"0\" | \"1 0\": 0.7;          # Pr(X_n = 0 | X_{n-1} = 1, X_{n-2} = 0)" << std::endl;
00060       out << "                \"1\" | \"1 0\": 0.3;          # Pr(X_n = 1 | X_{n-1} = 1, X_{n-2} = 0)" << std::endl;
00061       out << "                \"0\" | \"1 1\": 0.4;          # Pr(X_n = 0 | X_{n-1} = 1, X_{n-2} = 1)" << std::endl;
00062       out << "                \"1\" | \"1 1\": 0.6)          # Pr(X_n = 0 | X_{n-1} = 1, X_{n-2} = 1)" << std::endl;
00063 
00064 
00065 
00066       return out.str();
00067     }
00068     virtual std::string factory_name() const {
00069       return "VariableLengthMarkovChainCreator";
00070     }
00071 
00072   };
00073   typedef boost::shared_ptr < VariableLengthMarkovChainCreator> VariableLengthMarkovChainCreatorPtr;
00074 }
00075 
00076 #endif