亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? simulation.cpp

?? 在任務級并行平臺P2HP上開發的demo應用
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
				e_increase++;
		}
		quality.energy[5] = e_increase;
		quality.quality[5] = (next_Kfree + 0.5)*pow(parameter.Exp, e_increase);
	}

	for(int i=0; i<6; i++)
		quality.totalQuality += quality.quality[i];
	quality.averageQuality = quality.totalQuality / quality.k_free;
}


/***when restart simulation we must do this method***/ 
void Simulation::putFirstTwoPoint(){
	Point tempPoint(-1,-1,-1);
	int temp = sequence.getLength()-1;
	tempPoint.set(temp, temp, temp);
	tempResult.push_back(tempPoint);
	tempPoint.set(temp+1,temp,temp);
	tempResult.push_back(tempPoint);
	tempWeight.push_back(1);
	tempWeight.push_back(1);
	tempEnergy.push_back(0);
	tempEnergy.push_back(0);
	setSpaceNode(temp,temp,temp,sequence.getSequence().GetAt(0));
	setSpaceNode(temp+1,temp,temp,sequence.getSequence().GetAt(1));
}


/***choose a direction to put  node in***/
int Simulation::selectOneDirection(Quality &tempQuality){
	long double operation;
	int i;
	long double partSum[7];
	partSum[0] = 0;
	for(i=1; i<7; i++)
		partSum[i] = partSum[i-1] + tempQuality.quality[i-1]/tempQuality.totalQuality;
	while((operation = (long double)(rand()%1000)/1000) == 0){
	}
	for(i=1; i<7; i++){
		if(operation <= partSum[i] && operation > partSum[i-1]){
			break;			
		}			
	}	
	return (i-1);
}

/***put the  next point in to the space and set some parameter***/
void Simulation::putOneNode(Quality &tempQuality, int selectedDire){
	long double weight;
	Point point(-1,-1,-1);
	int energy =  tempQuality.energy[selectedDire];
	weight = tempWeight.back()*pow(parameter.Exp, energy)*tempQuality.k_free;
	tempWeight.push_back(weight);
	tempEnergy.push_back(energy);
	tempTotalEnergy += energy;
	//put the point into the site;
	point.set(tempResult.back().x+parameter.directions[selectedDire][0],
			  tempResult.back().y+parameter.directions[selectedDire][1],
			  tempResult.back().z+parameter.directions[selectedDire][2]);
	tempResult.push_back(point);
	setSpaceNode(point.x,point.y,point.z,sequence.getSequence().GetAt(tempResult.size()-1));
}

/***initialize a structure***/
void Simulation::initialization(){
	Quality quality;
	Point tempPoint(-1,-1,-1); //we use the point to insert the vector
	int select;
	//begin the construction
	while(tempResult.size() != sequence.getLength()){
		resetTemp();
		resetMatrix();
		putFirstTwoPoint();
		//find the sturction and give up the temp structure when a collide happen
		while(tempResult.size() < sequence.getLength()){
			computingQuality(quality);
			if(quality.k_free == 0)
				break;
			else{
				select = selectOneDirection(quality);
				putOneNode(quality, select);
			}
		}
	}
	bestRecoder = tempTotalEnergy;
	bestResult = tempResult;
	parameter.initial(tempWeight);
	
#ifdef MYDEBUG
/*
		std::vector<Point>::iterator pos;
		std::vector<long double>::iterator weight = parameter.averageOfWei.begin();
		for(pos = tempResult.begin(); pos<tempResult.end();pos++){
			cout<<pos->x<<"  "<<pos->y<<"  "<<pos->z<<" "<<"Weight:"<<*weight<<endl;
			weight++;
		}
		cout<<"energy of the structure:"<<tempTotalEnergy<<endl;
		cout<<"<The initialization of the simulaiton is stopping>"<<endl;*/
	
#endif
}

