RepastHPC
2.3.1
|
Abstract interface for Grids and ContinuousSpaces. More...
#include <Grid.h>
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 ProjectionInfoPacket * | getProjectionInfo (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 |
Abstract interface for Grids and ContinuousSpaces.
T | the type of objects this Grid contains |
GPType | the coordinate type of the grid point locations. This must be an int or a double. |
|
inline |
|
pure virtual |
Gets whether or not this grid contains the agent with the specified id.
id | the id of the agent to check |
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 >, and repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >.
|
pure virtual |
Gets the dimensions of this Grid.
Implemented in repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, 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 >.
|
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 >.
|
pure 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.
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 >.
|
pure virtual |
Gets vector difference between point 1 and point 2, putting the result in out.
p1 | the first point | |
p2 | the second point | |
[out] | the | vector where the difference will be 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 >.
|
pure virtual |
Gets the distance between the two grid points.
p1 | the first point |
p2 | the second point |
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 >.
|
pure virtual |
Gets the square of the distance between the two grid points.
p1 | the first point |
p2 | the second point |
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 >.
|
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 >.
|
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.
id | the id of the agent whose location we want to get | |
[out] | out | the agent's location will be put into this vector |
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 >.
|
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.
agent | the agent whose location we want to get | |
[out] | the | vector where the agents location will be put |
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 >.
|
pure virtual |
Gets the first object found at the specified point, or NULL if there is no such object.
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 >.
|
pure virtual |
Gets all the objects found at the specified point.
The found objects will be put into the out parameter.
pt | the point to get all the objects at | |
[out] | out | the vector into which the found objects will be put |
Implemented in repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >, repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, 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 >.
|
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 >.
|
pure virtual |
Gets whether or not this grid is periodic (i.e.
toroidal).
Implemented in repast::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >, repast::BaseGrid< RelogoAgent, MultipleOccupancy< RelogoAgent, int >, GPTransformer, Adder, int >, and repast::BaseGrid< T, MultipleOccupancy< T, int >, GPTransformer, Adder, int >.
|
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.
Implements repast::Projection< T >.
|
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.
agent | the object to move |
displacement | the amount to move the object |
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 >.
|
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."
agent | the object to move |
distance | the distance to move |
anglesInRadians | the angle to move along in radians. |
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 >.
|
pure virtual |
Moves the specified agent to the specified point.
id | the id of the agent to move |
pt | where to move the agent to |
Implemented in repast::SharedBaseGrid< RelogoAgent, GPTransformer, Adder, int >, repast::SharedBaseGrid< T, GPTransformer, Adder, int >, 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::BaseGrid< T, CellAccessor, GPTransformer, Adder, GPType >, repast::BaseGrid< T, MultipleOccupancy< T, GPType >, GPTransformer, Adder, GPType >, repast::SharedBaseGrid< T, GPTransformer, Adder, double >, and repast::BaseGrid< T, MultipleOccupancy< T, double >, GPTransformer, Adder, double >.
|
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.
Implements repast::Projection< T >.
|
pure virtual |
Transforms the specified location using the properties (e.g.
toroidal) of this space.
location | the location to transform | |
[out] | out | the vector where the result of the transform will be 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 >.
|
pure virtual |
Translates the specified location by the specified displacement put the result in out.
location | the initial location | |
displacement | the amount to translate the location by | |
[out] | out | the 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 >.