![]() |
fpmas 1.6
|
#include <spatial_model.h>
Public Types | |
typedef SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > | JsonBase |
![]() | |
typedef AgentType | FinalAgentType |
Protected Member Functions | |
void | updateLocation (CellType *cell) |
void | handleNewMove () override |
void | handleNewPerceive () override |
void | moveTo (DistributedId id) override |
Neighbors< CellType > | mobilityField () const |
template<typename NeighborType = api::model::Agent> | |
Neighbors< NeighborType > | perceptions () const |
Additional Inherited Members | |
![]() | |
static const api::model::TypeId | TYPE_ID |
api::model::SpatialAgent API implementation.
The SpatialAgentInterface
template parameter specifies the API actually implemented by this class. It can be api::model::SpatialAgent, or any other api that extends the api::model::SpatialAgent interface.
See fpmas::model::detail::AgentBase for more details about the implementation scheme.
This is a partial implementation, that does not implement moveTo(CellType*).
SpatialAgentInterface | SpatialAgent interface implemented by this SpatialAgentBase |
AgentType | final SpatialAgentBase type (i.e. most derived class from this SpatialAgentBase) |
CellType | type of cells on which the agent moves |
Derived | direct derived class, or at least the next class in the serialization chain |
typedef SpatialAgentBase<SpatialAgentInterface, AgentType, CellType, Derived> fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived >::JsonBase |
The type that must be used in FPMAS_REGISTER_AGENT_TYPES and FPMAS_JSON_SET_UP to enable json serialization of AgentType
, which is the dynamic type of any SpatialAgentBase<AgentType, CellType, Derived>.
|
protected |
Updates this SpatialAgent location.
cell
on the NEW_LOCATION layer.cell
s node id.This function is likely to be used by moveTo(CellType*) implementation, that is not implemented by this base.
cell | cell to which this agent should move |
|
overrideprotected |
Handles links on the NEW_MOVE layer.
Crops the current mobility field according to the current mobility range of the agent.
For each outgoing edge on the NEW_MOVE layer:
agent->mobilityRange().contains(agent->locationCell(), edge->getTargetNode())
, edge is replaced by an edge on the MOVE layer.
|
overrideprotected |
Handles links on the NEW_PERCEIVE layer.
Crops the current perception field according to the current perception range of the agent.
For each outgoing edge on the NEW_PERCEIVE layer:
agent->perceptionRange().contains(agent->locationCell(), edge->getTargetNode())
, edge is replaced by an edge on the PERCEIVE layer.
|
overrideprotected |
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 |
|
inlineprotected |
Returns Cells currently contained in the agent's mobility field.
|
inlineprotected |
|
inlineoverride |
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 |
|
inlineoverride |
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
.
|
override |
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.