Exemplo n.º 1
0
//----------------------------------------------------------------
//----------------------------------------------------------------
    int Exp3::getNextAction()
    {
        vector< AlphaReal > cumsum( getArmNumber()+1 );
        int i;

        cumsum[0] = 0.0;
        for( int i=0; i < getArmNumber(); i++ )
        {
            cumsum[i+1] = cumsum[i] + _pHat[i];
        }

        for( i=0; i < getArmNumber(); i++ )
        {
            cumsum[i+1] /= cumsum[  getArmNumber() ];
        }

        AlphaReal r = rand() / (AlphaReal) RAND_MAX;

        for( i=0; i < getArmNumber(); i++ )
        {
            if ( (cumsum[i] <= r) && ( r<=cumsum[i+1] )  ) break;
        }

        return i;
    }
Exemplo n.º 2
0
int UCBKRandomized::getNextAction()
{
	vector< double > cumsum( getArmNumber()+1 );
	int i;

	cumsum[0] = 0.0;
	for( int i=0; i < getArmNumber(); i++ )
	{
		cumsum[i+1] = cumsum[i] + _valueRecord[i]->first;
	}

	for( i=0; i < getArmNumber(); i++ )
	{
		cumsum[i+1] /= cumsum[  getArmNumber() ];
	}

	double r = rand() / (double) RAND_MAX;

	for( i=0; i < getArmNumber(); i++ )
	{
		if ( (cumsum[i] <= r) && ( r<=cumsum[i+1] )  ) break;
	}

	return i;
}
Exemplo n.º 3
0
int Random::getNextAction()
{
	int arm = (int) (rand() % getArmNumber() );

	return arm;
}