Alex Bikfalvi
SimStream Documentation
ModelSelectProbAll.cpp
00001 #include "Headers.h" 00002 #include "ModelSelectProbAll.h" 00003 00004 CModelSelectProbAll::CModelSelectProbAll( 00005 unsigned int numChannels, 00006 unsigned int numLayers, 00007 unsigned int numPeers, 00008 CProb* prob 00009 ) : CModelSelect(numChannels, numLayers, numPeers) 00010 { 00011 this->prob = prob; 00012 } 00013 00014 CModelSelectProbAll::~CModelSelectProbAll() 00015 { 00016 } 00017 00018 CPeer** CModelSelectProbAll::Select(__time time, __uint32 channel, __uint32 child) 00019 { 00020 assert(channel < this->numChannels); 00021 assert(child < this->numPeers); 00022 00023 CPeer* peerChild = &this->peers[child]; 00024 00025 for(__uint32 layer = 0; layer < this->numLayers; layer++) 00026 { 00027 double maxProb = 0; 00028 CPeer* maxPeer = 0; 00029 00030 for(set<CPeer*>::iterator iter = this->index[channel].begin(); iter != this->index[channel].end(); iter++) 00031 { 00032 if(!this->IsResult(*iter, layer)) 00033 { 00034 if(peerChild->VerifyParent(channel, layer, *iter)) 00035 { 00036 double prob = this->prob->Prob((*iter)->Elapsed(time, channel), peerChild->Elapsed(time, channel)); 00037 if(maxProb < prob) 00038 { 00039 maxProb = prob; 00040 maxPeer = *iter; 00041 } 00042 } 00043 } 00044 } 00045 00046 this->result[layer] = maxPeer; 00047 } 00048 00049 return this->result; 00050 } 00051 00052 CPeer* CModelSelectProbAll::Select(__time time, __uint32 channel, __uint32 layer, __uint32 child) 00053 { 00054 assert(channel < this->numChannels); 00055 assert(child < this->numPeers); 00056 00057 CPeer* peerChild = &this->peers[child]; 00058 00059 double maxProb = 0; 00060 CPeer* maxPeer = 0; 00061 00062 for(set<CPeer*>::iterator iter = this->index[channel].begin(); iter != this->index[channel].end(); iter++) 00063 { 00064 if(!this->IsResult(*iter, layer)) 00065 { 00066 if(peerChild->VerifyParent(channel, layer, *iter)) 00067 { 00068 double prob = this->prob->Prob((*iter)->Elapsed(time, channel), peerChild->Elapsed(time, channel)); 00069 if(maxProb < prob) 00070 { 00071 maxProb = prob; 00072 maxPeer = *iter; 00073 } 00074 } 00075 } 00076 } 00077 00078 return maxPeer; 00079 }
Last updated: February 8, 2011