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

Collection of agents of type T with set semantics. More...

#include <Context.h>

Inheritance diagram for repast::Context< T >:
repast::SharedContext< T >

Public Types

typedef boost::transform_iterator< SecondElement< T >, typename AgentMap::const_iterator > const_iterator
 
typedef boost::filter_iterator< IsAgentType< T >, typename Context< T >::const_iterator > const_bytype_iterator
 

Public Member Functions

virtual ~Context ()
 Destroys this context and the projections it contains.
 
T * addAgent (T *agent)
 Adds the agent to the context. More...
 
virtual void addProjection (Projection< T > *projection)
 Adds the specified projection to this context. More...
 
Projection< T > * getProjection (const std::string &name)
 Get the named Projection. More...
 
void removeAgent (const AgentId id)
 Removes the specified agent from this context. More...
 
void removeAgent (T *agent)
 Removes the specified agent from this context.
 
T * getAgent (const AgentId &id)
 Gets the specified agent. More...
 
void getRandomAgents (const int count, std::vector< T * > &agents)
 Gets at random the specified count of agents and returns them in the agents vector. More...
 
const_iterator begin () const
 Gets the start of iterator over the agents in this context. More...
 
const_iterator end () const
 Gets the end of an iterator over the agents in this context. More...
 
const_bytype_iterator byTypeBegin (int typeId) const
 Gets the start of an iterator over agents in this context of the specified type. More...
 
const_bytype_iterator byTypeEnd (int typeId) const
 Gets the end of an iterator over agents in this context of the specified type. More...
 
bool contains (const AgentId &id)
 Returns true if the specified agent is in this context, otherwise false.
 
int size () const
 Gets the size (number of agents) in this context.
 
void addValueLayer (BaseValueLayer *valueLayer)
 Adds a value layer to this context. More...
 
template<typename ValueType , typename Borders >
DiscreteValueLayer< ValueType, Borders > * getDiscreteValueLayer (const std::string &valueLayerName)
 Gets the named discrete value layer from this Context. More...
 
template<typename ValueType , typename Borders >
ContinuousValueLayer< ValueType, Borders > * getContinuousValueLayer (const std::string &valueLayerName)
 Gets the named continuous value layer from this Context. More...
 
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_iterator > filteredBegin (const filterStruct &fStruct)
 
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_iterator > filteredEnd (const filterStruct &fStruct)
 Creates a filtered iterator over the set of agents in this context and returns it with a value equal to one step past end of the list. More...
 
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_bytype_iterator > byTypeFilteredBegin (const int type, const filterStruct &fStruct)
 Creates a filtered iterator over the set of agents in this context of the specified type (per their AgentId values), and returns it with a value equal to the beginning of the list. More...
 
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_bytype_iterator > byTypeFilteredEnd (const int type, const filterStruct &fStruct)
 Creates a filtered iterator over the set of agents in this context of the specified type (per their AgentId values), and returns it with a value equal to one past the end of the list. More...
 
void selectAgents (std::set< T * > &selectedAgents, bool remove=false)
 Gets a set of pointers to all agents in this context. More...
 
void selectAgents (std::vector< T * > &selectedAgents, bool remove=false)
 Gets a randomly ordered vector of pointers to all agents in this context. More...
 
void selectAgents (int count, std::set< T * > &selectedAgents, bool remove=false)
 Gets a set of pointers to a specified number of randomly selected agents. More...
 
void selectAgents (int count, std::vector< T * > &selectedAgents, bool remove=false)
 Gets a randomly ordered vector of pointers to a specified number of randomly selected agents. More...
 
void selectAgents (std::set< T * > &selectedAgents, int type, bool remove=false, int popSize=-1)
 Gets a set of pointers to all agents in this context of a specified type (per their AgentId values). More...
 
void selectAgents (std::vector< T * > &selectedAgents, int type, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to all agents in this context of a specified type (per their AgentId values). More...
 
void selectAgents (int count, std::set< T * > &selectedAgents, int type, bool remove=false, int popSize=-1)
 Gets a set of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values). More...
 
void selectAgents (int count, std::vector< T * > &selectedAgents, int type, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values). More...
 
