15 std::shared_ptr<const Alphabet> alpha,
16 vector<std::unique_ptr<TransitionModelInterface>>& vpModel) :
21 size_t i, nbmod = vpModel.size();
23 throw Exception(
"MixtureOfTransitionModels::MixtureOfTransitionModels : empty vector of models.");
25 for (i = 0; i < nbmod; ++i)
29 for (
size_t j = i + 1; j < nbmod; ++j)
31 if (vpModel[i] == vpModel[j])
39 for (i = 0; i < nbmod; i++)
42 vProbas_.push_back(1.0 /
static_cast<double>(nbmod));
49 for (i = 0; i < nbmod - 1; i++)
57 for (i = 0; i < nbmod; i++)
67 std::shared_ptr<const Alphabet> alpha,
68 vector<std::unique_ptr<TransitionModelInterface>>& vpModel,
75 size_t i, nbmod = vpModel.size();
77 for (i = 0; i < nbmod; ++i)
81 for (
size_t j = i + 1; j < nbmod; ++j)
83 if (vpModel[i] == vpModel[j])
92 for (i = 0; i < nbmod; i++)
108 for (i = 0; i < nbmod; i++)
124 for (i = 0; i < nbmod - 1; ++i)
134 for (i = 0; i < nbmod; ++i)
164 for (
size_t i = 0; i < nbmod; ++i)
170 throw NullPointerException(
"MixtureOfTransitionModels::model. No model with name '" + name +
"'.");
180 for (i = 0; i < nbmod - 1; i++)
190 for (i = 0; i < nbmod - 1; i++)
201 for (i = 0; i < nbmod; i++)
208 for (i = 0; i < nbmod; i++)
249 for (i = 0; i < nbmod - 1; i++)
265 throw Exception(
"MixtureOfTransitionModels::getSubmodelNumbers model description do not match " + desc);
267 Vuint submodnb(1, uint(i));
Partial implementation for Mixed Transition models, defined as a mixture of "simple" substitution mod...
const TransitionModelInterface & nModel(size_t i) const override
Returns a specific model from the mixture.
std::shared_ptr< const TransitionModelInterface > getNModel(size_t i) const override
std::vector< double > vProbas_
vector of the probabilities of the models
virtual size_t getNumberOfModels() const override
returns the number of models in the mixture
virtual void setVRates(const Vdouble &vd) override
Sets the rates of the submodels to be proportional to a given vector, with the constraint that the me...
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 addParameters_(const ParameterList ¶meters)
void addParameter_(Parameter *parameter)
void setParameterValue(const std::string &name, double value) override
bool matchParametersValues(const ParameterList ¶meters) override
std::string getNamespace() 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.
double rate_
The rate of the model (default: 1). The generator (and all its vectorial components) is independent o...
size_t getNumberOfStates() const override
Get the number of states.
Transition models defined as a mixture of several substitution models.
virtual void setVRates(const Vdouble &vd) override
Sets the rates of the submodels to follow the constraint that the mean rate of the mixture equals rat...
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
MixtureOfTransitionModels(std::shared_ptr< const Alphabet > alpha, std::vector< std::unique_ptr< TransitionModelInterface >> &vpModel)
Constructor of a MixtureOfTransitionModels, where all the models have rate 1 and equal probability.
MixtureOfTransitionModels & operator=(const MixtureOfTransitionModels &)
virtual ~MixtureOfTransitionModels()
std::string getName() const override
Get the name of the model.
void setFreq(std::map< int, double > &) override
applies setFreq to all the models of the mixture and recovers the parameters values.
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...
const TransitionModelInterface & model(const std::string &name) const override
retrieve a pointer to the submodel with the given name.
virtual void addParameters(const ParameterList ¶ms)
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_EX
Interface for all transition models.
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< unsigned int > Vuint