OverSim
ConnectivityProbeQuon Class Reference

#include <ConnectivityProbeQuon.h>

Public Member Functions

void initialize ()
void handleMessage (cMessage *msg)
 ~ConnectivityProbeQuon ()

Private Member Functions

void extractTopology ()
void resetTopologyNodes ()
unsigned int getComponentSize (OverlayKey key)

Private Attributes

std::fstream pltNetwork
std::fstream pltData
std::fstream pltVector
simtime_t probeIntervall
simtime_t plotIntervall
simtime_t startPlotTime
simtime_t plotPeriod
bool plotConnections
bool plotBindings
bool plotMissing
cMessage * probeTimer
cMessage * plotTimer
QuonTopology Topology
GlobalStatisticsglobalStatistics
cOutVector cOV_NodeCount
cOutVector cOV_MaximumComponent
cOutVector cOV_MaxConnectivity
cOutVector cOV_ZeroMissingNeighbors
cOutVector cOV_AverageMissingNeighbors
cOutVector cOV_MaxMissingNeighbors
cOutVector cOV_AverageDrift

Detailed Description

Definition at line 48 of file ConnectivityProbeQuon.h.

Constructor & Destructor Documentation

ConnectivityProbeQuon::~ConnectivityProbeQuon ( )

Definition at line 301 of file ConnectivityProbeQuon.cc.

{
// destroy self timer messages
cancelAndDelete(probeTimer);
cancelAndDelete(plotTimer);
}

Member Function Documentation

void ConnectivityProbeQuon::extractTopology ( )
private

Definition at line 265 of file ConnectivityProbeQuon.cc.

Referenced by handleMessage().

{
for(int i=0; i<=simulation.getLastModuleId(); i++) {
cModule* module = simulation.getModule(i);
if(module && dynamic_cast<Quon*>(module)) {
Quon* quonp = check_and_cast<Quon*>(module);
if(quonp->getState() == QREADY) {
Topology.insert(std::make_pair(quonp->getKey(), temp));
}
}
}
}
unsigned int ConnectivityProbeQuon::getComponentSize ( OverlayKey  key)
private

Definition at line 286 of file ConnectivityProbeQuon.cc.

Referenced by handleMessage().

{
QuonTopology::iterator itEntry = Topology.find(key);
if(itEntry != Topology.end() && itEntry->second.visited == false) {
int count = 1;
itEntry->second.visited = true;
Quon* quonp = itEntry->second.getModule();
for(QuonSiteMap::iterator itSites = quonp->Sites.begin(); itSites != quonp->Sites.end(); ++itSites) {
count += getComponentSize(itSites->first);
}
return count;
}
return 0;
}
void ConnectivityProbeQuon::handleMessage ( cMessage *  msg)

Definition at line 75 of file ConnectivityProbeQuon.cc.

