fpmas 1.6
Public Member Functions | Protected Member Functions | List of all members
fpmas::model::GridAgent< AgentType, GridCellType, Derived > Class Template Reference

#include <grid.h>

Inheritance diagram for fpmas::model::GridAgent< AgentType, GridCellType, Derived >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::model::GridAgent< AgentType, GridCellType, Derived >:
Collaboration graph
[legend]

Public Member Functions

DiscretePoint locationPoint () const override
 
random::FPMAS_AGENT_RNGrd () override
 
void seed (std::FPMAS_AGENT_RNG::result_type seed) override
 
- Public Member Functions inherited from fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >
void initLocation (model::GridCell *cell) override
 
DistributedId locationId () const override
 
model::GridCelllocationCell () const override
 
- Public Member Functions inherited from fpmas::model::detail::AgentBase< api::model::GridAgent< model::GridCell >, AgentType, SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > > >
 AgentBase ()=default
 
 AgentBase (const AgentBase &agent)=default
 
 AgentBase (AgentBase &&)=default
 
AgentBaseoperator= (const AgentBase &agent)=default
 
AgentBaseoperator= (AgentBase &&)
 
GroupId groupId () const override
 
std::vector< GroupId > groupIds () const override
 
void setGroupId (api::model::GroupId id) override
 
void addGroupId (api::model::GroupId id) override
 
void removeGroupId (api::model::GroupId id) override
 
api::model::AgentGroupgroup () override
 
const api::model::AgentGroupgroup () const override
 
std::vector< const api::model::AgentGroup * > groups () const override
 
std::vector< api::model::AgentGroup * > groups () override
 
void setGroup (api::model::AgentGroup *group) override
 
void addGroup (api::model::AgentGroup *group) override
 
void removeGroup (api::model::AgentGroup *group) override
 
void setGroupPos (api::model::GroupId gid, std::list< api::model::Agent * >::iterator pos) override
 
std::list< api::model::Agent * >::iterator getGroupPos (api::model::GroupId gid) const override
 
api::model::TypeId typeId () const override
 
api::model::Agentcopy () const override
 
void copyAssign (api::model::Agent *agent) override
 
void moveAssign (api::model::Agent *agent) override
 
api::model::AgentNodenode () override
 
const api::model::AgentNodenode () const override
 
void setNode (api::model::AgentNode *node) override
 
api::model::Modelmodel () override
 
const api::model::Modelmodel () const override
 
void setModel (api::model::Model *model) override
 
api::model::AgentTasktask () override
 
const api::model::AgentTasktask () const override
 
api::model::AgentTasktask (api::model::GroupId id) override
 
const api::model::AgentTasktask (api::model::GroupId id) const override
 
void setTask (api::model::AgentTask *task) override
 
void setTask (api::model::GroupId id, api::model::AgentTask *task) override
 
const std::unordered_map< api::model::GroupId, api::model::AgentTask * > & tasks () override
 
virtual void act () override
 
Neighbors< NeighborAgentType > outNeighbors () const
 
Neighbors< NeighborAgentType > outNeighbors (api::graph::LayerId layer) const
 
Neighbors< NeighborAgentType > inNeighbors () const
 
Neighbors< NeighborAgentType > inNeighbors (api::graph::LayerId layer) const
 
- Public Member Functions inherited from fpmas::api::model::SpatialAgent< model::GridCell >
virtual DistributedId locationId () const=0
 
virtual model::GridCelllocationCell () const=0
 
virtual void initLocation (Cell *cell)=0
 
virtual const Range< model::GridCell > & mobilityRange () const=0
 
virtual const Range< model::GridCell > & perceptionRange () const=0
 
- Public Member Functions inherited from fpmas::api::model::Agent
virtual GroupId groupId () const =0
 
virtual std::vector< GroupIdgroupIds () const =0
 
virtual void setGroupId (GroupId id)=0
 
virtual void addGroupId (GroupId id)=0
 
virtual void removeGroupId (GroupId id)=0
 
virtual AgentGroupgroup ()=0
 
virtual const AgentGroupgroup () const =0
 
virtual std::vector< AgentGroup * > groups ()=0
 
virtual std::vector< const AgentGroup * > groups () const =0
 
virtual void setGroup (AgentGroup *group)=0
 
virtual void addGroup (AgentGroup *group)=0
 
virtual void removeGroup (AgentGroup *group)=0
 
virtual void setGroupPos (api::model::GroupId gid, std::list< Agent * >::iterator pos)=0
 
virtual std::list< Agent * >::iterator getGroupPos (api::model::GroupId gid) const =0
 
virtual TypeId typeId () const =0
 
virtual Agentcopy () const =0
 
virtual void copyAssign (Agent *agent)=0
 
virtual void moveAssign (Agent *agent)=0
 
virtual AgentNodenode ()=0
 
virtual const AgentNodenode () const =0
 
virtual void setNode (AgentNode *node)=0
 
virtual Modelmodel ()=0
 
virtual const Modelmodel () const =0
 
virtual void setModel (Model *model)=0
 
virtual AgentTasktask ()=0
 
virtual const AgentTasktask () const =0
 
virtual void setTask (AgentTask *task)=0
 
virtual AgentTasktask (GroupId id)=0
 
virtual const AgentTasktask (GroupId id) const =0
 
virtual void setTask (GroupId id, AgentTask *task)=0
 
virtual const std::unordered_map< GroupId, AgentTask * > & tasks ()=0
 
virtual void act ()=0
 
virtual void handleNewMove ()=0
 
