Specifying network restrictions for an algorithm
In order to declare restrictions for a distributed algorithm, the developer must define the class attribute
NodeAlgorithm.algorithm_restrictions as a list or tuple of restriction types. Such types must be subclasses of
pydistsim.restrictions.base_restriction.Restriction.
For example, for a broadcast algorithm, the restrictions could be:
algorithm_restrictions = (
BidirectionalLinks,
TotalReliability,
Connectivity,
UniqueInitiator,
)
See also
For the simulation to enforce the restrictions during runtime, the attribute check_restrictions of
pydistsim.simulation.Simulation must be set to True.
For a full example of a broadcast algorithm with restrictions, please refer to the file
pydistsim/demo_algorithms/broadcast.py in the source code.
Note
For the full list of available restrictions, please refer to the module reference of pydistsim.restrictions
in this documentation.
Warning
Some of the implemented restrictions require the algorithm to take action in the algorithm initialization.
For example, the pydistsim.restrictions.topological.UniqueInitiator restriction requires the algorithm to
set the initiator node.