{
// fill topology with all QUONP modules
if(Topology.size() == 0) {
return;
}
// catch self timer messages
if(msg->isName("probeTimer")) {
//reset timer
cancelEvent(probeTimer);
scheduleAt(simTime() + probeIntervall, msg);
unsigned int maxComponent = 0;
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
unsigned int count = getComponentSize(itTopology->second.getModule()->getKey());
if(count > maxComponent) {
maxComponent = count;
}
if(count == Topology.size()) {
break;
}
}
cOV_NodeCount.record((double)Topology.size());
cOV_MaximumComponent.record((double)maxComponent);
cOV_MaxConnectivity.record((double)maxComponent * 100.0 / (double)Topology.size());
globalStatistics->addStdDev("ConnectivityProbe: max connectivity", (double)maxComponent * 100.0 / (double)Topology.size());
);
int mnMax = 0;
int mnZero = 0;
int driftCount = 0;
double mnAverage = 0.0;
double drift = 0.0;
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
QuonAOI AOI(itTopology->second.getModule()->getPosition(), itTopology->second.getModule()->getAOI());
int missing = 0;
for(QuonTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
if(itI != itTopology && AOI.collide(itI->second.getModule()->getPosition())) {
QuonSiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getKey());
if(currentSite == itTopology->second.getModule()->Sites.end()) {
++missing;
}
else {
drift += sqrt(currentSite->second->position.distanceSqr(itI->second.getModule()->getPosition()));
++driftCount;
}
}
}
mnAverage += missing;
if(mnMax < missing) {
mnMax = missing;
}
if(missing == 0) {
++mnZero;
}
}
mnAverage /= (double)Topology.size();
if(driftCount > 0) {
drift /= (double)driftCount;
}
cOV_ZeroMissingNeighbors.record((double)mnZero);
globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size());
globalStatistics->addStdDev("ConnectivityProbe: average drift", drift);
);
cOV_AverageMissingNeighbors.record(mnAverage);
cOV_MaxMissingNeighbors.record((double)mnMax);
cOV_AverageDrift.record(drift);
}
else if(msg->isName("plotTimer")) {
//reset timer
cancelEvent(plotTimer);
if(plotPeriod == 0.0 || simTime() <= startPlotTime + plotPeriod) {
scheduleAt(simTime() + plotIntervall, msg);
}
bool missingFound = false;
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
QuonAOI AOI(itTopology->second.getModule()->getPosition(), itTopology->second.getModule()->getAOI());
for(QuonTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
if(itI != itTopology && AOI.collide(itI->second.getModule()->getPosition())) {
QuonSiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getKey());
if(currentSite == itTopology->second.getModule()->Sites.end()) {
missingFound = true;
}
}
}
}
}
if(!plotMissing || missingFound) {
int range = (int)Topology.begin()->second.getModule()->getAreaDimension();
std::stringstream oss;
std::string filename;
int simTimeInt, stellen = 1;
simTimeInt = (int)SIMTIME_DBL(simTime());
oss << "plot";
for(int i=0; i<6; i++) {
if(!(simTimeInt / stellen)) {
oss << "0";
}
stellen *= 10;
}
oss << simTimeInt;
// open / write plot file
filename = oss.str() + ".plot";
pltNetwork.open(filename.c_str(), std::ios::out);
pltNetwork << "set xrange [0:" << range << "]" << endl;
pltNetwork << "set yrange [0:" << range << "]" << endl;
pltNetwork << "set nokey" << endl;
// open point file
filename = oss.str() + ".point";
pltData.open(filename.c_str(), std::ios::out);
pltNetwork << "plot '" << filename << "' using 1:2 with points pointtype 7,\\" << endl;
// open vector file
filename = oss.str() + ".arrow";
pltVector.open(filename.c_str(), std::ios::out);
pltNetwork << " '" << filename << "' using 1:2:3:4 with vectors linetype 1" << endl;
pltNetwork.close();
// write point data file
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
pltData << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << endl;
}
pltData.close();
//write arrow data file
if(!plotMissing) {
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
for(QuonSiteMap::iterator itSites = itTopology->second.getModule()->Sites.begin(); itSites != itTopology->second.getModule()->Sites.end(); ++itSites) {
if(plotBindings && itSites->second->type != QBINDING && !itSites->second->softNeighbor) {
continue;
}
QuonTopology::iterator destNode = Topology.find(itSites->second->address.getKey());
if(destNode != Topology.end()) {
Vector2D relPos = destNode->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition();
pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t"
<< relPos.x << "\t" << relPos.y << endl;
}
}
else {
Vector2D relPos = itSites->second->position - itTopology->second.getModule()->getPosition();
pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t"
<< relPos.x << "\t" << relPos.y << endl;
}
}
}
}
else {
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
QuonAOI AOI(itTopology->second.getModule()->getPosition(), itTopology->second.getModule()->getAOI());
for(QuonTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
if(itI != itTopology && AOI.collide(itI->second.getModule()->getPosition())) {
QuonSiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getKey());
if(currentSite == itTopology->second.getModule()->Sites.end()) {
Vector2D relPos = itI->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition();
pltVector << itTopology->second.getModule()->getPosition().x << "\t"
<< itTopology->second.getModule()->getPosition().y << "\t"
<< relPos.x << "\t" << relPos.y << "\t"
<< itTopology->second.getModule()->getParentModule()->getParentModule()->getFullName() << ":"
<< itTopology->second.getModule()->getKey().toString(16) << "\t"
<< itI->second.getModule()->getParentModule()->getParentModule()->getFullName() << ":"
<< itI->second.getModule()->getKey().toString(16) << endl;
}
}
}
}
}
pltVector.close();
}
}
Topology.clear();
}
void ConnectivityProbeQuon::initialize ( )

