RepastHPC  2.3.1
Public Member Functions | List of all members
repast::Grid< T, GPType > Class Template Referenceabstract

Abstract interface for Grids and ContinuousSpaces. More...

#include <Grid.h>

Inheritance diagram for repast::Grid< T, GPType >:
repast::Projection< T > repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType > repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType > repast::SharedBaseGrid< T, GPTransformer, Adder, GPType >

Public Member Functions

 Grid (std::string name)
 Creates a Grid with the specified name. More...
 
virtual bool contains (const AgentId &id)=0
 Gets whether or not this grid contains the agent with the specified id. More...
 
virtual bool moveTo (const AgentId &id, const Point< GPType > &pt)=0
 Moves the specified agent to the specified point. More...
 
virtual std::pair< bool, Point< GPType > > moveByVector (const T *agent, double distance, const std::vector< double > &anglesInRadians)=0
 Moves the specifed object the specified distance from its current position along the specified angle. More...
 
virtual std::pair< bool, Point< GPType > > moveByDisplacement (const T *agent, const std::vector< GPType > &displacement)=0
 Moves the specified object from its current location by the specified amount. More...
 
virtual const GridDimensions dimensions () const =0
 Gets the dimensions of this Grid. More...
 
virtual const GridDimensions bounds () const =0
 
virtual T * getObjectAt (const Point< GPType > &pt) const =0
 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 =0
 Gets all the objects found at the specified point. More...
 
virtual bool getLocation (const T *agent, std::vector< GPType > &out) const =0
 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 =0
 Gets the location of this agent and puts it in the specified vectors. More...
 
virtual void getDisplacement (const Point< GPType > &pt1, const Point< GPType > &pt2, std::vector< GPType > &out) const =0
 Gets vector difference between point 1 and point 2, putting the result in out. More...
 
virtual double getDistance (const Point< GPType > &pt1, const Point< GPType > &pt2) const =0
 Gets the distance between the two grid points. More...
 
virtual double getDistanceSq (const Point< GPType > &pt1, const Point< GPType > &pt2) const =0
 Gets the square of the distance between the two grid points. More...
 
