![]() |
fpmas 1.6
|
#include <spatial_model.h>
Public Types | |
typedef CellType | Cell |
Public Member Functions | |
virtual DistributedId | locationId () const =0 |
virtual CellType * | locationCell () const =0 |
virtual void | initLocation (Cell *cell)=0 |
virtual const Range< CellType > & | mobilityRange () const =0 |
virtual const Range< CellType > & | perceptionRange () const =0 |
![]() | |
virtual GroupId | groupId () const =0 |
virtual std::vector< GroupId > | groupIds () const =0 |
virtual void | setGroupId (GroupId id)=0 |
virtual void | addGroupId (GroupId id)=0 |
virtual void | removeGroupId (GroupId id)=0 |
virtual AgentGroup * | group ()=0 |
virtual const AgentGroup * | group () 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 Agent * | copy () const =0 |
virtual void | copyAssign (Agent *agent)=0 |
virtual void | moveAssign (Agent *agent)=0 |
virtual AgentNode * | node ()=0 |
virtual const AgentNode * | node () const =0 |
virtual void | setNode (AgentNode *node)=0 |
virtual Model * | model ()=0 |
virtual const Model * | model () const =0 |
virtual void | setModel (Model *model)=0 |
virtual AgentTask * | task ()=0 |
virtual const AgentTask * | task () const =0 |
virtual void | setTask (AgentTask *task)=0 |
virtual AgentTask * | task (GroupId id)=0 |
virtual const AgentTask * | task (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 |
Protected Member Functions | |
virtual void | moveTo (DistributedId id)=0 |
virtual void | moveTo (Cell *cell)=0 |
SpatialAgent API.
In addition to the classical Agent properties, SpatialAgents can be located on a Cell network, move and perceive objects within it.
The mobility field of a SpatialAgent is defined as the set of outgoing neighbors of type Cell on the MOVE
layer.
The perceptions of a SpatialAgent are defined as elements of the set of outgoind neighbors of type Agent on the PERCEPTION
layer.
Helper functions might be defined in implementing classes to access those elements.
The specified CellType
must extend Cell.
typedef CellType fpmas::api::model::SpatialAgent< CellType >::Cell |
Type of Cell on which the SpatialAgent is moving.
|
pure virtual |
Returns the id
of the location Cell of this SpatialAgent.
This id can be used to easily move to the location of DISTANT perceived SpatialAgent.
For example, let's consider a SpatialAgent A
, that is LOCAL. It can perceive a DISTANT agent B
, located on a Cell C
, that is also DISTANT. We also assume C
is currently in the mobility field of A
. Considering the properties of an FPMAS DistributedGraph, B
is guaranteed to be represented on the current process, since it's linked to A
on the PERCEPTION
layer, and so does C
on the MOVE
layer. However, since B
and C
are distant, the LOCATION
link from B
to C
is not expected to be presented on the current process, so calling B->locationCell()
will produce an unexpected behavior. However, A
can still move to the current location of B
using the locationId() method:
Notice that this is valid whatever the current SynchronizationMode is. Indeed, moveTo
operations are only committed at the next DistributedMoveAlgorithm execution, that includes a Graph synchronization process. So, in any case, even if B
moves during its execution on an other process while A->moveTo()
is executed on the current process, its new location will effectively be committed only when all SpatialAgents are synchronized, so it is still consistent to assume that, during this epoch, B
is still located at B->locationId()
. However, when the DistributedMoveAlgorithm will be applied, A
will finally end on a different location than B
.
Implemented in fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >, and fpmas::model::SpatialAgentBase< api::model::SpatialAgent< api::model::Cell >, AgentType, api::model::Cell, AgentType >.
|
pure virtual |
Returns the current location of this SpatialAgent.
The location of a SpatialAgent is defined as the target of the only outgoing edge connected to this SpatialAgent on the LOCATION
layer.
Contrary to locationId(), this method produces an unexpected result when called on a DISTANT SpatialAgent.
Implemented in fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >, and fpmas::model::SpatialAgentBase< api::model::SpatialAgent< api::model::Cell >, AgentType, api::model::Cell, AgentType >.
|
pure virtual |
Initializes the location of this SpatialAgent.
Contrary to moveTo
, this method is public and does not assume that old location, mobility field and perceptions must be unlinked. If the SpatialAgent location was already defined (using initLocation() or moveTo()), the behavior of this method is undefined. However, notice that the location of the SpatialAgent can also be initialized internally using a moveTo() operation.
The DistributedMoveAlgorithm must still be applied to commit the initial location, as with regular moveTo() operations.
cell | initial location of the SpatialAgent |
Implemented in fpmas::model::SpatialAgentBase< api::model::SpatialAgent< api::model::Cell >, AgentType, api::model::Cell, AgentType >.
|
pure virtual |
Returns the current mobility range of this SpatialAgent.
|
pure virtual |
Returns the current perception range of this SpatialAgent.
|
protectedpure virtual |
Moves to the Cell with the provided id
.
If the id
does not correspond to any Cell in the current mobility field, an OutOfMobilityFieldException is thrown.
If a corresponding Cell is found, the move operation is performed as described in moveTo(Cell*).
id | Cell id |
OutOfMobilityFieldException |
Implemented in fpmas::model::SpatialAgentBase< api::model::GridAgent< model::GridCell >, AgentType, model::GridCell, GridAgent< AgentType, model::GridCell, AgentType > >, and fpmas::model::SpatialAgentBase< api::model::SpatialAgent< api::model::Cell >, AgentType, api::model::Cell, AgentType >.
|
protectedpure virtual |
Moves to the input Cell.
The input Cell is not required to be contained in the current mobility field of this SpatialAgent, what allows:
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.
cell | cell to which this SpatialAgent should move. |