![]() |
fpmas 1.6
|
#include <grid_load_balancing.h>
Public Member Functions | |
GridLoadBalancing (DiscreteCoordinate width, DiscreteCoordinate height, api::communication::MpiCommunicator &comm) | |
GridLoadBalancing (const GridProcessMapping &grid_process_mapping) | |
api::graph::PartitionMap | balance (api::graph::NodeMap< api::model::AgentPtr > nodes) override |
api::graph::PartitionMap | balance (api::graph::NodeMap< api::model::AgentPtr > nodes, api::graph::PartitionMode partition_mode) override |
![]() | |
virtual PartitionMap | balance (NodeMap< api::model::AgentPtr > nodes)=0 |
virtual PartitionMap | balance (NodeMap< api::model::AgentPtr > nodes, PartitionMode partition_mode)=0 |
A grid based load balancing algorithm.
This algorithm only applies to Agents of the graph that implement api::model::GridCell or api::model::GridAgent (or, more specifically, api::model::GridAgentBase).
However notice that several implementations, i.e. distinct types extending each interface, can simultaneously exist in the graph, and the algorithm is indifferently applied to all of them.
If Agents that do not implement one of those interface are contained in the graph, the algorithm can still be applied, but those Agents are ignored: they will always be associated to the process that already owned them when the algorithm is applied.
The partitioning of the environment is performed using a GridProcessMapping, that first optimally associates each api::model::GridCell to a process. Then, each api::model::GridAgent is associated to the process that owns its locationCell()
, so that each api::model::GridCell and all api::model::GridAgents located on that cell are all LOCAL from their process.
The frequency at which the algorithm is executed is relatively important. Indeed, the DistributedMoveAlgorithm still allows agents to move past the "borders" associated to each process. This means that when an agent moves, is can be temporarily associated to a DISTANT location, until the GridLoadBalancing is applied again.
fpmas::model::GridLoadBalancing::GridLoadBalancing | ( | DiscreteCoordinate | width, |
DiscreteCoordinate | height, | ||
api::communication::MpiCommunicator & | comm | ||
) |
GridLoadBalancing constructor.
By default, a FastProcessMapping instance is used to map GridCells to processes.
width | global grid width |
height | global grid height |
comm | MPI communicator |
fpmas::model::GridLoadBalancing::GridLoadBalancing | ( | const GridProcessMapping & | grid_process_mapping | ) |
GridLoadBalancing constructor.
The specified GridProcessMapping is used instead of the default TreeProcessMapping.
|
override |
|
override |
Builds a partition according to the grid based load balancing algorithm from the input nodes.
Nodes that don't inherit from api::model::GridCell or api::model::GridAgentBase are ignored and not contained in the final partition, so that their state is unchanged when the partition is given back to the DistributedGraph.
nodes | nodes on which the algorithm is applied |
partition_mode | partitioning strategy |