RepastHPC  2.3.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
repast::Projection< T > Class Template Referenceabstract

Abstract base class for all Projections. More...

#include <Projection.h>

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

Public Types

enum  RADIUS { PRIMARY, SECONDARY }
 

Public Member Functions

 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 bool keepsAgentsOnSyncProj ()=0
 Should return true if the Projection implemented can 'keep' some (non-local) agents during a projection information synchronization operation. More...
 
virtual bool sendsSecondaryAgentsOnStatusExchange ()=0
 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 getRequiredAgents (std::set< AgentId > &agentsToTest, std::set< AgentId > &agentsRequired, RADIUS radius=PRIMARY)=0
 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 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 cleanProjectionInfo (std::set< AgentId > &agentsToKeep)=0
 
virtual void balance ()
 

Protected Member Functions

virtual bool addAgent (boost::shared_ptr< T > agent)=0
 
virtual void removeAgent (T *agent)=0
 
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
 

Protected Attributes

std::string name_
 
std::set< int > filter
 

Friends

class Context< T >
 

Detailed Description

template<typename T>
class repast::Projection< T >

Abstract base class for all Projections.

Constructor & Destructor Documentation

◆ Projection()

template<typename T >
repast::Projection< T >::Projection ( std::string  name)
inline

Creates a projection with specified name.

Parameters
namethe name of the projection. This must be unique across projections

Member Function Documentation

◆ addFilterVal()

template<typename T >
void repast::Projection< T >::addFilterVal ( int  type)
inline

Adds an entry to the list of agent types that can be added to this projection.

Note: no indication if type is already listed

Parameters
typetype to be added

◆ agentCanBeAdded()

template<typename T >
bool repast::Projection< T >::agentCanBeAdded ( boost::shared_ptr< T >  agent)
inline

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.

Parameters
agentpointer to the agent to be tested

◆ getAgentStatusExchangePartners()

template<typename T >
virtual void repast::Projection< T >::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.

Implemented in repast::Grid< T, GPType >, repast::Grid< RelogoAgent, int >, repast::Grid< T, double >, repast::Grid< T, int >, 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::Graph< V, E, Ec, EcM >, 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 >
virtual void repast::Projection< T >::getAgentsToPush ( std::set< AgentId > &  agentsToTest,
std::map< int, std::set< AgentId > > &  agentsToPush 
)
pure virtual

◆ getInfoExchangePartners()

template<typename T >
virtual void repast::Projection< T >::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.

Implemented in repast::Grid< T, GPType >, repast::Grid< RelogoAgent, int >, repast::Grid< T, double >, repast::Grid< T, int >, 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::Graph< V, E, Ec, EcM >, 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 >.

◆ getRequiredAgents()

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

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.

Implemented in repast::Grid< T, GPType >, repast::Grid< T, double >, and repast::Grid< T, int >.

◆ keepsAgentsOnSyncProj()

template<typename T >
virtual bool repast::Projection< T >::keepsAgentsOnSyncProj ( )
pure virtual

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.

Implemented in repast::Graph< V, E, Ec, EcM >, repast::Grid< T, GPType >, repast::Grid< RelogoAgent, int >, repast::Grid< T, double >, and repast::Grid< T, int >.

◆ removeFilterVal()

template<typename T >
void repast::Projection< T >::removeFilterVal ( int  type)
inline

Removes an entry from the list of agent types that can be added to this projection.

Note: no indication if type is not listed

Parameters
typeentry to be removed

◆ sendsSecondaryAgentsOnStatusExchange()

template<typename T >
virtual bool repast::Projection< T >::sendsSecondaryAgentsOnStatusExchange ( )
pure virtual

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

Implemented in repast::Graph< V, E, Ec, EcM >, repast::Grid< T, GPType >, repast::Grid< RelogoAgent, int >, repast::Grid< T, double >, and repast::Grid< T, int >.


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