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

📄 evaluator.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
//
//////////////////////////////////////////////////////////////////////

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

#include "Evaluator.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Evaluator::Evaluator() {
}

Evaluator::Evaluator(BSAgent *agent) {
  this->agent = agent;
  // local cache for global parameters
  W0 = agent->df->parameter.W0;
  W1 = agent->df->parameter.W1;
  W2 = agent->df->parameter.W2;
  W3 = agent->df->parameter.W3;
}

Evaluator::~Evaluator() {
}

//////////////////////////////////////////////////////////////////////
// Calculate the repulsion force from BS to TU.
//		So it points to the BS
//
// Please refer to our paper
//
//////////////////////////////////////////////////////////////////////
Point Evaluator::getRepulsionForce(const TrafficUnit &tu) const {
	double utility;
  // Calculate the distance and angle to this base station
  double dist1 = agent->bs->distance(tu);	
	double ang = agent->bs->angle (tu);
	if (dist1 < MIN_DISTANCE) {		// must server if the tu is with the circle of MIN_DISTANCE
		utility = INFINITY;
	}
	else {	// otherwise, check the utitlity value to decide if serve or not
		// Calculate the utilisation (load) of prospective helper
		U_INT16 nbrID, helperID;
		nbrID = TestBed::ang2index(ang);  
		// User the closest neighbour as helper in this version.
		helperID = agent->getNeighbourID( nbrID ); 

		// Set the default value for difficulty. so they will be very high if there is no neighbour
		double load1 = INFINITY;
		double dist2 = INFINITY; 
		double load2 = INFINITY; 
		// Check if the helper is on the boundary
		if ( helperID != NULL ) {
			BaseStation *bs = agent->df->findBS( helperID );
			dist2 = bs->distance(tu);		
			load1 = agent->bs->getNbrDemand(nbrID);
			load2 = bs->getNbrDemand(nbrID);      // use load2 as a chain to the next sector along the line from BS to TU.
		}

		// combine them.
		utility = (MAX_DISTANCE - dist1) + W0 * (load1);										// U0
//	  double util = (-dist1) + W0 * (load1) + W1 * (load2);			// U1
	//  double util = (-dist1) + W0 * (load1) + W1 * (dist2);			// U2
	//  double util = (-dist1) + W0 * (load1) + W1 * (load2) + W2 * (dist2);		// U3
	//  double util = ( W0 * (load1) + (load2) )/pow(dist1/dist2, W1);
//	  utility = (W0*load1 + load2)/(dist1*dist1);										// U4
	//  utility = W0/(dist1*dist1);										// U5
	}

	// convert it to a vector and return it
	return Point(utility*cos(Point::deg2Rad(ang)), utility*sin(Point::deg2Rad(ang)));
}

//////////////////////////////////////////////////////////////////////
// Calculate the attraction force from Blocked TU(vacuum) to servedTU.
//		So it points to the vacuum
//
// Please refer to our paper
//
//////////////////////////////////////////////////////////////////////
Point Evaluator::getAttractionForce(const TrafficUnit &targetTU, const TrafficUnit &vacuumTU) const {
	double utility, ang;
  // Calculate the distance to this base station
//  double dist = targetTU.distance(vacuumTU);	

  // calculate the utility value
//  utility = W3*vacuumTU.getDemand()/(dist*dist);			// U0
  utility = W3*vacuumTU.getDemand();										// U1

	if (targetTU != vacuumTU) { // if they are not the same one, point the vector from targetTU to vacuumTU
		ang = targetTU.angle (vacuumTU);
	}
	else {		// if they are the same one, point the vector from BS to vacuumTU, so increase the blocked TU
    ang = agent->bs->angle (vacuumTU);
	}

	// convert it to a vector and return it
	return Point(utility*cos(Point::deg2Rad(ang)), utility*sin(Point::deg2Rad(ang)));
}

⌨️ 快捷键说明

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