⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 markov.cpp

📁 这是cdma2000的一个分组调度算法实例
💻 CPP
字号:
#include "markov.h"
/////////// ONLY FORWARD CHANNEL is modeled here!!!!!!!!!!!
int CMarkovVoice::stTable[16][3]=
{
	{0,		0,		2916	},
	{0,		20906,	25264	},
	{0,		0,		0		},
	{0,		0,		0		},
	{0,		0,		4915	},
	{0,		17170,	24969	},
	{21856,	25887,	27099	},
	{0,		0,		0		},
	{0,		0,		4522	},
	{0,		5472,	16384	},
	{21856,	21856,	24576	},
	{28246,	29622,	30802	},
	{0,		0,		5472	},
	{0,		6554,	6554	},
	{28377,	28934,	29491	},
	{29753,	32473,	32571	}  };

CMarkovVoice::CMarkovVoice()
{
	a=16807;
	m=2147483647;

	currentState=0;  //initial state should be 15!!!
	///////////////// NOTICE!!!!! /////////////////
	//according to 3GPP2 document, initial state should be 15,
	//but in our simulation platform, voice users are in active state
	//once they are created, so we change its value to 0.  ZhangXin.
	
	FRNG=0; //default is 0; system time in frames of the forwards synchronization frame
	FRNG=(FRNG^0x2AAAAAAA)&0x7FFFFFFF;
	FRNG=(((((((FRNG*a)%m)*a)%m)*a)%m)*a)%m;

}

///////// for randomizing the seed //////////////
void CMarkovVoice::initRan(long lTemp)
{
	FRNG=lTemp; //system time in frames of the forwards synchronization frame
	FRNG=(FRNG^0x2AAAAAAA)&0x7FFFFFFF;
	FRNG=(((((((FRNG*a)%m)*a)%m)*a)%m)*a)%m;
}

void CMarkovVoice::genRan()
{
	FRNG=(FRNG*a)%m;
}

int CMarkovVoice::GetNextState()
{   long temp;
	long yn,zn;
	genRan();
	temp=FRNG;
	yn=temp>>7;
	zn=yn&0x7FFF; //taking the 15 LSBs of yn

	if(zn<stTable[currentState][0])
	{
		nextState=(4*currentState+3)%16;
	}
	else if( (stTable[currentState][0]<=zn) && (zn<stTable[currentState][1]) )
	{
		nextState=(4*currentState+2)%16;
	}
	else if( (stTable[currentState][1]<=zn) && (zn<stTable[currentState][2]) )
	{
		nextState=(4*currentState+1)%16;
	}
	else if(zn>=stTable[currentState][2])
	{
		nextState=(4*currentState)%16;
	}

	currentState=nextState;
	return (nextState);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -