![]() |
fpmas 1.6
|
#include <grid.h>
Public Member Functions | |
void | build (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, api::model::SpatialAgentFactory< CellType > &factory, api::model::SpatialAgentMapping< api::model::GridCell > &agent_mapping) override |
void | build (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, std::function< api::model::SpatialAgent< CellType > *()> factory, api::model::SpatialAgentMapping< api::model::GridCell > &agent_mapping) override |
void | initSample (std::size_t n, std::function< void(api::model::GridAgent< CellType > *)> init_function) const |
template<typename T > | |
void | initSequence (const std::vector< T > &items, std::function< void(api::model::GridAgent< CellType > *, typename std::vector< T >::const_reference)> init_function) const |
![]() | |
virtual void | build (SpatialModel< GridCell > &model, GroupList groups, SpatialAgentFactory< GridCell > &factory, SpatialAgentMapping< api::model::GridCell > &agent_mapping)=0 |
virtual void | build (SpatialModel< GridCell > &model, GroupList groups, std::function< SpatialAgent< GridCell > *()> factory, SpatialAgentMapping< api::model::GridCell > &agent_mapping)=0 |
Additional Inherited Members | |
![]() | |
static const api::model::GroupId | TEMP_GROUP_ID |
![]() | |
void | build_agents (api::model::SpatialModel< GridCell > &model, api::model::GroupList groups, api::model::SpatialAgentFactory< GridCell > &factory, api::model::SpatialAgentMapping< api::model::GridCell > &agent_mapping) |
void | build_agents (api::model::SpatialModel< GridCell > &model, api::model::GroupList groups, std::function< api::model::SpatialAgent< GridCell > *()> factory, api::model::SpatialAgentMapping< api::model::GridCell > &agent_mapping) |
Grid specialization of the SpatialAgentBuilder class.
The fpmas::model::GridAgentBuilder uses api::model::GridCell as the MappingCellType
parameter, meaning an SpatialAgentMapping<api::model::GridCell> must be provided to the fpmas::model::GridAgentBuilder::build() method. As an example, RandomGridAgentMapping might be used.
|
override |
Implements api::model::SpatialAgentBuilder::build(SpatialModel<CellType>&, GroupList, SpatialAgentFactory<CellType>&, SpatialAgentMapping<MappingCellType>&), and seeds built agents, implicitly considered as api::model::GridAgent.
The seed associated to each agent is independent from the current cell distribution. This notably means that all agents will generate the same random numbers sequence, independently of the current process count, the cell distribution or the migration of agents during the simulation.
The process can be seeded with fpmas::seed().
|
override |
Same as build(api::model::SpatialModel<CellType>& model, api::model::GroupList groups, api::model::SpatialAgentFactory<CellType>& factory, api::model::SpatialAgentMapping<api::model::GridCell>& agent_mapping), but uses calls to factory()
to build agents.
void fpmas::model::GridAgentBuilder< CellType >::initSample | ( | std::size_t | n, |
std::function< void(api::model::GridAgent< CellType > *)> | init_function | ||
) | const |
Initializes a sample of n
agents selected from the previously built agents with the provided init_function
.
The sample of agents selected is deterministic: it is guaranteed that the same agents are initialized independently of the current cell distribution.
The selection process can be seeded with fpmas::seed().
Successive calls can be used to independently initialize several agent states.
n | sample size |
init_function | initialization function |
void fpmas::model::GridAgentBuilder< CellType >::initSequence | ( | const std::vector< T > & | items, |
std::function< void(api::model::GridAgent< CellType > *, typename std::vector< T >::const_reference)> | init_function | ||
) | const |
Sequentially initializes built agents from the input items
.
Each item is assigned to an agent using the specified init_function
.
The item assignment is deterministic: it is guaranteed that each agent is always initialized with the same item independently of the current cell distribution.
items | Items to assign to built agents. The number of items must be greater or equal to the total number of built agents, n_agent . Only the first n_agent items are assigned, other are ignored. |
init_function | item assignment function |