virtual void handleNewPerceive ()=0
 
virtual DiscretePoint locationPoint () const =0
 
virtual api::random::Generator< std::FPMAS_AGENT_RNG::result_type > & rd ()=0
 
virtual void seed (std::FPMAS_AGENT_RNG::result_type seed)=0
 

Protected Member Functions

void moveTo (GridCellType *cell) override
 
void moveTo (DiscretePoint point) override
 
- Protected Member Functions inherited from fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >
void updateLocation (model::GridCell *cell)
 
void handleNewMove () override
 
void handleNewPerceive () override
 
void moveTo (DistributedId id) override
 
Neighbors< model::GridCellmobilityField () const
 
Neighbors< NeighborType > perceptions () const
 
- Protected Member Functions inherited from fpmas::api::model::GridAgent< model::GridCell >
virtual void moveTo (DiscretePoint point)=0
 
- Protected Member Functions inherited from fpmas::api::model::SpatialAgent< model::GridCell >
virtual void moveTo (DistributedId id)=0
 
virtual void moveTo (Cell *cell)=0
 
virtual void moveTo (DiscretePoint point)=0
 

Additional Inherited Members

- Public Types inherited from fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >
typedef SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > > JsonBase
 
- Public Types inherited from fpmas::model::detail::AgentBase< api::model::GridAgent< model::GridCell >, AgentType, SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > > >
typedef AgentType FinalAgentType
 
- Public Types inherited from fpmas::api::model::SpatialAgent< model::GridCell >
typedef model::GridCell Cell
 
- Static Public Attributes inherited from fpmas::model::detail::AgentBase< api::model::GridAgent< model::GridCell >, AgentType, SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > > >
static const api::model::TypeId TYPE_ID
 

Detailed Description

template<typename AgentType, typename GridCellType = model::GridCell, typename Derived = AgentType>
class fpmas::model::GridAgent< AgentType, GridCellType, Derived >

api::model::GridAgent implementation.

Template Parameters
AgentTypefinal GridAgent type (i.e. the most derived type from this GridAgent)
GridCellTypeType of cells constituting the Grid on which the agent is moving. Must extend api::model::GridCell.
Deriveddirect derived class, or at least the next class in the serialization chain

Member Function Documentation

◆ moveTo() [1/2]

template<typename AgentType , typename GridCellType , typename Derived >
void fpmas::model::GridAgent< AgentType, GridCellType, Derived >::moveTo ( GridCellType *  cell)
overrideprotected

Moves to the input Cell.

The input Cell is not required to be contained in the current mobility field of this SpatialAgent, what allows:

  1. To initialize the location of this SpatialAgent (since in this case, the mobility field is still empty)
  2. A SpatialAgent to move an other DISTANT SpatialAgent.

The execution of a DistributedMoveAlgorithm is required to commit the operation and update mobility fields and perceptions. However, this can be handled automatically on specific AgentGroups: see SpatialModel::buildMoveGroup().

More precisely, the current location, if defined, is unlinked, and so does the mobility field and perceptions, and a link from this SpatialAgent to cell is created on the NEW_LOCATION layer. In consequence, the behavior of locationCell() is undefined until a DistributedMoveAlgorithm is executed.

Notice that performing an other moveTo() operation before the previous is committed produces an undefined behavior.

Parameters
cellcell to which this SpatialAgent should move.

◆ moveTo() [2/2]

template<typename AgentType , typename GridCellType , typename Derived >
void fpmas::model::GridAgent< AgentType, GridCellType, Derived >::moveTo ( DiscretePoint  point)
overrideprotectedvirtual

Moves to the Cell at the specified point.

Notice that it is assumed that at most one GridCell can be located at each point.

If no Cell at point can be found in the current mobility field, an OutOfMobilityFieldException is thrown.

Parameters
pointdiscrete coordinates
Exceptions
OutOfMobilityFieldException

Implements fpmas::api::model::GridAgentBase.

◆ locationPoint()

template<typename AgentType , typename GridCellType = model::GridCell, typename Derived = AgentType>
DiscretePoint fpmas::model::GridAgent< AgentType, GridCellType, Derived >::locationPoint ( ) const
inlineoverridevirtual

Returns the current location of the GridAgent as discrete coordinates.

The behavior of this method is similar to the SpatialAgent::locationId() method: considering the moveTo(DiscretePoint) method, the agent can move using this kind of operations:

agent->moveTo(neighbor->locationPoint())
Returns
location of the GridAgent

Implements fpmas::api::model::GridAgentBase.

◆ rd()

template<typename AgentType , typename GridCellType = model::GridCell, typename Derived = AgentType>
random::FPMAS_AGENT_RNG & fpmas::model::GridAgent< AgentType, GridCellType, Derived >::rd ( )
inlineoverridevirtual

Returns a reference to the sequential random number bound to this agent.

The implementation should ensure that each agent produces an indenpendent random number sequence.

This can be perfomed:

  • Bounding a sequential generator to all agents, and seed() them independently.
  • Using a global DistributedGenerator

Implements fpmas::api::model::RandomAgent.

◆ seed()

template<typename AgentType , typename GridCellType = model::GridCell, typename Derived = AgentType>
void fpmas::model::GridAgent< AgentType, GridCellType, Derived >::seed ( std::FPMAS_AGENT_RNG::result_type  seed)
inlineoverridevirtual

Seeds the generator bound to this agent.

Note
The generator is seeded from this agent, even if it is shared by several agents, for example in the case of a DistributedGenerator.

Implements fpmas::api::model::RandomAgent.


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