/***back to the last state**/
void Simulation::releaseOneNode(){
	tempWeight.pop_back();//delete
	int energy = tempEnergy.back();
	tempTotalEnergy -= energy;//delete
	tempEnergy.pop_back();
	Point point = tempResult.back();
	tempResult.pop_back();//delete
	setSpaceNode(point.x, point.y, point.z, '0');//delete
}

	
long double Simulation::selectMultiDirection(Quality &tempQuality, std::vector<int> &direction, const int &number){
	int multiple = linage(tempQuality.k_free, number)*number / tempQuality.k_free;
	long double allQuality = tempQuality.totalQuality * multiple;
	long double partQuality = 0;
	int tempIndex;
	int flag[6] = {0,0,0,0,0,0};
	while(direction.size() < number){
		tempIndex = rand()%6;
		if(tempQuality.quality[tempIndex] != 0 && flag[tempIndex] ==0){
			flag[tempIndex] = 1;
			direction.push_back(tempIndex);
			partQuality += tempQuality.quality[tempIndex];
		}
	}
	return (allQuality/partQuality);
}

/***conputing c(N,m)***/
int Simulation::linage(int big, int little){
	static const int mul[6] = {1, 1, 2, 6 ,24, 120};
	return (mul[big] / (mul[little]*mul[big-little]));
}

/***start the recursion procedure***/	
void Simulation::recursion(){
#ifdef MYDEBUG
		//cout<<"The program begin???"<<1<<endl;
#endif
	int finished = tempResult.size();
	int select;
	//find the better result, the reset the best recorder
	if(finished == sequence.getLength()){
#ifdef MYDEBUG
		//cout<<"((((((There is a new structure)))))))))"<<endl;
#endif		
		if(tempTotalEnergy >= bestRecoder){
			bestRecoder = tempTotalEnergy;
			bestResult = tempResult;
		}
		return;
	}

	Quality tempQuality;
	computingQuality(tempQuality);
	//the structure have collided
	if(tempQuality.k_free == 0)
		return;

	long double weightPred  = tempWeight.back()*tempQuality.totalQuality;
#ifdef MYDEBUG
		//cout<<parameter.averageOfWei.size()<<endl;
		//cout<<parameter.c<<endl;
		//cout<<parameter.averageOfWei[finished]<<endl;
		//cout<<parameter.numberOfLen.size()<<endl;
#endif
	long double uperThreshold 
		= parameter.c *(parameter.averageOfWei[finished] / parameter.z0)
					  *(parameter.numberOfLen[finished] / parameter.c0)
					  *(parameter.numberOfLen[finished] / parameter.c0);
	long double downThreshold = uperThreshold * 0.2;

	if(weightPred >= downThreshold && weightPred < uperThreshold){
		select = selectOneDirection(tempQuality);
		putOneNode(tempQuality, select);

#ifdef MYDEBUG
	//cout<<"<*********Enter the middle area***********>"<<endl;
	/*cout<<"Direciton selected is "<<select<<endl;
	cout<<"TempTotalEnergy is "<<tempTotalEnergy<<endl;*/		
#endif

		parameter.updatePara(tempWeight.back(), finished);
		recursion();
		releaseOneNode();
	}
	else if(weightPred < downThreshold){
#ifdef MYDEBUG

	//cout<<"<**********Enter the low area*********>"<<endl;
	/*cout<<"Direciton selected is "<<select<<endl;
	cout<<"TempTotalEnergy is "<<tempTotalEnergy<<endl;*/
		
#endif
		if((double)(rand()%1000) / 1000 <0.5)
			return;
		else{
			select = selectOneDirection(tempQuality);
			putOneNode(tempQuality, select);
			int tail = tempWeight.size() -1;
			tempWeight[tail] = 2*tempWeight[tail]; 
			parameter.updatePara(tempWeight.back(), finished);
			recursion();
			releaseOneNode();
		}
	}
	else if(weightPred > uperThreshold){
		unsigned int numberOfCopy = (int)(weightPred/uperThreshold)+1;
		if(numberOfCopy > tempQuality.k_free)
			numberOfCopy = tempQuality.k_free;
		std::vector<int> direction;
		//we need selectMultiDIrection return a random sequence direcitons !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		double PA = selectMultiDirection(tempQuality, direction, numberOfCopy);
#ifdef MYDEBUG

		//cout<<"<*********Enter the up area**********>"<<endl;
/*		cout<<"Number of the direciton selected are "<<direction.size()<<endl;
		for(int j=0; j<direction.size(); j++)
			cout<<"The direction of selected is: "<<direction[j]<<endl;
		cout<<"TempTotalEnergy is "<<tempTotalEnergy<<endl;*/
		
#endif
		//start the loop
		for(int i=0; i<numberOfCopy; i++){
			putOneNode(tempQuality, direction[i]);
			int tail = tempWeight.size() -1;
			tempWeight[tail] = tempWeight[tail] / (numberOfCopy*PA*linage(tempQuality.k_free, numberOfCopy)); 			
			parameter.updatePara(tempWeight.back(), finished);
			recursion();
			releaseOneNode();
		}
	}
}






































