RepastHPC
2.3.1
|
Grid / Space implementation specialized for the distributed context. More...
#include <SharedBaseGrid.h>
Public Member Functions | |
void | balance () |
SharedBaseGrid (std::string name, GridDimensions gridDims, std::vector< int > processDims, int buffer, boost::mpi::communicator *communicator) | |
Creates a SharedGrid with the specified name. More... | |
virtual const GridDimensions | bounds () const |
Gets the global bounds for this grid. More... | |
virtual const GridDimensions | dimensions () const |
Gets the local bounds of this SharedGrid. More... | |
virtual bool | moveTo (const AgentId &id, const std::vector< GPType > &newLocation) |
Moves the specified agent to the specified location. More... | |
virtual bool | moveTo (const AgentId &id, const Point< GPType > &pt) |
Moves the specified agent to the specified point. More... | |
virtual void | removeAgent (T *agent) |
virtual void | getRequiredAgents (std::set< AgentId > &agentsToTest, std::set< AgentId > &agentsRequired) |
virtual void | getAgentsToPush (std::set< AgentId > &agentsToTest, std::map< int, std::set< AgentId > > &agentsToPush) |
Given a set of agents, gets the agents that this projection implementation must 'push' to other processes. More... | |
virtual void | getInfoExchangePartners (std::set< int > &psToSendTo, std::set< int > &psToReceiveFrom) |
Gets the set of processes with which this Projection exchanges projection info. More... | |
virtual void | getAgentStatusExchangePartners (std::set< int > &psToSendTo, std::set< int > &psToReceiveFrom) |
Gets the set of processes with which this Projection exchanges agent status info- that is, the set of processes from which agents can move to this one or to which they can move when moving from this one. More... | |
virtual void | updateProjectionInfo (ProjectionInfoPacket *pip, Context< T > *context) |
Public Member Functions inherited from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | |
BaseGrid (std::string name, GridDimensions dimensions) | |
Creates a BaseGrid with the specified name and dimensions. More... | |
virtual bool | contains (const AgentId &id) |
Gets whether or not this grid contains the agent with the specified id. More... | |
virtual bool | getLocation (const T *agent, std::vector< GPType > &pt) const |
Gets the location of this agent and puts it in the specified vector. More... | |
virtual bool | getLocation (const AgentId &id, std::vector< GPType > &out) const |
Gets the location of this agent and puts it in the specified vectors. More... | |
virtual T * | getObjectAt (const Point< GPType > &pt) const |
Gets the first object found at the specified point, or NULL if there is no such object. More... | |
virtual void | getObjectsAt (const Point< GPType > &pt, std::vector< T * > &out) const |
Gets all the objects found at the specified point. More... | |
virtual bool | moveTo (const T *agent, const std::vector< GPType > &newLocation) |
Moves the specified agent to the specified location. More... | |
virtual bool | moveTo (const T *agent, const Point< GPType > &newLocation) |
Moves the specified agent to the specified location. More... | |
virtual std::pair< bool, Point< GPType > > | moveByDisplacement (const T *agent, const std::vector< GPType > &displacement) |
Moves the specified object from its current location by the specified amount. More... | |
virtual std::pair< bool, Point< GPType > > | moveByVector (const T *agent, double distance, const std::vector< double > &anglesInRadians) |
doc inherited from Grid | |
virtual const_iterator | begin () const |
Gets an iterator over the agents in this BaseGrid starting with the first agent. More... | |
virtual const_iterator | end () const |
Gets the end of an iterator over the agents in this BaseGrid. More... | |
virtual size_t | size () const |
Gets the number of agents in this BaseGrid. More... | |
virtual double | getDistance (const Point< GPType > &pt1, const Point< GPType > &pt2) const |
Gets the distance between the two grid points. More... | |
virtual double | getDistanceSq (const Point< GPType > &pt1, const Point< GPType > &pt2) const |
Gets the square of the distance between the two grid points. More... | |
virtual void | getDisplacement (const Point< GPType > &pt1, const Point< GPType > &pt2, std::vector< GPType > &out) const |
Gets vector difference between point 1 and point 2, putting the result in out. More... | |
virtual const GridDimensions | dimensions () const |
Gets the dimensions of this Grid. More... | |
virtual void | translate (const Point< GPType > &location, const Point< GPType > &displacement, std::vector< GPType > &out) const |
Translates the specified location by the specified displacement put the result in out. More... | |
virtual void | transform (const std::vector< GPType > &location, std::vector< GPType > &out) const |
Transforms the specified location using the properties (e.g. More... | |
virtual bool | isPeriodic () const |
Gets whether or not this grid is periodic (i.e. More... | |
virtual ProjectionInfoPacket * | getProjectionInfo (AgentId id, bool secondaryInfo=false, std::set< AgentId > *secondaryIds=0, int destProc=-1) |
Public Member Functions inherited from repast::Grid< T, GPType > | |
Grid (std::string name) | |
Creates a Grid with the specified name. More... | |
virtual bool | isPeriodic () const =0 |
Gets whether or not this grid is periodic (i.e. More... | |
virtual void | getRequiredAgents (std::set< AgentId > &agentsToTest, std::set< AgentId > &agentsRequired, RADIUS radius=Projection< T >::PRIMARY) |
Given a set of agents to test, gets the subset that must be kept in order to fulfill the projection's 'contract' to the specified radius. More... | |
virtual bool | keepsAgentsOnSyncProj () |
Should return true if the Projection implemented can 'keep' some (non-local) agents during a projection information synchronization operation. More... | |
virtual bool | sendsSecondaryAgentsOnStatusExchange () |
Should return true if the Projection implemented will send secondary agents during a status exchange. More... | |
virtual void | cleanProjectionInfo (std::set< AgentId > &agentsToKeep) |
Public Member Functions inherited from repast::Projection< T > | |
Projection (std::string name) | |
Creates a projection with specified name. More... | |
const std::string | name () const |
Gets the name of this projection. | |
void | addFilterVal (int type) |
Adds an entry to the list of agent types that can be added to this projection. More... | |
void | removeFilterVal (int type) |
Removes an entry from the list of agent types that can be added to this projection. More... | |
void | clearFilter () |
Clears the list of agent types that can be added to this projection; the result is that the filter is empty, and any agent can be added. | |
bool | agentCanBeAdded (boost::shared_ptr< T > agent) |
Returns true if the agent can be added to the projection, which will be the case if the filter list is empty or if the agent's type is in the filter list. More... | |
virtual void | getProjectionInfo (std::vector< AgentId > &agents, std::vector< ProjectionInfoPacket * > &packets, bool secondaryInfo=false, std::set< AgentId > *secondaryIds=0, int destProc=-1) |
Convenience wrapper that gets all of the projection information for the agents specified (calls implementation in child class that gets only the information for one agent). | |
void | updateProjectionInfo (std::vector< ProjectionInfoPacket * > &pips, Context< T > *context) |
Updates the projection information for the agents in this projection according to the information contained in the vector of information packets passed. | |
Protected Types | |
typedef repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | GridBaseType |
Protected Types inherited from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | |
typedef AgentLocationMap::iterator | LocationMapIter |
typedef AgentLocationMap::const_iterator | LocationMapConstIter |
Protected Member Functions | |
virtual void | synchMoveTo (const AgentId &id, const Point< GPType > &pt)=0 |
Protected Member Functions inherited from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | |
virtual bool | addAgent (boost::shared_ptr< T > agent) |
LocationMapConstIter | locationsBegin () const |
LocationMapConstIter | locationsEnd () const |
T * | get (const AgentId &id) |
Protected Attributes | |
int | _buffer |
GridDimensions | localBounds |
GridDimensions | globalBounds |
Neighbors * | nghs |
std::vector< AgentId > | buffered |
int | rank |
boost::mpi::communicator * | comm |
Protected Attributes inherited from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | |
GPTransformer | gpTransformer |
Adder | adder |
Protected Attributes inherited from repast::Projection< T > | |
std::string | name_ |
std::set< int > | filter |
Additional Inherited Members | |
Public Types inherited from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > | |
typedef boost::transform_iterator< AgentFromGridPoint< T, GPType >, LocationMapConstIter > | const_iterator |
A const iterator over shared_ptr<T>. | |
Public Types inherited from repast::Projection< T > | |
enum | RADIUS { PRIMARY, SECONDARY } |
Grid / Space implementation specialized for the distributed context.
Each SharedBaseGrid of the same name running on different processes is part of a pan process grid. This class manages this local part of the grid and its communication with its process neighbors. Users can specify a buffer size that determines how much of the neighboring grids are visible in this grid. For example, if this grid originates at 0x0 and ends at 3x3, a buffer of 1 would make the locations (4,0), (4,1) (4,2) ... (4,4) and (0,4), (1,4)... (4,4) visible in this grid. The SharedBaseGrid takes many template parameters. Default variations of these that define typical grids and spaces are given in SharedGrids in SharedSpace.h
T | the type of objects contained by this BaseGrid |
GPTransformer | transforms cell points according to the topology (e.g. periodic) of the BaseGrid. |
Adder | determines how objects are added to the grid from its associated context. |
GPType | the coordinate type of the grid point locations. This must be an int or a double. |
repast::SharedBaseGrid< T, GPTransformer, Adder, GPType >::SharedBaseGrid | ( | std::string | name, |
GridDimensions | gridDims, | ||
std::vector< int > | processDims, | ||
int | buffer, | ||
boost::mpi::communicator * | communicator | ||
) |
Creates a SharedGrid with the specified name.
name | the name of this SharedBaseGrid |
gridDims | the dimensions of the entire pan-process grid |
processDims | the number of processes in each dimension. This must divide evenly into gridDims. |
buffer | the size of the buffer between this part of the pan-process grid and its neighbors. |
|
inlinevirtual |
Gets the global bounds for this grid.
Implements repast::Grid< T, GPType >.
|
inlinevirtual |
Gets the local bounds of this SharedGrid.
The local bounds are the dimensions of the section of the pan-process grid represented by this SharedGrid.
Implements repast::Grid< T, GPType >.
|
inlinevirtual |
Gets the set of processes with which this Projection exchanges agent status info- that is, the set of processes from which agents can move to this one or to which they can move when moving from this one.
In the most general case this will be all other processors. However, simulations where agents move in spaces will usually exchange agents only with a small subset of 'neighbor' processes, which is knowable in advance and constant. To accommodate the general case, the algorithm for exchanging information must poll all other processes to see which are sending to this one; if this is known in advance, this additional (expensive) step can be skipped.
Reimplemented from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >.
|
virtual |
Given a set of agents, gets the agents that this projection implementation must 'push' to other processes.
Generally spaces must push agents that are in 'buffer zones' and graphs must push local agents that are vertices to master edges where the other vertex is non- local. The results are returned per-process in the agentsToPush map.
Reimplemented from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >.
|
inlinevirtual |
Gets the set of processes with which this Projection exchanges projection info.
In the most general case this will be all other processors; this is the case for graphs, where agent connections can be arbitrary. However, spaces usually exchange information only with a small subset of 'neighbor' processes, which is knowable in advance and constant. To accommodate the general case, the algorithm for exchanging information must poll all other processes to see which are sending to this one; if this is known in advance, this additional (expensive) step can be skipped.
Reimplemented from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >.
|
virtual |
Moves the specified agent to the specified point.
id | the id of the agent to move |
pt | where to move the agent to |
Reimplemented from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >.
|
virtual |
Moves the specified agent to the specified location.
Returns true if the move was successful otherwise false. The agent must be already added to the context associated with this space, otherwise this throws an out_of_range exception if the new location out of bounds.
id | the id of the agent to move |
newLocation | the location to move to |
Reimplemented from repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >.