fpmas 1.6
Public Member Functions | List of all members
fpmas::model::GridLoadBalancing Class Reference

#include <grid_load_balancing.h>

Inheritance diagram for fpmas::model::GridLoadBalancing:
Inheritance graph
[legend]
Collaboration diagram for fpmas::model::GridLoadBalancing:
Collaboration graph
[legend]

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
 
- Public Member Functions inherited from fpmas::api::graph::LoadBalancing< api::model::AgentPtr >
virtual PartitionMap balance (NodeMap< api::model::AgentPtr > nodes)=0
 
virtual PartitionMap balance (NodeMap< api::model::AgentPtr > nodes, PartitionMode partition_mode)=0
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GridLoadBalancing() [1/2]

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.

Parameters
widthglobal grid width
heightglobal grid height
commMPI communicator

◆ GridLoadBalancing() [2/2]

fpmas::model::GridLoadBalancing::GridLoadBalancing ( const GridProcessMapping grid_process_mapping)

GridLoadBalancing constructor.

The specified GridProcessMapping is used instead of the default TreeProcessMapping.

Member Function Documentation

◆ balance() [1/2]

api::graph::PartitionMap fpmas::model::GridLoadBalancing::balance ( api::graph::NodeMap< api::model::AgentPtr nodes)
override

Deprecated:
Deprecated in favor of balance(NodeMap<T>, PartitionMode)

◆ balance() [2/2]

api::graph::PartitionMap fpmas::model::GridLoadBalancing::balance ( api::graph::NodeMap< api::model::AgentPtr nodes,
api::graph::PartitionMode  partition_mode 
)
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.

Parameters
nodesnodes on which the algorithm is applied
partition_modepartitioning strategy
Returns
grid based partition

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