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

📄 mas_df.cpp

📁 Bubble Oscillation Algorithm. It is used to implement balancing load traffic, which is similar to wh
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////
//  Title:        Geographic Load Balancing for Cellular Networks 
//		          by emulating the behavior of air bubbles 
//
//  Description:  This project is for dynamically balancing the traffic load 
//                  over a cellular network with fully adaptive antennas by 
//		    emulating the behaviours of a bubble array. Since 
//                  we assume fully adaptive base station antenna in this  
//                  version, antenna agent and simulator are not needed. 
//
//  Copyright:    Copyright (c) 2003
//  Company:      Elec. Eng. Dept., Queen Mary, University of London
//  @author       Lin Du (lin.du@elec.qmul.ac.uk)
//  @version      1.0
//
//////////////////////////////////////////////////////////////////////

// MAS_DF.cpp: implementation of the MAS_DF class.
//
//////////////////////////////////////////////////////////////////////

#include "MAS_DF.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MAS_DF::MAS_DF() {
  BSD_srandom( (unsigned long)time(NULL) );
//  BSD_srandom(1000);
  uniqueID = 1;
}

MAS_DF::~MAS_DF() {
}

//////////////////////////////////////////////////////////////////////
// Return a global unique ID, used for message ID, from 1-59999
//////////////////////////////////////////////////////////////////////
U_INT32 MAS_DF::getUniqueID() {
  if (uniqueID > 8000000) // the max size of a map is 8134407.
    uniqueID = 1;
  else
    uniqueID++;

  return uniqueID;
}

//////////////////////////////////////////////////////////////////////
// set the uniqueID, used for recovering from previous saved states
//////////////////////////////////////////////////////////////////////
void MAS_DF::setUniqueID(U_INT32 uniqueID) {
  this->uniqueID = uniqueID;
}

//////////////////////////////////////////////////////////////////////
// return testbed
//////////////////////////////////////////////////////////////////////
TestBed *MAS_DF::getTestBed() const {
  return tb;
}

//////////////////////////////////////////////////////////////////////
// find the base station object by its ID
//////////////////////////////////////////////////////////////////////
BaseStation *MAS_DF::findBS(int ID) {
  for ( int i=0; i<BS_NUMBER; i++ ) {
    if (tb->bs[i]->getID() == ID) 
      return tb->bs[i];
  }
  return NULL;
}

//////////////////////////////////////////////////////////////////////
// find the traffic unit object by its ID
//////////////////////////////////////////////////////////////////////
TrafficUnit *MAS_DF::findTU(int ID) {
	if (tuList.size() == 0) {   // first time invoke this method
		for ( long i=0; i<TU_NUMBER; i++ ) {
			tuList.insert(P_TU_MAP_INT::value_type(tb->tu[i]->getID(), tb->tu[i])); 
		}
	}
	else {
		P_TU_MAP_INT::iterator it = tuList.find(ID);
		if (it != tuList.end()) {
			return it->second;
		}
	}
  return NULL;
}

⌨️ 快捷键说明

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