fpmas 1.6
Public Member Functions | List of all members
fpmas::model::SpatialAgentBuilder< CellType, MappingCellType > Class Template Reference

#include <spatial_model.h>

Inheritance diagram for fpmas::model::SpatialAgentBuilder< CellType, MappingCellType >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::model::SpatialAgentBuilder< CellType, MappingCellType >:
Collaboration graph
[legend]

Public Member Functions

void build (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, api::model::SpatialAgentFactory< CellType > &factory, api::model::SpatialAgentMapping< MappingCellType > &agent_mapping) override
 
void build (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, std::function< api::model::SpatialAgent< CellType > *()> factory, api::model::SpatialAgentMapping< MappingCellType > &agent_mapping) override
 
- Public Member Functions inherited from fpmas::api::model::SpatialAgentBuilder< CellType, api::model::Cell >
virtual void build (SpatialModel< CellType > &model, GroupList groups, SpatialAgentFactory< CellType > &factory, SpatialAgentMapping< api::model::Cell > &agent_mapping)=0
 
virtual void build (SpatialModel< CellType > &model, GroupList groups, std::function< SpatialAgent< CellType > *()> factory, SpatialAgentMapping< api::model::Cell > &agent_mapping)=0
 

Additional Inherited Members

- Static Public Attributes inherited from fpmas::model::SpatialAgentBuilderBase< CellType, api::model::Cell >
static const api::model::GroupId TEMP_GROUP_ID
 
- Protected Member Functions inherited from fpmas::model::SpatialAgentBuilderBase< CellType, api::model::Cell >
void build_agents (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, api::model::SpatialAgentFactory< CellType > &factory, api::model::SpatialAgentMapping< api::model::Cell > &agent_mapping)
 
void build_agents (api::model::SpatialModel< CellType > &model, api::model::GroupList groups, std::function< api::model::SpatialAgent< CellType > *()> factory, api::model::SpatialAgentMapping< api::model::Cell > &agent_mapping)
 

Detailed Description

template<typename CellType, typename MappingCellType = api::model::Cell>
class fpmas::model::SpatialAgentBuilder< CellType, MappingCellType >

api::model::SpatialAgentBuilder implementation.

Template Parameters
CellTypefinal Cell type on which agents are moving
MappingCellTypeCell type used by the mapping. MappingCellType must be a base of CellType.

Member Function Documentation

◆ build() [1/2]

template<typename CellType , typename MappingCellType = api::model::Cell>
void fpmas::model::SpatialAgentBuilder< CellType, MappingCellType >::build ( api::model::SpatialModel< CellType > &  model,
api::model::GroupList  groups,
api::model::SpatialAgentFactory< CellType > &  factory,
api::model::SpatialAgentMapping< MappingCellType > &  agent_mapping 
)
inlineoverride

Build SpatialAgents in the specified model in a distributed way.

More precisely:

  1. For each cell in model.cells(), agent_mapping.countAt(cell) SpatialAgents are allocated using factory.build().
  2. All built agents are added to all the AgentGroups specified in groups, using AgentGroup::add().
  3. The location of each SpatialAgent is initialized to the cell they were built from, according to point 1. This is eventually performed using SpatialAgent::initLocation().
  4. The DistributedMoveAlgorithm provided by model.distributedMoveAlgorithm() is executed to complete the location initialization of built SpatialAgents.

Additionnal implementation defined behaviors can be added according to the current model type.

Parameters
modelmodel in which agent are initialized. More precisely, agents are initialized within the Cell network defined by model.cells()
groupsgroups to which each agent must be added
factoryagent factory used to allocate agents
agent_mappingagent mapping used to compute the number of agents to initialize on each cell

◆ build() [2/2]

template<typename CellType , typename MappingCellType = api::model::Cell>
void fpmas::model::SpatialAgentBuilder< CellType, MappingCellType >::build ( api::model::SpatialModel< CellType > &  model,
api::model::GroupList  groups,
std::function< api::model::SpatialAgent< CellType > *()>  factory,
api::model::SpatialAgentMapping< MappingCellType > &  agent_mapping 
)
inlineoverride

Same as build(SpatialModel<CellType>&, GroupList, SpatialAgentFactory<CellType>&, SpatialAgentMapping<MappingCellType>&) but uses a call to factory() instead of the SpatialAgentFactory::build() method to build Agents.

It might be convenient to initialize the factory from a lambda function:

int data;
agent_builder.build(
model, {agent_group},
[&data] () {return new Agent(data);}, // Called only when required
agent_mapping
);
Parameters
modelmodel in which agent are initialized. More precisely, agents are initialized within the Cell network defined by model.cells()
groupsgroups to which each agent must be added
factorycallable object used to allocate agents
agent_mappingagent mapping used to compute the number of agents to initialize on each cell

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