OverSim
StrategySimplifyCoords Class Reference

#include <StrategySimplifyCoords.h>

Inheritance diagram for StrategySimplifyCoords:
AbstractSendStrategy

Public Member Functions

 StrategySimplifyCoords ()
 .cc
virtual ~StrategySimplifyCoords ()
virtual GlobalViewBuilderCallgetCoordinateMessage ()
virtual void handleCoordinateRpcCall (GlobalViewBuilderCall *globalViewBuilderCall)
virtual std::string getStrategyDataStatus ()
 return a short status of the running send strategy
virtual std::vector
< std::vector< double > > 
getGlobalViewData ()
 return the decodes global View Data
virtual void setMyCoordinates (const AbstractNcsNodeInfo &ncsInfo)
virtual void cleanUpCoordData (const treeNodeMap &currentTreeChildNodes)
 cleanup the coordinate map and remove data of nodes which are not longer in the branch
virtual std::string getStrategyCombinedParams ()
 return a string of the currently used strategy params
- Public Member Functions inherited from AbstractSendStrategy
 AbstractSendStrategy ()
 .cc
virtual ~AbstractSendStrategy ()
virtual void initialize (GlobalViewBuilder *globalViewBuilder)
 set a pointer to the neighborCache to access the optional parameters for the strategies
virtual void initializeStrategy ()
 stub method to initialize the concrete strategy
virtual void setThisNode (const NodeHandle thisNode)
 Set the Nodehandle of the own node to identify the own coordinates.

Protected Types

typedef std::pair
< TransportAddress,
simpleCoordCountMap
nodeCoordData
typedef UNORDERED_MAP
< TransportAddress,
simpleCoordCountMap,
TransportAddress::hashFcn
branchCoordDataMap

Protected Member Functions

void setBranchCoordinates (const NodeHandle &node, simpleCoordCountMap countMap)
 set the coordCountMap delivered by a child to our coordCountMap
SimpleCoordinate simplify (std::vector< double > coordVector)
 simplify every dimension of the given coordVector by the simplifyFactor
std::vector< double > decode (SimpleCoordinate simplifiedVector)
 decode the simplified vector to the original interval
const simpleCoordCountMap getCombinedCoordCountMap ()

Protected Attributes

branchCoordDataMap coordData
- Protected Attributes inherited from AbstractSendStrategy
NodeHandle thisNode
GlobalViewBuilderglobalViewBuilder
int lastSendCount
 the quantity of coordinates sent by last message

Detailed Description

Definition at line 37 of file StrategySimplifyCoords.h.

Member Typedef Documentation

Constructor & Destructor Documentation

StrategySimplifyCoords::StrategySimplifyCoords ( )

.cc

Author
Daniel Lienert

Definition at line 27 of file StrategySimplifyCoords.cc.

{
// TODO Auto-generated constructor stub
}
StrategySimplifyCoords::~StrategySimplifyCoords ( )
virtual

Definition at line 31 of file StrategySimplifyCoords.cc.

{
// TODO Auto-generated destructor stub
}

Member Function Documentation

void StrategySimplifyCoords::cleanUpCoordData ( const treeNodeMap currentTreeChildNodes)
virtual

cleanup the coordinate map and remove data of nodes which are not longer in the branch

Reimplemented from AbstractSendStrategy.

Definition at line 142 of file StrategySimplifyCoords.cc.

{
branchCoordDataMap::const_iterator coordMapIterator = coordData.begin();
while(coordMapIterator != coordData.end()) {
if(currentTreeChildNodes.find(coordMapIterator->first) == currentTreeChildNodes.end() && coordMapIterator->first != thisNode) {
coordData.erase(coordMapIterator);
}
coordMapIterator++;
}
}
std::vector< double > StrategySimplifyCoords::decode ( SimpleCoordinate  simplifiedVector)
protected

decode the simplified vector to the original interval

Parameters
std::vector<int>simplifiedVector
Returns
std::vector<double> vector in original intervall

Definition at line 175 of file StrategySimplifyCoords.cc.

Referenced by getGlobalViewData().

{
int simplifyFactor = globalViewBuilder->parProxy("gvbStrategySimplifyCoordsFactor");
double dimension = 0.0;
std::vector<int>::const_iterator dimIterator = simplifiedVector.coordData.begin();
std::vector<double> outVector;
while(dimIterator != simplifiedVector.coordData.end()) {
dimension = static_cast<double>(*dimIterator) / static_cast<double>(simplifyFactor);
outVector.push_back(dimension);
dimIterator++;
}
return outVector;
}
const simpleCoordCountMap StrategySimplifyCoords::getCombinedCoordCountMap ( )
protected

Definition at line 66 of file StrategySimplifyCoords.cc.

Referenced by getCoordinateMessage(), getGlobalViewData(), and getStrategyDataStatus().

{
simpleCoordCountMap combinedCoordMap;
simpleCoordCountMap branchCoordMap;
branchCoordDataMap::const_iterator coordDataIterator = coordData.begin();
while(coordDataIterator != coordData.end()) {
branchCoordMap = coordDataIterator->second;
simpleCoordCountMap::iterator bSCMapIterator = branchCoordMap.begin();
while(bSCMapIterator != branchCoordMap.end()) {
if(combinedCoordMap.find(bSCMapIterator->first) == combinedCoordMap.end()) {
combinedCoordMap.insert(simpleCoordPair(bSCMapIterator->first, bSCMapIterator->second));
} else {
combinedCoordMap.find(bSCMapIterator->first)->second += bSCMapIterator->second;
}
bSCMapIterator++;
}
coordDataIterator++;
}
return combinedCoordMap;
}
GlobalViewBuilderCall * StrategySimplifyCoords::getCoordinateMessage ( )
virtual

