ToPS
InhomogeneousFactorableModel.hpp
00001 /*
00002  *       InhomogeneousFactorableModel.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 IH_FACTORABLE_MODEL_HPP
00026 #define IH_FACTORABLE_MODEL_HPP
00027 
00028 #include "crossplatform.hpp"
00029 
00030 #include "ProbabilisticModel.hpp"
00031 
00032 namespace tops {
00034   class DLLEXPORT InhomogeneousFactorableModel : public ProbabilisticModel {
00035   private:
00036     ProbabilisticModel * _model;
00037     std::vector<DoubleVector> _alpha;
00038     std::vector<DoubleVector> _precision;
00039     DoubleVector _scores;
00040     int _phase;
00041   public:
00042      InhomogeneousFactorableModel() {};
00043     virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end) const;
00044 
00045     virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end, int phase) const;
00046     virtual Sequence & choose(Sequence & h, int size) const;
00047 
00048     virtual Sequence & chooseWithHistory(Sequence & h, int i, int size) const;
00049 
00050     virtual Sequence & chooseWithHistory(Sequence & h, int i,  int phase, int size) const;
00051     virtual ~ InhomogeneousFactorableModel(){};
00053 
00058     virtual double evaluatePosition(const Sequence & s, int i, int t) const = 0;
00060 
00065     virtual int choosePosition(const Sequence & s, int i, int t) const = 0;
00066 
00068     virtual int maximumTimeValue() const = 0;
00069 
00071     virtual bool isPhased() const = 0;
00072 
00073     virtual  double prefix_sum_array_compute(int begin, int end) ;
00074     virtual  double prefix_sum_array_compute(int begin, int end, int phase) ;
00075 
00076     virtual bool initialize_prefix_sum_array(const Sequence & s, int phase);
00077     virtual bool initialize_prefix_sum_array(const Sequence & s){
00078       return initialize_prefix_sum_array(s, 0);
00079     }
00080 
00081     virtual InhomogeneousFactorableModel * inhomogeneous() {
00082       return this;
00083     }
00084 
00085   };
00086 }
00087 
00088 #endif