Definition at line 40 of file ConnectivityProbeQuon.cc.

{
probeIntervall = par("connectivityProbeIntervall");
plotIntervall = par("visualizeNetworkIntervall");
startPlotTime = par("startPlotTime");
plotPeriod = par("plotPeriod");
probeTimer = new cMessage("probeTimer");
plotTimer = new cMessage("plotTimer");
plotConnections = par("plotConnections");
plotBindings = par("plotBindings");
plotMissing = par("plotMissing");
if(probeIntervall > 0.0) {
scheduleAt(simTime() + probeIntervall, probeTimer);
cOV_NodeCount.setName("total node count");
cOV_MaximumComponent.setName("largest connected component");
cOV_MaxConnectivity.setName("connectivity in percent");
cOV_ZeroMissingNeighbors.setName("neighbor-error free nodes");
cOV_AverageMissingNeighbors.setName("average missing neighbors per node");
cOV_MaxMissingNeighbors.setName("largest missing neighbors count");
cOV_AverageDrift.setName("average drift");
}
if(plotIntervall > 0.0) {
if(startPlotTime == 0.0) {
scheduleAt(simTime() + plotIntervall, plotTimer);
}
else {
scheduleAt(simTime() + startPlotTime, plotTimer);
}
}
}
void ConnectivityProbeQuon::resetTopologyNodes ( )
private

Definition at line 279 of file ConnectivityProbeQuon.cc.

Referenced by handleMessage().

{
for(QuonTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
itTopology->second.visited = false;
}
}

Member Data Documentation

cOutVector ConnectivityProbeQuon::cOV_AverageDrift
private

Definition at line 80 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_AverageMissingNeighbors
private

Definition at line 78 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_MaxConnectivity
private

Definition at line 76 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_MaximumComponent
private

Definition at line 75 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_MaxMissingNeighbors
private

Definition at line 79 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_NodeCount
private

Definition at line 74 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeQuon::cOV_ZeroMissingNeighbors
private

Definition at line 77 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

GlobalStatistics* ConnectivityProbeQuon::globalStatistics
private

Definition at line 71 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

bool ConnectivityProbeQuon::plotBindings
private

Definition at line 66 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

bool ConnectivityProbeQuon::plotConnections
private

Definition at line 65 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

simtime_t ConnectivityProbeQuon::plotIntervall
private

Definition at line 62 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

bool ConnectivityProbeQuon::plotMissing
private

Definition at line 67 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

simtime_t ConnectivityProbeQuon::plotPeriod
private

Definition at line 64 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cMessage* ConnectivityProbeQuon::plotTimer
private

Definition at line 69 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), initialize(), and ~ConnectivityProbeQuon().

std::fstream ConnectivityProbeQuon::pltData
private

Definition at line 56 of file ConnectivityProbeQuon.h.

Referenced by handleMessage().

std::fstream ConnectivityProbeQuon::pltNetwork
private

Definition at line 56 of file ConnectivityProbeQuon.h.

Referenced by handleMessage().

std::fstream ConnectivityProbeQuon::pltVector
private

Definition at line 56 of file ConnectivityProbeQuon.h.

Referenced by handleMessage().

simtime_t ConnectivityProbeQuon::probeIntervall
private

Definition at line 61 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

cMessage* ConnectivityProbeQuon::probeTimer
private

Definition at line 68 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), initialize(), and ~ConnectivityProbeQuon().

simtime_t ConnectivityProbeQuon::startPlotTime
private

Definition at line 63 of file ConnectivityProbeQuon.h.

Referenced by handleMessage(), and initialize().

QuonTopology ConnectivityProbeQuon::Topology
private

The documentation for this class was generated from the following files: