18 std::shared_ptr<const Alphabet> alpha,
19 std::unique_ptr<TransitionModelInterface> model,
20 std::map<std::string, std::unique_ptr<DiscreteDistributionInterface>>& parametersDistributionsList,
30 if (
to_ >=
int(alpha->getSize()))
32 if (
from_ >=
int(alpha->getSize()))
47 if (parametersDistributionsList.find(s2) != parametersDistributionsList.end())
48 distributionMap_[s1].reset(parametersDistributionsList.find(s2)->second->clone());
69 c *= it.second->getNumberOfCategories();
72 for (i = 0; i < c; i++)
75 vProbas_.push_back(1.0 /
static_cast<double>(c));
95 for (i = 0; i != it.second->getNumberOfParameters(); ++i)
161 for (
auto& parname : vDistnames)
166 distrib.second->matchParametersValues(pl);
171 t = distrib.second->getNamespace();
173 distrib.second->setParameterValue(
"value", d);
184 l = j % distrib.second->getNumberOfCategories();
186 d = distrib.second->getCategory(l);
187 vProbas_[i] *= distrib.second->getProbability(l);
193 j = j / distrib.second->getNumberOfCategories();
218 vector<string> parnames =
modelsContainer_[0]->getParameters().getParameterNames();
219 std::map<std::string, size_t> msubn;
225 string::size_type index = param.rfind(
"_");
226 if (index == string::npos)
227 throw Exception(
"MixtureOfATransitionModel::getSubmodelNumbers parameter description should contain a number " + param);
228 msubn[param.substr(0, index)] = TextTools::to<size_t>(param.substr(index + 1, 4)) - 1;
242 l = j % it.second->getNumberOfCategories();
244 if (msubn.find(s) != msubn.end())
252 j = j / it.second->getNumberOfCategories();
254 if (stopped == msubn.size())
255 submodnb.push_back(uint(i));
Partial implementation for Mixed Transition models, defined as a mixture of "simple" substitution mod...
std::vector< double > vProbas_
vector of the probabilities of the models
AbstractMixedTransitionModel & operator=(const AbstractMixedTransitionModel &)
std::vector< double > vRates_
vector of the rates of the models.
std::vector< std::shared_ptr< TransitionModelInterface > > modelsContainer_
vector of pointers to TransitionModels.
void addParameter_(Parameter *parameter)
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
const Parameter & parameter(const std::string &name) const override
bool matchParametersValues(const ParameterList ¶meters) override
std::string getNamespace() const override
std::string getParameterNameWithoutNamespace(const std::string &name) const override
const ParameterList & getParameters() const override
double getParameterValue(const std::string &name) const override
Partial implementation of the TransitionModel interface.
Vdouble freq_
The vector of equilibrium frequencies.
size_t getNumberOfStates() const override
Get the number of states.
virtual double getCategory(size_t categoryIndex) const=0
virtual void restrictToConstraint(const ConstraintInterface &c)=0
Transition models defined as a mixture of nested substitution models.
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
Vuint getSubmodelNumbers(const std::string &desc) const override
Returns the vector of numbers of the submodels in the mixture that match a description of the paramet...
virtual ~MixtureOfATransitionModel()
MixtureOfATransitionModel & operator=(const MixtureOfATransitionModel &)
void setFreq(std::map< int, double > &) override
sets the eq frequencies of the first nested model, and adapts the parameters at best to it (surely th...
std::map< std::string, std::unique_ptr< DiscreteDistributionInterface > > distributionMap_
MixtureOfATransitionModel(std::shared_ptr< const Alphabet > alpha, std::unique_ptr< TransitionModelInterface > model, std::map< std::string, std::unique_ptr< DiscreteDistributionInterface >> ¶metersDistributionsList, int ffrom=-1, int tto=-1)
const TransitionModelInterface & model(const std::string &name) const override
retrieve a pointer to the submodel with the given name.
MixtureOfATransitionModel * clone() const override
virtual bool hasParameter(const std::string &name) const
virtual std::vector< std::string > getParameterNames() const
virtual void setParameterValue(const std::string &name, double value)
virtual void addParameter(const Parameter ¶m)
virtual double getValue() const
virtual std::shared_ptr< const ConstraintInterface > getConstraint() const
virtual bool hasConstraint() const
virtual std::string getParameterNameWithoutNamespace(const std::string &name) const=0
virtual size_t getNumberOfParameters() const=0
virtual double getParameterValue(const std::string &name) const=0
virtual const ParameterList & getParameters() const=0
virtual const Parameter & parameter(const std::string &name) const=0
const std::string & nextToken()
bool hasMoreToken() const
TransitionModelInterface * clone() const =0
Defines the basic types of data flow nodes.
std::vector< unsigned int > Vuint