template<typename filterStruct >
void selectAgents (std::set< T * > &selectedAgents, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a set of pointers to all agents in this context matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (std::vector< T * > &selectedAgents, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to all agents in this context matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (int count, std::set< T * > &selectedAgents, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a set of pointers to a specified number of randomly selected agents matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (int count, std::vector< T * > &selectedAgents, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to a specified number of randomly selected agents matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (std::set< T * > &selectedAgents, int type, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a set of pointers to all agents in this context of a specified type (per their AgentId values) and matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (std::vector< T * > &selectedAgents, int type, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to all agents in this context of a specified type (per their AgentId values) and matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (int count, std::set< T * > &selectedAgents, int type, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a set of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values) and matching a user-defined filter. More...
 
template<typename filterStruct >
void selectAgents (int count, std::vector< T * > &selectedAgents, int type, filterStruct &filter, bool remove=false, int popSize=-1)
 Gets a randomly ordered vector of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values) and matching a user-defined filter. More...
 
void getProjectionInfo (AgentRequest req, std::map< std::string, std::vector< repast::ProjectionInfoPacket * > > &map, bool secondaryInfo=false, std::set< AgentId > *secondaryIds=0, int destProc=-1)
 Gets the projection information for all projections in this context, for all agents whose IDs are listed in the AgentRequest. More...
 
void setProjectionInfo (std::map< std::string, std::vector< repast::ProjectionInfoPacket * > > &projInfo)
 Sets the projection information as specified. More...
 
void cleanProjectionInfo (std::set< AgentId > &agentsToKeep)
 

Protected Attributes

std::vector< Projection< T > * > projections
 

Detailed Description

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

Collection of agents of type T with set semantics.

Object identity and equality is determined by their AgentId.

Template Parameters
thetype objects contained by the Context. The T must extends repast::Agent.

Member Function Documentation

◆ addAgent()

template<typename T >
T * repast::Context< T >::addAgent ( T *  agent)

Adds the agent to the context.

Performs a check to ensure that no agent with the same ID (presumably the 'same' agent) has previously been added. If a matching ID is found, the new agent is not added, and the address of the pre-existing agent is returned. If no match is found, the agent is added and the return value is the same as the value passed

Parameters
agentthe agent to add
Returns
the address of the agent in the context; will be the same as the address passed if the agent was successfully added, but if there was already an agent with the same ID the address returned will be that of the pre-existing agent, which is not replaced.

◆ addProjection()

template<typename T >
void repast::Context< T >::addProjection ( Projection< T > *  projection)
virtual

Adds the specified projection to this context.

All the agents in this context will be added to the Projection. Any agents subsequently added to this context will also be added to the Projection.

Parameters
projectionthe projection to add

Reimplemented in repast::SharedContext< T >, and repast::SharedContext< repast::relogo::RelogoAgent >.

◆ addValueLayer()

template<typename T >
void repast::Context< T >::addValueLayer ( BaseValueLayer valueLayer)

Adds a value layer to this context.

Parameters
valueLayerthe value layer to add

◆ begin()

template<typename T >
const_iterator repast::Context< T >::begin ( ) const
inline

Gets the start of iterator over the agents in this context.

The iterator derefrences into shared_ptr<T>. The actual agent can be accessed by derefrenceing the iter: (*iter)->getId() for example.

Returns
the start of iterator over the agents in this context.

◆ byTypeBegin()

template<typename T >
const_bytype_iterator repast::Context< T >::byTypeBegin ( int  typeId) const
inline

Gets the start of an iterator over agents in this context of the specified type.

The type corresponds to the type component of an agent's AgentId.

Parameters
typeIdthe type of the agent. Only Agents whose agentId.agentType() is equal to this typeId will be included in the iterator
Returns
the start of an iterator over agents in this context of the specified type.

◆ byTypeEnd()

template<typename T >
const_bytype_iterator repast::Context< T >::byTypeEnd ( int  typeId) const
inline

Gets the end of an iterator over agents in this context of the specified type.

The type corresponds to the type component of an agent's AgentId.

Parameters
typeIdthe type of the agent. Only Agents whose agentId.agentType() is equal to this typeId will be included in the iterator
Returns
the end of an iterator over agents in this context of the specified type.

◆ byTypeFilteredBegin()

template<typename T >
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_bytype_iterator > repast::Context< T >::byTypeFilteredBegin ( const int  type,
const filterStruct &  fStruct 
)

Creates a filtered iterator over the set of agents in this context of the specified type (per their AgentId values), and returns it with a value equal to the beginning of the list.

The struct can be any user-defined structure that implements a unary operator (see IsAgentType) that can be passed and which will become a filter to sort across the agent list, e.g.:

struct filter { bool operator()(const boost::shared_ptr<T>& ptr){ return (ptr->getAgentValue() == targetValue;) } }

This should allow filtering of agents by type and on any attribute.

Parameters
fStructan instance of the struct to be used as the filter
typethe numeric type of agents to be included in the list
Template Parameters
filterStructthe type of the filter to be applied to the agents
Returns
an iterator positioned at the beginning of the list of agents meeting the filter's criteria

◆ byTypeFilteredEnd()

template<typename T >
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_bytype_iterator > repast::Context< T >::byTypeFilteredEnd ( const int  type,
const filterStruct &  fStruct 
)

Creates a filtered iterator over the set of agents in this context of the specified type (per their AgentId values), and returns it with a value equal to one past the end of the list.

The struct can be any user-defined structure that implements a unary operator (see IsAgentType) that can be passed and which will become a filter to sort across the agent list, e.g.:

struct filter { bool operator()(const boost::shared_ptr<T>& ptr){ return (ptr->getAgentValue() == targetValue;) } }

This should allow filtering of agents by type and on any attribute.

Parameters
fStructan instance of the struct to be used as the filter
typethe numeric type of agents to be included in the list
Template Parameters
filterStructthe type of the filter to be applied to the agents
Returns
an iterator positioned at one past the end of the list of agents meeting the filter's criteria

◆ end()

template<typename T >
const_iterator repast::Context< T >::end ( ) const
inline

Gets the end of an iterator over the agents in this context.

The iterator derefrences into shared_ptr<T>. The actual agent can be accessed by derefrenceing the iter: (*iter)->getId() for example.

Returns
the end of an iterator over the agents in this context

◆ filteredBegin()

template<typename T >
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_iterator > repast::Context< T >::filteredBegin ( const filterStruct &  fStruct)
Creates a filtered iterator over the set of agents
in this context and returns it with a value equal
to the beginning of the list.

The struct can be any user-defined structure that implements
a unary operator (see IsAgentType) that can be passed and
which will become a filter to sort across the agent

list, e.g.:

struct filter { bool operator()(const boost::shared_ptr<T>& ptr){ return (ptr->getAgentValue() == targetValue;) } }

This should allow filtering of agents by any attribute.

Parameters
fStructan instance of the struct to be used as the filter
@tparam filterStruct the type of the filter to be applied to the agents

@return an iterator positioned at the beginning of the list of
agents meeting the filter's criteria

◆ filteredEnd()

template<typename T >
template<typename filterStruct >
boost::filter_iterator< filterStruct, typename Context< T >::const_iterator > repast::Context< T >::filteredEnd ( const filterStruct &  fStruct)

Creates a filtered iterator over the set of agents in this context and returns it with a value equal to one step past end of the list.

The struct can be any user-defined structure that implements a unary operator (see IsAgentType) that can be passed and which will become a filter to sort across the agent list, e.g.:

struct filter { bool operator()(const boost::shared_ptr<T>& ptr){ return (ptr->getAgentValue() == targetValue;) } }

This should allow filtering of agents by any attribute.

Parameters
fStructan instance of the struct to be used as the filter
Template Parameters
filterStructthe type of the filter to be applied to the agents
Returns
an iterator positioned at one past the end of the list of agents meeting the filter's criteria

◆ getAgent()

template<typename T >
T * repast::Context< T >::getAgent ( const AgentId id)

Gets the specified agent.

Parameters
theid of the agent to get.

◆ getContinuousValueLayer()

template<typename T >
template<typename ValueType , typename Borders >
ContinuousValueLayer< ValueType, Borders > * repast::Context< T >::getContinuousValueLayer ( const std::string &  valueLayerName)

Gets the named continuous value layer from this Context.

The value layer must have been previously added.

Parameters
valueLayerNamethe name of the value layer to get
Template Parameters
ValueTypethe numeric type contained by the value layer
Bordersthe Border type of the value layer
Returns
the named continuous value layer from this Context.

◆ getDiscreteValueLayer()

template<typename T >
template<typename ValueType , typename Borders >
DiscreteValueLayer< ValueType, Borders > * repast::Context< T >::getDiscreteValueLayer ( const std::string &  valueLayerName)

Gets the named discrete value layer from this Context.

The value layer must have been previously added.

Parameters
valueLayerNamethe name of the value layer to get
Template Parameters
ValueTypethe numeric type contained by the value layer
Bordersthe Border type of the value layer
Returns
the named discrete value layer from this Context.

◆ getProjection()

template<typename T >
Projection< T > * repast::Context< T >::getProjection ( const std::string &  name)

Get the named Projection.

Parameters
thename of the projection to get
Returns
the named Projection or 0 if no such Projection is found.

◆ getProjectionInfo()

template<typename T >
void repast::Context< T >::getProjectionInfo ( AgentRequest  req,
std::map< std::string, std::vector< repast::ProjectionInfoPacket * > > &  map,
bool  secondaryInfo = false,
std::set< AgentId > *  secondaryIds = 0,
int  destProc = -1 
)

Gets the projection information for all projections in this context, for all agents whose IDs are listed in the AgentRequest.

The general sense of this method can be easily understood: given a list of agents, get the projection information for all of those agents. But there are some subtleties that should be kept in mind.

"The projection information for an agent" is misleading. In fact, the projection information that is needed can vary depending on the context and on the kind of projection.

Generally speaking, spaces return only one kind projection information: coordinate locations for the agent specified. This is the simplest case.

The more complicated case is given by graphs. A graph projection can return different sets of information depending on how that information will have to be used. The basic issue is that a graph projection returns sets of edges, and edges must be connected to other agents; this means that a mechanism must be in place for ensuring that the projection info that arrives can be used, which means that for a given 'ego' agent, all 'alter' agents that are connected to it by edges must also be on the receiving process. (Note: Repast HPC 1.0 versions sent all of the alter agents' content along with the edge send; this version does not do this, partly to minimize the amount of information being packaged and sent but also because the alternative method used is integrated with the normal bookkeeping for sharing agent information across processes (AgentRequests).) In different circumstances, different assumptions can be made about what information will be available on the receiving process. Note that the coordinate information is generally referred to as 'Primary' information, while edge information is 'secondary'; in a third category ('secondary IDs') are the IDs of the alter agents, which can be packaged separately.

The impact of this is that this function is generally called in the following ways:

1) When requesting agents: in this case, a copy of the agent will be sent from one process to another. No secondary information will be sent at all. This is because it is assumed that if an agent participated in a graph on the receiving process, it would already be present on that process and would not be being requested.

2) When synchronizing Projection Information: in this case, some secondary information (edges) is needed: the edges that connect the specified ego agent with edges on the receiving process. No secondary IDs are needed, because the only edges being sent are those that connect to agents on the receiving process, which will be assumed to already be available on that process.

3) When synchronizing Agent Status (moving agents from process to process): in this case, the full collection of projection information is needed, including all of the edges in which the specified agent participates and all of the secondary IDs. (The secondary IDs of agents that are already on the receiving process can be omitted, at least theoretically.) This allows the full reconstruction of Projection Information on the receiving process.

Parameters
reqList of IDs for agents whose information is requested
mapA map into which the projection information will be placed. Key values represent the names of the projections in this context.
secondaryInfotrue if the 'secondary' projection info must also be returned
secondaryIdsA set of IDs for agents who are referred to by the projection informaton being returned (may be null)
destProcThe Process that will be receiving this information (the information sent may be customized depending on the destination process). If not specified a larger set of information will be sent.

◆ getRandomAgents()

template<typename T >
void repast::Context< T >::getRandomAgents ( const int  count,
std::vector< T * > &  agents 
)

Gets at random the specified count of agents and returns them in the agents vector.

Parameters
countthe number of agents to get
[out]agentsa vector where the agents will be returned

◆ removeAgent()

template<typename T >
void repast::Context< T >::removeAgent ( const AgentId  id)

Removes the specified agent from this context.

Parameters
idthe id of the agent to remove

◆ selectAgents() [1/16]

template<typename T >
void repast::Context< T >::selectAgents ( int  count,
std::set< T * > &  selectedAgents,
bool  remove = false 
)

Gets a set of pointers to a specified number of randomly selected agents.

If the set passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa set into which the pointers to the agents will be placed
removeif true, remove any elements originally in the set before the set is returned (default is false)

◆ selectAgents() [2/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( int  count,
std::set< T * > &  selectedAgents,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to a specified number of randomly selected agents matching a user-defined filter.

If the set passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa set into which the pointers to the agents will be placed
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [3/16]

template<typename T >
void repast::Context< T >::selectAgents ( int  count,
std::set< T * > &  selectedAgents,
int  type,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values).

If the set passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa set into which the pointers to the agents will be placed
typenumeric type of agent to be selected
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn

◆ selectAgents() [4/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( int  count,
std::set< T * > &  selectedAgents,
int  type,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values) and matching a user-defined filter.

If the set passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa set into which the pointers to the agents will be placed
typenumeric type of agent to be selected
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [5/16]

template<typename T >
void repast::Context< T >::selectAgents ( int  count,
std::vector< T * > &  selectedAgents,
bool  remove = false 
)

Gets a randomly ordered vector of pointers to a specified number of randomly selected agents.

If the vector passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa vector into which the pointers to the agents will be placed
removeif true, remove any elements originally in the set before the set is returned (default is false)

◆ selectAgents() [6/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( int  count,
std::vector< T * > &  selectedAgents,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to a specified number of randomly selected agents matching a user-defined filter.

If the vector passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa vector into which the pointers to the agents will be placed
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [7/16]

template<typename T >
void repast::Context< T >::selectAgents ( int  count,
std::vector< T * > &  selectedAgents,
int  type,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values).

If the vector passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa vector into which the pointers to the agents will be placed
typenumeric type of agent to be selected
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn

◆ selectAgents() [8/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( int  count,
std::vector< T * > &  selectedAgents,
int  type,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to a specified number of randomly selected agents of a specified type (per their AgentId values) and matching a user-defined filter.

If the vector passed contains any elements when this method is called, the agents pointed to by those elements will be omitted from the selection.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
countthe number of agents to be selected. If this exceeds the number that can possibly be selected, all possible agents will be selected
[out]selectedAgentsa vector into which the pointers to the agents will be placed
typenumeric type of agent to be selected
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [9/16]

template<typename T >
void repast::Context< T >::selectAgents ( std::set< T * > &  selectedAgents,
bool  remove = false 
)

Gets a set of pointers to all agents in this context.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

Parameters
[out]selectedAgentsa set into which the pointers to the agents will be placed
removeif true, remove any elements originally in the set before the set is returned (default is false)

◆ selectAgents() [10/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( std::set< T * > &  selectedAgents,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to all agents in this context matching a user-defined filter.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

that can possibly be selected, all possible agents will be selected

Parameters
[out]selectedAgentsa set into which the pointers to the agents will be placed
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [11/16]

template<typename T >
void repast::Context< T >::selectAgents ( std::set< T * > &  selectedAgents,
int  type,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to all agents in this context of a specified type (per their AgentId values).

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
[out]selectedAgentsa set into which the pointers to the agents will be placed
typenumeric type of agent to be selected
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn

◆ selectAgents() [12/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( std::set< T * > &  selectedAgents,
int  type,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a set of pointers to all agents in this context of a specified type (per their AgentId values) and matching a user-defined filter.

If the 'remove' parameter is set to true, any elements in the original set will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
[out]selectedAgentsa set into which the pointers to the agents will be placed
typenumeric type of agent to be selected
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [13/16]

template<typename T >
void repast::Context< T >::selectAgents ( std::vector< T * > &  selectedAgents,
bool  remove = false 
)

Gets a randomly ordered vector of pointers to all agents in this context.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

Parameters
[out]selectedAgentsa vector into which the pointers to the agents will be placed
removeif true, remove any elements originally in the set before the set is returned (default is false)

◆ selectAgents() [14/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( std::vector< T * > &  selectedAgents,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to all agents in this context matching a user-defined filter.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
[out]selectedAgentsa vector into which the pointers to the agents will be placed
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ selectAgents() [15/16]

template<typename T >
void repast::Context< T >::selectAgents ( std::vector< T * > &  selectedAgents,
int  type,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to all agents in this context of a specified type (per their AgentId values).

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
[out]selectedAgentsa vector into which the pointers to the agents will be placed
typenumeric type of agent to be selected
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn

◆ selectAgents() [16/16]

template<typename T >
template<typename filterStruct >
void repast::Context< T >::selectAgents ( std::vector< T * > &  selectedAgents,
int  type,
filterStruct &  filter,
bool  remove = false,
int  popSize = -1 
)

Gets a randomly ordered vector of pointers to all agents in this context of a specified type (per their AgentId values) and matching a user-defined filter.

If the 'remove' parameter is set to true, any elements in the original vector will be removed before the method returns.

The popSize parameter is used when the method is repeatedly called on a population whose size is known. Calls to this method typically begin by determining the size of the (valid) population to be sampled; if this is known, it can be provided here, improving performance.

Parameters
[out]selectedAgentsa vector into which the pointers to the agents will be placed
typenumeric type of agent to be selected
filteruser-defined filter specifying any criteria agents to be selected must meet
removeif true, remove any elements originally in the set before the set is returned (default is false)
popSizesize of the population from which the sample will be drawn
Template Parameters
filterStructthe type of the filter to be applied to the agents

◆ setProjectionInfo()

template<typename T >
void repast::Context< T >::setProjectionInfo ( std::map< std::string, std::vector< repast::ProjectionInfoPacket * > > &  projInfo)

Sets the projection information as specified.

Parameters
projInfomap where keys represent projections in this context and the values represent collections of projection information content that will be used to specify the relationships among the agents.

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