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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? antnest.cc

?? 用OMNET++仿真蟻群的源碼,是無線傳感器網(wǎng)絡(luò)仿真的一個重要工具
?? CC
字號:
// -*- C++ -*-// Copyright (C) 2003 Leherstuh f黵 Betrieb System/ Verteilte System, // Universitaet Dortmund //// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.// Author: Muddassar Farooq// Informatik III, Universitaet Dortmund// Germany//-------------------------------------------------------------// file: antNest.cpp//        (part of AntNet Routing Simulation)//-------------------------------------------------------------#include "antNest.h"/* #define original */

// There are small variations suggested by the author of AnNet Algorithm.
// If some one wants to omitt them then simply uncomment following line

/* #define original */Define_Module( antNest );antNest::~antNest(){	delete[] averageOfTimeToDest;	delete[] varianceOfTimeToDest;	delete[] bestTimeToDest;	delete[] timeWindowSamples;	delete[] bestTimeToDestInWindow;}void antNest::initializeNestFromRouter(){	antsDeleted = 0;	ptr = (Router *) gate("toRouter")->toGate()->ownerModule();	numNeighbors = ptr->getNumNeighbors();	numNodes = ptr->getNumNodes();	queueSize = ptr->getQueueMaxLen();	dataRate = ptr->getBandwidth();	myAddress = ptr->getMyAddress();	strcpy(sFileName,par("statFile"));	sPtr = statistics::Instance(sFileName);	hopsLimit = (int) (maxHopsCoefficient * numNodes);	// Co-efficient of exponential (n) means is used to compute	// exponential averages for the local traffic statistics	// 5*(1/n). Hence with the help of this 	// coefficient we could easily determine the number	// of samples that must be used in the computation	// of interval of confidence.	exponentialWinSize = (int) (1./expMeanCoefficient) * 5;	squreExpWinSize = (int) sqrt( (double)exponentialWinSize );	//  The purpose of this window size is to determine the	//  best round trip time over a window and then use it	//  in the reinforcement. Reinforcement takes into account	//  the ratio between current trip time and the best	//  trip time observed over this window.	//  | Wmax | = 5*(c/n) where c is windowSizeCoefficient	windowSize = (int) (windowSizeCoefficient * exponentialWinSize);	// initializing the probability in a uniform fashion	const double initialTransProb = 1./numNeighbors;	for(int i = 0; i < numNodes; i++)	{		for(int j = 0; j < numNeighbors; j++)		{			int neighbor = ptr->findNeighborAtIndex(j);			if( i != myAddress)			{				ptr->setProb(i,neighbor,initialTransProb);			}			else			{				ptr->setProb(i,neighbor,0.0);			}				} 	}		averageOfTimeToDest = new double[numNodes];	varianceOfTimeToDest = new double[numNodes];	bestTimeToDest = new double[numNodes];	timeWindowSamples = new int[numNodes];	bestTimeToDestInWindow = new double[numNodes];		for(int k = 0; k < numNodes; k++)	{		timeWindowSamples[k] = 0;		bestTimeToDest[k] = MAXFLOAT;		bestTimeToDestInWindow[k] = MAXFLOAT;		averageOfTimeToDest[k] = 0.0;		varianceOfTimeToDest[k] = 0.0;	}}

void antNest::initialize()
{
	expMeanCoefficient = par("expMeanCoefficient");
	windowSizeCoefficient = par("windowSizeCoefficient");
	zetaConfidenceLevel = par("zetaConfidenceLevel");
	explorationProbablity = par("explorationProbablity");
	rescalingPower = par("rescalingPower");
	queueWeight = par("queueWeight");
	forkProbability = par("forkProbability");
	maxHopsCoefficient = par("maxHopsCoefficient");
	ageLimit = par("ageLimit");
	squashFunctionCoefficient = par("squashFunctionCoefficient");
	probabilisticRouting = par("probabilisticRouting");
	timeWeight = par("timeWeight");
	converganceTime = par("converganceTime");

	double sleepTime = (double) par("sleepTimeAtStart");
	initRouter = new cMessage("InitRouter");
	scheduleAt( simTime() + sleepTime, initRouter);
}void antNest::handleMessage(cMessage *msg){
	int kind = msg->kind();

	if(kind == NETLAYER_FORWARD_ANT)
	{
		current = (Ant *) msg;
		processForwardAnts();
	}
	else if(kind == NETLAYER_BACKWARD_ANT)
	{
		current = (Ant *) msg;
		processBackwardAnts();
	}
	else if( msg == initRouter)
	{
		initializeNestFromRouter();
	}
	else	{		throw new cException("Unknown Message %d in AntNest of router %d",								kind, myAddress);	}}void antNest::processForwardAnts(){	bool antDeleted = false;	// 1. Check whether hop or age limit has been reached 	// 2. check whether the ant has reached the destination	if( current->getDestNode() == myAddress)	{		current->setKind( NETLAYER_BACKWARD_ANT );		// Determine the previous node and set it as neighbor chosen		// to simpliy processing of this ant at router module		int previousNode = (current->topOfStack()).nodeAddress;		current->setNeighborChosen(previousNode);		antStackEntry entry;		entry.nodeAddress = myAddress;		entry.nodeEntranceTime = simTime();				// now do the recording keep values by pushing the		// entrance time and nodeID onto the stack.		// for quick checking of cycles, we keep another		// array for the nodes being visited by the ant.		current->addToVisitedNodes( myAddress );		current->addToCycleNodes( entry );	}		else	{		// Determine if ant were generated at this node		findSourceForAnt( current );		if(nTcb.source == ROUTER)		{			//3. doForwardAntActions()			antDeleted = doForwardAntActions();		}		else if (nTcb.source == ANT_GEN)		{			selectLinks();		}	}	// Finally now send this forward ant back to the router	if( !antDeleted )	{		int hops = current->getHops();
		hops++;		current->setHops(hops);		current->setSourceModule( (int) ANT_NEST);		send(current,"toRouter");	}}void antNest::processBackwardAnts(){	// Update Routing Table	doBackwardAntActions();	if(current->getSourceNode() == myAddress)	{		// send to the sink		send(current,"toAntSink");			}	else	{		// set the source of this ant		current->setSourceModule( (int) ANT_NEST);		send(current,"toRouter");	}}void antNest::doBackwardAntActions(){	int dest = current->getDestNode();	updateRoutingTable(dest);}void antNest::selectLinks(){		int destNode = current->getDestNode();		int nextHop = 0;		int fLinks = 0; // number of feasible links		nodeProbPair *goodnessProbability = new nodeProbPair[numNeighbors];		// calculate goodness for feasible links		goodnessForFeasibleLinks(destNode,fLinks,goodnessProbability);		int node = 0;#ifdef original		if( explorationProbablity > 0 && 			(node = selectLinkInRandomUniformWay()) != UNIFORM_RANDOM_SELECTION_FAILED)#else // GIANNI		double prob = uniform(0.0, 1.0);		if( explorationProbablity > prob && 			(node = selectLinkInRandomUniformWay()) != UNIFORM_RANDOM_SELECTION_FAILED)#endif		{						nextHop = node;		}	  // Select the outlink in a probabilistic proportional way according to the 	  // computed goodness estimates goodnessProbability. The selection is made among 	  // the nodes not visited yet. If all the nodes have been already visited, 	  // the one with the highest goodness estimate is deterministically selected#ifdef original		else if (fLinks == numNeighbors) // all neighbors visited		{			nextHop = selectLinkWithHighestGoodness(fLinks, goodnessProbability);		}#else// GIANNI		else if (fLinks == numNeighbors) // all neighbors visited		{		  node = selectLinkInRandomUniformWay();		  if( node == UNIFORM_RANDOM_SELECTION_FAILED )		    node =  ptr->findNeighborAtIndex(0);		  nextHop = node;		}#endif		else		{#ifdef original		  double binProb = uniform(0.0,1.0);		  if( binProb <= 0.75)		    {		      nextHop = selectLinkInRandomPropotionalWay(fLinks, goodnessProbability);		      		    }		  else		    {		      nextHop = selectLinkWithHighestGoodness(fLinks, goodnessProbability);		    }#else//GIANNI		  double binProb = uniform(0.0,1.0);		  nextHop = selectLinkInRandomPropotionalWay(fLinks, goodnessProbability);#endif		}		delete[] goodnessProbability;				antStackEntry entry;		entry.nodeAddress = myAddress;		entry.nodeEntranceTime = simTime();				// now do the recording keep values by pushing the		// entrance time and nodeID onto the stack.		// for quick checking of cycles, we keep another		// array for the nodes being visited by the ant.		current->setNeighborChosen( nextHop );		current->addToVisitedNodes( myAddress );		current->addToCycleNodes( entry );}bool antNest::doForwardAntActions(){	// check if this ant reached age or hop limits	if( !checkIfAntReachedAgeOrHopsLimitThenDelete())	{		if( !checkIfAntIsObsoleteThenDelete() ) 		{			selectLinks();			return false;		}	}	antsDeleted++;	sPtr->incrTotalAntsDeleted();
	return true;	// do nothing as this ant has been deleted}#ifdef originalint antNest::selectLinkInRandomUniformWay(){	double prob = uniform(0.0, 1.0);	int index = 0;	int sourceNode = current->getSourceNode();	if ( sourceNode != myAddress)	{		int lastNode = (current->topOfStack()).nodeAddress;		int neighborIndex = ptr->findIndexForNeighbor(lastNode);		if( prob < explorationProbablity)		{			// Do not select the same neighbor from which this ant came			while(( index = intrand( numNeighbors )) == neighborIndex)			{				int neighbor = ptr->findNeighborAtIndex(index);				return neighbor;			}		}	}	else	{		if( prob < explorationProbablity)		{			int index = intrand( numNeighbors );			int neighbor = ptr->findNeighborAtIndex(index);			return neighbor;		}	}	return UNIFORM_RANDOM_SELECTION_FAILED;}#else// GIANNIint antNest::selectLinkInRandomUniformWay(){  int index = 0;    int sourceNode = current->getSourceNode();    if( numNeighbors == 1 )    return UNIFORM_RANDOM_SELECTION_FAILED;  if ( sourceNode != myAddress)    {      int lastNode = (current->topOfStack()).nodeAddress;            int lastNodeNeighborIndex = ptr->findIndexForNeighbor(lastNode);            // Do not select the same neighbor from which this ant came      while(1)	{	  index = intrand( numNeighbors ); 	  	  if(index != lastNodeNeighborIndex)	    return ptr->findNeighborAtIndex(index);	}    }  else    {      int index = intrand( numNeighbors );      return ptr->findNeighborAtIndex(index);    }    return UNIFORM_RANDOM_SELECTION_FAILED;}#endifint antNest::selectLinkInRandomUniformWayAntsGeneratedAtThisNode(){	int neighbor;	do	{		// Do not select the node that generated current ant as next hop		int index =  intrand( numNeighbors);		neighbor = ptr->findNeighborAtIndex(index);	} while ( neighbor == myAddress);	return neighbor;		}int antNest::selectLinkInRandomPropotionalWay(int count, nodeProbPair *goodnessProb){	double incrProb = 0.0;	int selectedNeighbor = -2;	int neighbor;	double binProb = uniform(0.0, 1.0);	int lastNode;	int sourceNode = current->getSourceNode();		// if ant is origanted at this node, so it would not be having	// any last node hence we could set it to currentNode. In this	// way neighbor != lastNode will be true in any case	if( sourceNode != myAddress)	{		int lastNode = (current->topOfStack()).nodeAddress;	}	else	{		lastNode = myAddress;	}	// we need to ensure that we do not send the ant to the same node 	// from where it arrived. 	for(int i = 0; i < numNeighbors; i++)	{		int k = goodnessProb[i].neighbor;		if ( k != -1)		{					incrProb += goodnessProb[i].value;			neighbor = goodnessProb[i].neighbor;			if( binProb <= incrProb && neighbor != lastNode) 			{				return neighbor;			}		}	}	for(int j = 0; j < numNeighbors; j++)	{		int k = goodnessProb[j].neighbor;		if ( k != -1 && k != lastNode)		{					selectedNeighbor = k;			break;		}	}		if(selectedNeighbor == -2)	{		selectedNeighbor = lastNode;	}	return selectedNeighbor;}int antNest::selectLinkWithHighestGoodness(int count, nodeProbPair *goodnessProb){	nodeProbPair temp;	temp.value = 0.0;	temp.neighbor = -2;	int lastNode;	int sourceNode = current->getSourceNode();		// if ant is origanted at this node, so it would not be having	// any last node hence we could set it to currentNode. In this	// way neighbor != lastNode will be true in any case	if( sourceNode != myAddress)	{		 lastNode = (current->topOfStack()).nodeAddress;	}	else	{		lastNode = myAddress;	}	for(int i = 0; i < numNeighbors; i++)	{		int k = goodnessProb[i].neighbor;		if ( k != -1 && k != lastNode)		{			if ( goodnessProb[i].value > temp.value )			{				temp.value = goodnessProb[i].value;				temp.neighbor = goodnessProb[i].neighbor;							}		}	}	if(temp.neighbor == -2)	{		temp.neighbor = lastNode;	}	return temp.neighbor;}void antNest::goodnessForFeasibleLinks(int destNode, int& count, nodeProbPair *goodnessProb){	int feasibleNeighbors = 0;	double normGoodness = 0.0;	nodeProbPair *neighbors = new nodeProbPair[numNeighbors];	heuristicCorrectionFactor(feasibleNeighbors, neighbors);	count = feasibleNeighbors;	for(int i = 0; i < numNeighbors ; i++)	{		int k =  neighbors[i].neighbor;		if ( k != -1)		{			int neighbor = neighbors[i].neighbor;			double Pnd = ptr->getProb(destNode,neighbor);					// Pnd + aplha * Ln			double ln = neighbors[i].value;			double Pgoodness = Pnd + queueWeight * ln;			normGoodness += Pgoodness;		}	}	for(int j = 0; j < numNeighbors ; j++)	{		int k = neighbors[j].neighbor;		if ( k != -1)		{			int neighbor = neighbors[j].neighbor;					double Pnd = ptr->getProb(destNode,neighbor);			// Pnd + aplha * Ln			double ln = neighbors[j].value;			double Pgoodness = Pnd + queueWeight * ln;			goodnessProb[j].neighbor = neighbor;			goodnessProb[j].value = Pgoodness / normGoodness;		}		else		{			goodnessProb[j].neighbor = k;		}	}	delete[] neighbors;}// ln = 1 - qn/sum(qn

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品乱码久久久久久久久| 欧美浪妇xxxx高跟鞋交| 久久久91精品国产一区二区精品| 看片网站欧美日韩| 久久精品视频网| 国产精品77777竹菊影视小说| 国产偷国产偷精品高清尤物| 毛片一区二区三区| 久久夜色精品一区| 成人av电影观看| 亚洲黄色小说网站| 欧美一区二区在线免费观看| 久久99精品国产麻豆婷婷| 久久亚洲精精品中文字幕早川悠里 | 亚洲中国最大av网站| 欧美日韩国产另类不卡| 青青青伊人色综合久久| 2023国产一二三区日本精品2022| 成人国产免费视频| 亚洲自拍偷拍麻豆| 日韩美女视频一区二区在线观看| 国产福利一区二区三区视频在线| 中文字幕一区在线观看| 欧美日韩一区 二区 三区 久久精品 | 精品一区二区三区av| 国产午夜精品久久久久久免费视| 色悠悠久久综合| 蜜桃av一区二区三区| 精品一区二区久久久| 国产精品毛片a∨一区二区三区| 99精品视频在线播放观看| 亚洲一区二区三区国产| 欧美性色黄大片| 午夜精品免费在线观看| 久久午夜羞羞影院免费观看| 色噜噜久久综合| 久久er精品视频| 色综合久久综合中文综合网| 亚洲成精国产精品女| www.日韩av| 成人美女在线观看| 成人免费视频免费观看| 国产91丝袜在线播放| 粉嫩一区二区三区性色av| 欧美日韩国产乱码电影| 欧美亚洲一区三区| 欧美日韩中文精品| 91精品国产色综合久久ai换脸| 欧美电影在线免费观看| 欧美一区二区播放| 精品成人a区在线观看| 久久综合狠狠综合久久激情| 久久综合丝袜日本网| 国产亚洲成aⅴ人片在线观看| 国产日韩精品一区二区三区| 亚洲国产成人在线| 亚洲色图视频网| 亚洲伊人伊色伊影伊综合网| 亚洲成人免费看| 免费观看在线综合| 国产精品自在在线| 99久久久国产精品| 欧美日韩在线播放| 欧美一级理论片| 国产日韩欧美精品综合| 最近日韩中文字幕| 亚洲午夜av在线| 喷白浆一区二区| 国产福利精品导航| 91国偷自产一区二区使用方法| 欧美日韩国产另类一区| 精品日韩一区二区三区免费视频| 国产香蕉久久精品综合网| 日韩理论片一区二区| 亚洲成a天堂v人片| 国产一二三精品| 色八戒一区二区三区| 欧美一区永久视频免费观看| 国产日韩欧美综合一区| 亚洲一区二区黄色| 国产一区二区三区国产| 91成人免费电影| 精品国产电影一区二区| 亚洲青青青在线视频| 日韩av网站免费在线| 丁香婷婷综合色啪| 欧美日韩精品一区视频| 欧美经典一区二区三区| 香蕉成人啪国产精品视频综合网| 国产一区二区免费在线| 欧洲另类一二三四区| 精品国产乱码久久久久久久久| 亚洲丝袜另类动漫二区| 久久 天天综合| 欧美成人伊人久久综合网| 欧美激情一区不卡| 秋霞电影网一区二区| 成人免费观看av| 日韩欧美在线123| 亚洲视频在线一区| 国产一区二区不卡| 欧美蜜桃一区二区三区| 国产精品国产自产拍在线| 日韩成人伦理电影在线观看| 97精品国产露脸对白| 欧美videos大乳护士334| 一区二区三区在线播| 成人自拍视频在线| 欧美成人一级视频| 亚洲一区免费视频| 99久久久精品| 国产欧美久久久精品影院| 蜜臀av性久久久久蜜臀aⅴ四虎| 在线看国产一区二区| 国产精品嫩草影院av蜜臀| 久久精品国产精品青草| 欧美日韩高清影院| 亚洲狼人国产精品| 99精品国产热久久91蜜凸| 国产欧美一二三区| 国产一区视频在线看| 欧美一区二区国产| 天天影视色香欲综合网老头| 色哟哟亚洲精品| 亚洲欧洲99久久| 波多野结衣在线一区| 久久久蜜桃精品| 加勒比av一区二区| 日韩精品在线一区| 久久狠狠亚洲综合| 日韩免费视频一区| 美女网站色91| 欧美成人性战久久| 毛片一区二区三区| 欧美成人猛片aaaaaaa| 麻豆91精品视频| 欧美精品一区二区三区久久久 | 日韩一区在线播放| a在线播放不卡| 亚洲图片你懂的| 99精品国产一区二区三区不卡| 国产精品久久久久天堂| 成人一区二区三区| 国产精品剧情在线亚洲| eeuss国产一区二区三区| 国产精品理论在线观看| 91亚洲永久精品| 一区二区激情视频| 欧美剧在线免费观看网站| 首页欧美精品中文字幕| 日韩欧美精品在线视频| 国内精品在线播放| 欧美国产日韩在线观看| 91视频.com| 亚洲高清免费一级二级三级| 91精品免费在线| 九一九一国产精品| 国产精品免费aⅴ片在线观看| www.亚洲人| 午夜精品久久久久| 精品日产卡一卡二卡麻豆| 国产乱码一区二区三区| 国产精品美女久久久久久久| 91在线小视频| 日韩精品一二区| 久久亚区不卡日本| 91丨九色丨国产丨porny| 亚洲国产wwwccc36天堂| 日韩欧美激情一区| 成人免费不卡视频| 亚洲成人av资源| 久久一日本道色综合| 91亚洲精品久久久蜜桃| 日韩电影免费一区| 国产欧美一区二区三区网站| 色国产综合视频| 色婷婷久久久亚洲一区二区三区 | 中文字幕国产精品一区二区| 91福利在线播放| 精品在线亚洲视频| 亚洲人成亚洲人成在线观看图片 | 国产成人av福利| 亚洲综合色噜噜狠狠| 欧美mv日韩mv国产网站| 91在线视频播放| 开心九九激情九九欧美日韩精美视频电影 | 欧美老肥妇做.爰bbww| 国产不卡视频在线观看| 亚洲成人精品一区| 国产精品午夜电影| 日韩一区二区三区免费看| 波多野结衣在线aⅴ中文字幕不卡| 日日夜夜精品免费视频| 国产精品精品国产色婷婷| 日韩三级中文字幕| 欧美主播一区二区三区美女| 国产精品一区二区三区网站| 天堂成人国产精品一区| 亚洲欧洲日本在线| 久久女同精品一区二区|