virtual void translate (const Point< GPType > &location, const Point< GPType > &displacement, std::vector< GPType > &out) const =0
 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 =0
 Transforms the specified location using the properties (e.g. More...
 
virtual bool isPeriodic () const =0
 Gets whether or not this grid is periodic (i.e. More...
 
virtual ProjectionInfoPacketgetProjectionInfo (AgentId id, bool secondaryInfo=false, std::set< AgentId > *secondaryIds=0, int destProc=-1)=0
 
virtual void updateProjectionInfo (ProjectionInfoPacket *pip, Context< T > *context)=0
 
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 void getAgentsToPush (std::set< AgentId > &agentsToTest, std::map< int, std::set< AgentId > > &agentsToPush)=0
 Given a set of agents, gets the agents that this projection implementation must 'push' to other processes. 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 getInfoExchangePartners (std::set< int > &psToSendTo, std::set< int > &psToReceiveFrom)=0
 Gets the set of processes with which this Projection exchanges projection info. More...
 
virtual void getAgentStatusExchangePartners (std::set< int > &psToSendTo, std::set< int > &psToReceiveFrom)=0
 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 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.
 
virtual void balance ()
 

Additional Inherited Members

- Public Types inherited from repast::Projection< T >
enum  RADIUS { PRIMARY, SECONDARY }
 
- Protected Member Functions inherited from repast::Projection< T >
virtual bool addAgent (boost::shared_ptr< T > agent)=0
 
virtual void removeAgent (T *agent)=0
 
- Protected Attributes inherited from repast::Projection< T >
std::string name_
 
std::set< int > filter
 

Detailed Description

template<typename T, typename GPType>
class repast::Grid< T, GPType >

Abstract interface for Grids and ContinuousSpaces.

Template Parameters
Tthe type of objects this Grid contains
GPTypethe coordinate type of the grid point locations. This must be an int or a double.

Constructor & Destructor Documentation

◆ Grid()

template<typename T , typename GPType >
repast::Grid< T, GPType >::Grid ( std::string  name)
inline

Creates a Grid with the specified name.

Parameters
namethe name of the Grid. This should be unique among Projections.

Member Function Documentation

◆ contains()

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::contains ( const AgentId id)
pure virtual

◆ dimensions()

template<typename T , typename GPType >
virtual const GridDimensions repast::Grid< T, GPType >::dimensions ( ) const
pure virtual

◆ getAgentStatusExchangePartners()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getAgentStatusExchangePartners ( std::set< int > &  psToSendTo,
std::set< int > &  psToReceiveFrom 
)
pure virtual

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.

Implements repast::Projection< T >.

Implemented in repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::SharedBaseGrid< T, GPTransformer, Adder, GPType >, repast::SharedBaseGrid< RelogoAgent, GPTransformer, Adder, int >, repast::SharedBaseGrid< T, GPTransformer, Adder, int >, and repast::SharedBaseGrid< T, GPTransformer, Adder, double >.

◆ getAgentsToPush()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getAgentsToPush ( std::set< AgentId > &  agentsToTest,
std::map< int, std::set< AgentId > > &  agentsToPush 
)
pure virtual

◆ getDisplacement()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getDisplacement ( const Point< GPType > &  pt1,
const Point< GPType > &  pt2,
std::vector< GPType > &  out 
) const
pure virtual

◆ getDistance()

template<typename T , typename GPType >
virtual double repast::Grid< T, GPType >::getDistance ( const Point< GPType > &  pt1,
const Point< GPType > &  pt2 
) const
pure virtual

◆ getDistanceSq()

template<typename T , typename GPType >
virtual double repast::Grid< T, GPType >::getDistanceSq ( const Point< GPType > &  pt1,
const Point< GPType > &  pt2 
) const
pure virtual

◆ getInfoExchangePartners()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getInfoExchangePartners ( std::set< int > &  psToSendTo,
std::set< int > &  psToReceiveFrom 
)
pure virtual

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.

Implements repast::Projection< T >.

Implemented in repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::SharedBaseGrid< T, GPTransformer, Adder, GPType >, repast::SharedBaseGrid< RelogoAgent, GPTransformer, Adder, int >, repast::SharedBaseGrid< T, GPTransformer, Adder, int >, and repast::SharedBaseGrid< T, GPTransformer, Adder, double >.

◆ getLocation() [1/2]

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::getLocation ( const AgentId id,
std::vector< GPType > &  out 
) const
pure virtual

Gets the location of this agent and puts it in the specified vectors.

The x coordinate will be the first value, the y the second and so on.

Parameters
idthe id of the agent whose location we want to get
[out]outthe agent's location will be put into this vector
Returns
true if the location was successfully found, otherwise false.

Implemented in repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, and repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >.

◆ getLocation() [2/2]

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::getLocation ( const T *  agent,
std::vector< GPType > &  out 
) const
pure virtual

Gets the location of this agent and puts it in the specified vector.

The x coordinate will be the first value, the y the second and so on.

Parameters
agentthe agent whose location we want to get
[out]thevector where the agents location will be put
Returns
true if the location was successfully found, otherwise false.

Implemented in repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, and repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >.

◆ getObjectAt()

template<typename T , typename GPType >
virtual T* repast::Grid< T, GPType >::getObjectAt ( const Point< GPType > &  pt) const
pure virtual

◆ getObjectsAt()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getObjectsAt ( const Point< GPType > &  pt,
std::vector< T * > &  out 
) const
pure virtual

◆ getRequiredAgents()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::getRequiredAgents ( std::set< AgentId > &  agentsToTest,
std::set< AgentId > &  agentsRequired,
RADIUS  radius = Projection< T >::PRIMARY 
)
inlinevirtual

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.

Generally spaces do not require any agents, but graphs do- generally the non-local ends to master copies of edges.

Implements repast::Projection< T >.

◆ isPeriodic()

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::isPeriodic ( ) const
pure virtual

◆ keepsAgentsOnSyncProj()

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::keepsAgentsOnSyncProj ( )
inlinevirtual

Should return true if the Projection implemented can 'keep' some (non-local) agents during a projection information synchronization operation.

Generally spaces will allow all non-local agents to be deleted, but graphs keep the non-local agents that participate in Master edges.

It is possible to override these. A graph projection can be created that does not permit non-local agents to be 'kept'. This would be an extremely unusual use case, but it is possible.

Note that these are used for optimization. If no projection in a given context keeps any agents, several steps in the synchronization algorithm can be omitted. Of course, omitting these steps when a projection actually retains agents can caused undefined problems.

Returns
true if this projection will keep non-local agents during a projection information synchronziation event, false if it will not.

Implements repast::Projection< T >.

◆ moveByDisplacement()

template<typename T , typename GPType >
virtual std::pair<bool, Point<GPType> > repast::Grid< T, GPType >::moveByDisplacement ( const T *  agent,
const std::vector< GPType > &  displacement 
)
pure virtual

Moves the specified object from its current location by the specified amount.

For example moveByDisplacement(object, 3, -2, 1) will move the object by 3 along the x-axis, -2 along the y and 1 along the z. The displacement argument can be less than the number of dimensions in the space in which case the remaining argument will be set to 0. For example, moveByDisplacement(object, 3) will move the object 3 along the x-axis and 0 along the y and z axes, assuming a 3D grid.

Parameters
agentthe object to move
displacementthe amount to move the object
Returns
a pair containing a bool that indicates whether the move was a success or not, and the point where the agent was moved to.

Implemented in repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, and repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >.

◆ moveByVector()

template<typename T , typename GPType >
virtual std::pair<bool, Point<GPType> > repast::Grid< T, GPType >::moveByVector ( const T *  agent,
double  distance,
const std::vector< double > &  anglesInRadians 
)
pure virtual

Moves the specifed object the specified distance from its current position along the specified angle.

For example, moveByVector(object, 1, Grid.NORTH) will move the object 1 unit "north" up the y-axis, assuming a 2D grid. Similarly, grid.moveByVector(object, 2, 0, Math.toRadians(90), 0) will rotate 90 degrees around the y-axis, thus moving the object 2 units along the z-axis.

Note that the radians / degrees are incremented in a anti-clockwise fashion, such that 0 degrees is "east", 90 degrees is "north", 180 is "west" and 270 is "south."

Parameters
agentthe object to move
distancethe distance to move
anglesInRadiansthe angle to move along in radians.
Returns
a pair containing a bool that indicates whether the move was a success or not, and the point where the agent was moved to.

Implemented in repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, and repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >.

◆ moveTo()

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::moveTo ( const AgentId id,
const Point< GPType > &  pt 
)
pure virtual

◆ sendsSecondaryAgentsOnStatusExchange()

template<typename T , typename GPType >
virtual bool repast::Grid< T, GPType >::sendsSecondaryAgentsOnStatusExchange ( )
inlinevirtual

Should return true if the Projection implemented will send secondary agents during a status exchange.

Generally spaces do not and graphs do.

If no secondary agents will be sent, portions of the algorithm can be omitted for optimization.

Returns
true if the Projection returns secondary agents, false if not

Implements repast::Projection< T >.

◆ transform()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::transform ( const std::vector< GPType > &  location,
std::vector< GPType > &  out 
) const
pure virtual

◆ translate()

template<typename T , typename GPType >
virtual void repast::Grid< T, GPType >::translate ( const Point< GPType > &  location,
const Point< GPType > &  displacement,
std::vector< GPType > &  out 
) const
pure virtual

Translates the specified location by the specified displacement put the result in out.

Parameters
locationthe initial location
displacementthe amount to translate the location by
[out]outthe vector where the result of the translation is put

Implemented in repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, and repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >.


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