Reimplemented from AbstractSendStrategy.

Definition at line 53 of file StrategySimplifyCoords.cc.

{
SimpleCoordStrategyCall* msg = new SimpleCoordStrategyCall("SimpleCoordStrategyCall");
SimpleCoordDataContainer tmpSimpleCoordContainer;
tmpSimpleCoordContainer.coordData = getCombinedCoordCountMap();
msg->setCoordData(tmpSimpleCoordContainer);
msg->setBitLength(SIMPLECOORDSTRATEGYCALL_L(msg));
return msg;
}
std::vector< std::vector< double > > StrategySimplifyCoords::getGlobalViewData ( )
virtual

return the decodes global View Data

Implements AbstractSendStrategy.

Definition at line 194 of file StrategySimplifyCoords.cc.

{
simpleCoordCountMap::const_iterator coordIterator = coordMap.begin();
std::vector<std::vector<double> > globalViewData;
int i;
while(coordIterator != coordMap.end()) {
for(i=1; i<=coordIterator->second; i++) {
globalViewData.push_back(decode(coordIterator->first));
}
coordIterator++;
}
return globalViewData;
}
std::string StrategySimplifyCoords::getStrategyCombinedParams ( )
virtual

return a string of the currently used strategy params

Implements AbstractSendStrategy.

Definition at line 131 of file StrategySimplifyCoords.cc.

{
std::stringstream tempStr;
tempStr << globalViewBuilder->parProxy("gvbSendStrategy").stdstringValue();
tempStr << "/";
tempStr << globalViewBuilder->parProxy("gvbStrategySimplifyCoordsFactor").longValue();
return tempStr.str();
}
std::string StrategySimplifyCoords::getStrategyDataStatus ( )
virtual

return a short status of the running send strategy

Reimplemented from AbstractSendStrategy.

Definition at line 101 of file StrategySimplifyCoords.cc.

{
std::stringstream tempStr;
simpleCoordCountMap::const_iterator coordIterator = coordMap.begin();
while(coordIterator != coordMap.end()) {
tempStr << "(";
std::vector<int> vDim = coordIterator->first.coordData;
std::vector<int>::const_iterator vDimIterator = vDim.begin();
while(vDimIterator != vDim.end()) {
tempStr << (*vDimIterator) << ";";
vDimIterator++;
}
tempStr << "):" << coordIterator->second << "|";
coordIterator++;
}
return tempStr.str();
}
void StrategySimplifyCoords::handleCoordinateRpcCall ( GlobalViewBuilderCall globalViewBuilderCall)
virtual

Reimplemented from AbstractSendStrategy.

Definition at line 95 of file StrategySimplifyCoords.cc.

{
SimpleCoordStrategyCall* simpleCoordStrategyCall = dynamic_cast<SimpleCoordStrategyCall*>(globalViewBuilderCall);
setBranchCoordinates(simpleCoordStrategyCall->getSrcNode(), simpleCoordStrategyCall->getCoordData().coordData);
}
void StrategySimplifyCoords::setBranchCoordinates ( const NodeHandle node,
simpleCoordCountMap  countMap 
)
protected

set the coordCountMap delivered by a child to our coordCountMap

Parameters
nodeNodeHandle assign the map to this node
countMapsimpleCoordCountMap the map of the node

Definition at line 44 of file StrategySimplifyCoords.cc.

Referenced by handleCoordinateRpcCall(), and setMyCoordinates().

{
if(coordData.find(node) != coordData.end()) {
coordData.find(node)->second = countMap;
} else {
coordData.insert(nodeCoordData(node, countMap));
}
}
void StrategySimplifyCoords::setMyCoordinates ( const AbstractNcsNodeInfo ncsInfo)
virtual

Reimplemented from AbstractSendStrategy.

Definition at line 35 of file StrategySimplifyCoords.cc.

{
std::vector<double> tmpDimVector = ncsInfo.getCoords();
simpleCoordCountMap tmpCountMap;
tmpCountMap.insert(simpleCoordPair(simplify(tmpDimVector),1));
setBranchCoordinates(thisNode, tmpCountMap); // i am my own branch here ...
}
SimpleCoordinate StrategySimplifyCoords::simplify ( std::vector< double >  coordVector)
protected

simplify every dimension of the given coordVector by the simplifyFactor

Parameters
std::vector<double>coordvector original double vector
Returns
std::vector<int> simplified vector

Definition at line 158 of file StrategySimplifyCoords.cc.

Referenced by setMyCoordinates().

{
int simplifyFactor = globalViewBuilder->parProxy("gvbStrategySimplifyCoordsFactor");
int simplified = 0;
SimpleCoordinate outVector;
std::vector<double>::const_iterator dimIterator = coordVector.begin();
while(dimIterator != coordVector.end()) {
simplified = static_cast<int>((*dimIterator)*simplifyFactor + 0.5);
outVector.coordData.push_back(simplified);
dimIterator++;
}
return outVector;
}

Member Data Documentation

branchCoordDataMap StrategySimplifyCoords::coordData
protected

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