Ejemplo n.º 1
0
void rlMain::onStart()
{
	//Inicializa valores diferentes para cada partida.
	time_t t = time(0);
	srand(t);

	setStateVector();

	Qtable.resize(StateVector.size());
	for (auto& qsa : Qtable)
	{
		qsa.resize(actionAvailable);
	}
}
void CXXEnzymeExecutableModel::getStateVectorRate(double time, const double* y,
        double* dydt)
{
    this->time = time;

    if (y && dydt)
    {
        // save and assign state vector
        double *savedFloatingSpeciesAmounts = floatingSpeciesAmounts;
        floatingSpeciesAmounts = const_cast<double*>(y);
        floatingSpeciesAmountRates = dydt;

        // not setting state vector, react rates get dirty
        double conversionFactor = evalReactionRates();

        csr_matrix_dgemv(conversionFactor, stoichiometry, reactionRates, 0.0, floatingSpeciesAmountRates);

        floatingSpeciesAmounts = savedFloatingSpeciesAmounts;
        floatingSpeciesAmountRates = 0;
    }
    else if (y && !dydt)
    {
        setStateVector(y);
    }
    else if (!y && dydt)
    {
        // evaluate dydt using current state

        double conversionFactor = evalReactionRates();

        // floatingSpeciesAmountRates only valid for the following two
        // functions, this will move to a parameter shortly...

        floatingSpeciesAmountRates = dydt;

        csr_matrix_dgemv(conversionFactor, stoichiometry, reactionRates, 0.0, floatingSpeciesAmountRates);

        floatingSpeciesAmountRates = 0;
    }
}