?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
九色综合狠狠综合久久| 538prom精品视频线放| 91成人国产精品| 国产亚洲人成网站| 午夜伊人狠狠久久| 99久久精品国产一区二区三区| 91精品国产综合久久福利| 亚洲欧美韩国综合色| 福利一区二区在线| 久久伊人蜜桃av一区二区| 日韩精品乱码免费| 欧美性欧美巨大黑白大战| 国产精品久久久99| 国产自产高清不卡| 精品国产一区久久| 男女视频一区二区| 欧美一区二区福利视频| 亚洲制服欧美中文字幕中文字幕| 不卡视频在线观看| 久久久www成人免费毛片麻豆| 欧美a级一区二区| 欧美日本免费一区二区三区| 亚洲一区二区综合| 欧美三级视频在线播放| 亚洲欧美激情小说另类| 色噜噜狠狠色综合中国| 国产精品高潮呻吟久久| 成人国产在线观看| 中文字幕精品—区二区四季| 国产suv精品一区二区883| 久久精品日产第一区二区三区高清版| 国内精品在线播放| 久久久久国产精品麻豆ai换脸| 激情欧美日韩一区二区| 久久在线免费观看| 高清在线观看日韩| 中文字幕五月欧美| 91精彩视频在线观看| 亚洲高清三级视频| 欧美日韩国产美女| 免费成人美女在线观看| 久久亚洲捆绑美女| 成人午夜激情视频| 亚洲精品免费在线观看| 欧美色区777第一页| 日韩电影免费在线观看网站| 日韩精品一区二区三区视频播放| 国产最新精品精品你懂的| 国产精品国产三级国产三级人妇 | 日韩高清一区在线| 欧美一级高清片在线观看| 精品无人区卡一卡二卡三乱码免费卡| 久久久久久久久久看片| 不卡视频免费播放| 一区二区三区精品在线| 日韩免费高清视频| 风间由美一区二区三区在线观看| 亚洲天堂免费在线观看视频| 欧美日韩一级二级三级| 国产一区视频网站| 亚洲色图视频网站| 欧美日韩成人一区二区| 国产乱子轮精品视频| 亚洲色图清纯唯美| 欧美成人aa大片| 一本久久综合亚洲鲁鲁五月天| 日韩综合一区二区| 国产精品美女久久久久aⅴ| 欧美日韩dvd在线观看| 国产麻豆精品一区二区| 亚洲一区二区三区四区的| 精品国产99国产精品| 色婷婷综合在线| 国内精品在线播放| 午夜日韩在线观看| 中文字幕在线不卡一区| 欧美va亚洲va| 欧美性猛交xxxxxx富婆| 国产成人精品网址| 亚洲高清视频的网址| 国产精品视频看| 精品国产91亚洲一区二区三区婷婷| 色婷婷av久久久久久久| 成人免费看黄yyy456| 日韩精品1区2区3区| 亚洲精品中文在线影院| 国产欧美日韩另类一区| 精品国产区一区| 555夜色666亚洲国产免| 欧美中文字幕一区二区三区亚洲| 国产高清亚洲一区| 日本在线观看不卡视频| 亚洲一区二区三区四区五区黄| 国产精品久久二区二区| 久久精品亚洲一区二区三区浴池 | 中文一区一区三区高中清不卡| 7777女厕盗摄久久久| 在线精品观看国产| 91美女蜜桃在线| 99re8在线精品视频免费播放| 国产精品自在在线| 精品无人码麻豆乱码1区2区| 美美哒免费高清在线观看视频一区二区 | 日韩国产欧美在线观看| 一区二区三区精品视频| 亚洲欧美区自拍先锋| 1000部国产精品成人观看| 久久你懂得1024| 久久久综合视频| wwwwxxxxx欧美| 欧美电影免费观看高清完整版 | 国产精品久久久久影院亚瑟| 国产欧美日韩综合| 国产精品沙发午睡系列990531| 精品理论电影在线| 久久久欧美精品sm网站| 久久精品一区八戒影视| 中文久久乱码一区二区| 中文字幕一区免费在线观看| 亚洲少妇最新在线视频| 一区二区三区中文字幕电影| 亚洲综合激情另类小说区| 亚洲成av人片在www色猫咪| 视频一区免费在线观看| 蜜桃精品视频在线观看| 国产很黄免费观看久久| 成人动漫av在线| 色婷婷综合久色| 欧美精品在线一区二区三区| 日韩美女视频在线| 国产人久久人人人人爽| 亚洲女女做受ⅹxx高潮| 日日骚欧美日韩| 国产一区二区视频在线| 国产成人精品免费一区二区| k8久久久一区二区三区| 欧美色图在线观看| 欧美大片顶级少妇| 国产精品福利电影一区二区三区四区| 中文字幕日本不卡| 三级不卡在线观看| 国产精品18久久久久久久久| av网站一区二区三区| 欧美日韩高清不卡| 日本一区二区三区久久久久久久久不| 日韩伦理免费电影| 奇米色一区二区| 91在线看国产| 精品久久99ma| 亚洲综合一二区| 国产精品一二三四五| 欧美日韩一区二区三区视频| 久久美女高清视频| 亚洲资源在线观看| 国产成人欧美日韩在线电影| 在线视频观看一区| 久久久久久亚洲综合影院红桃| 一区二区在线观看视频| 国产激情一区二区三区| 欧美天堂一区二区三区| 国产日韩综合av| 天天综合色天天| 91网站在线观看视频| 精品国产网站在线观看| 一区二区久久久久久| 国产在线观看一区二区| 欧美在线观看一区二区| 国产亚洲欧美日韩日本| 日韩精品一二三| 色成年激情久久综合| 欧美精品一区视频| 日韩av一区二区在线影视| 色婷婷综合久久久| 国产精品麻豆视频| 国产在线看一区| 日韩视频免费观看高清完整版| 亚洲视频在线一区观看| 成人精品视频网站| 久久综合九色综合97_久久久| 婷婷一区二区三区| 在线亚洲免费视频| 亚洲欧洲综合另类| 99视频超级精品| 国产日韩欧美一区二区三区乱码 | 亚洲 欧美综合在线网络| 91一区二区在线观看| 国产精品欧美极品| 国产盗摄一区二区三区| 久久中文娱乐网| 国产精品亚洲人在线观看| 精品日韩欧美在线| 九九九久久久精品| 欧美精品一区二区在线观看| 蜜乳av一区二区| 精品国产露脸精彩对白| 久久99国产精品久久99果冻传媒| 欧美一区二区三区色| 青青青伊人色综合久久| 欧美一二三在线| 国内精品国产成人|