Class SingleSourceSPParticle
Implements the (1, l)-SPF algorithm. See https://doi.org/10.1145/3662158.3662776.
In the first phase, we run the Euler Tour Technique (ETT) on the
implicit portal graphs for the 3 axes, using the source amoebot as
root and the destination amoebots to define the weight function.
After each iteration, each amoebot knows which of its adjacent portals
is a parent portal. For each neighbor, we count in how many portal graphs
this neighbor is on a parent portal.
At the end of the first phase, each amoebot elects one neighbor that
occurred as parent portal twice to be its parent in the shortest path tree.
In the second phase, we run ETT again on the resulting forest to prune all
subtrees without destinations and to identify and remove components that
are not connected to the root.
Inheritance
object
SingleSourceSPParticle
Assembly: .dll
Syntax
public class SingleSourceSPParticle : ParticleAlgorithm
Constructors
|
Edit this page
View Source
SingleSourceSPParticle(Particle)
Declaration
public SingleSourceSPParticle(Particle p)
Parameters
Fields
|
Edit this page
View Source
destColor
Declaration
private static readonly Color destColor
Field Value
|
Edit this page
View Source
destPortalColor
Declaration
private static readonly Color destPortalColor
Field Value
|
Edit this page
View Source
ett
Declaration
Field Value
|
Edit this page
View Source
isDest
Declaration
private ParticleAttribute<bool> isDest
Field Value
|
Edit this page
View Source
isDestRepr
Declaration
private ParticleAttribute<bool> isDestRepr
Field Value
|
Edit this page
View Source
isRootRepr
Declaration
private ParticleAttribute<bool> isRootRepr
Field Value
|
Edit this page
View Source
isSource
Declaration
private ParticleAttribute<bool> isSource
Field Value
|
Edit this page
View Source
mixedPortalColor
Declaration
private static readonly Color mixedPortalColor
Field Value
|
Edit this page
View Source
nbrPortalDir1
Declaration
private ParticleAttribute<Direction> nbrPortalDir1
Field Value
|
Edit this page
View Source
nbrPortalDir2
Declaration
private ParticleAttribute<Direction> nbrPortalDir2
Field Value
|
Edit this page
View Source
onDestPortal
Declaration
private ParticleAttribute<bool> onDestPortal
Field Value
|
Edit this page
View Source
onRootPortal
Declaration
private ParticleAttribute<bool> onRootPortal
Field Value
|
Edit this page
View Source
parent
Declaration
private ParticleAttribute<Direction> parent
Field Value
|
Edit this page
View Source
parentCounters
Declaration
private ParticleAttribute<int>[] parentCounters
Field Value
|
Edit this page
View Source
phase
Declaration
private ParticleAttribute<SingleSourceSPParticle.Phase> phase
Field Value
|
Edit this page
View Source
portalAxisDir
Declaration
private ParticleAttribute<Direction> portalAxisDir
Field Value
|
Edit this page
View Source
pruned
Declaration
private ParticleAttribute<bool> pruned
Field Value
|
Edit this page
View Source
round
Declaration
private ParticleAttribute<int> round
Field Value
|
Edit this page
View Source
sourceColor
Declaration
private static readonly Color sourceColor
Field Value
|
Edit this page
View Source
sourcePortalColor
Declaration
private static readonly Color sourcePortalColor
Field Value
Properties
|
Edit this page
View Source
GenerationMethod
Declaration
public static string GenerationMethod { get; }
Property Value
|
Edit this page
View Source
Name
Declaration
public static string Name { get; }
Property Value
|
Edit this page
View Source
PinsPerEdge
The number of pins on each edge.
This number must be the same constant for all
particles.
Declaration
public override int PinsPerEdge { get; }
Property Value
Overrides
Methods
|
Edit this page
View Source
ActivateBeep()
This is the second part of the main activation logic of the
particle. It is called exactly once in each round, after the
movements scheduled in ActivateMove() have been
executed, and should contain the algorithm code that
implements the look-compute-beep cycle.
Inside of this method, particles are allowed to change their
pin configuration and send beeps and messages on the updated
configuration.
Note that beeps and messages sent in the current round will
be readable in both the ActivateMove() and
ActivateBeep() calls in the next round.
Declaration
public override void ActivateBeep()
Overrides
|
Edit this page
View Source
ActivateFinalPrunePhase()
Declaration
private void ActivateFinalPrunePhase()
|
Edit this page
View Source
ActivateMove()
This is one part of the main activation logic of the particle.
It is called exactly once in each round and should contain the
algorithm code that implements the look-compute-move cycle.
After the movements are executed, ActivateBeep()
is called within the same round.
Inside of this method, particles are allowed to release bonds,
define which bonds should be marked, and schedule movements.
Only the last movement operation scheduled in this method will
be applied.
Declaration
public override void ActivateMove()
Overrides
|
Edit this page
View Source
ActivatePortalPhase()
Declaration
private void ActivatePortalPhase()
|
Edit this page
View Source
DeterminePortalNeighbors(Direction)
Sets the neighbor portal flags of this amoebot. Direction 1
indicates the "top" neighbor edge, direction 2 the "bottom"
neighbor edge. The direction will be unequal to
NONE if and only if this amoebot
is the unique amoebot with the edge to that neighboring portal.
Declaration
private void DeterminePortalNeighbors(Direction portalDir)
Parameters
Type |
Name |
Description |
Direction |
portalDir |
The direction of the portal axis.
|
|
Edit this page
View Source
Init(bool, bool)
Declaration
public void Init(bool isSource = false, bool isDest = false)
Parameters
Type |
Name |
Description |
bool |
isSource |
|
bool |
isDest |
|
|
Edit this page
View Source
IsChild(Direction)
Checks whether there is an amoebot in direction d
which has its parent direction pointing at this amoebot.
Declaration
private bool IsChild(Direction d)
Parameters
Type |
Name |
Description |
Direction |
d |
The direction to check.
|
Returns
Type |
Description |
bool |
true if and only if we have a shortest path tree
child in direction d .
|
|
Edit this page
View Source
IsFinished()
Checks whether this particle has finished its algorithm.
Override this method to return true
when a particle
is done executing the algorithm. Once all particles in the
system are finished, the simulation will stop automatically.
When a particle's state results in this method returning
true
, its activation methods should not change its
state any more.
Declaration
public override bool IsFinished()
Returns
Type |
Description |
bool |
true if and only if this particle has
finished its algorithm.
|
Overrides
|
Edit this page
View Source
Prune()
Sets this amoebot's internal state to pruned. Hereafter,
the amoebot will not participate in the rest of the
algorithm. Also sets the correct color.
Declaration
|
Edit this page
View Source
SetColor()
Sets the color of this amoebot according to its
current phase and state.
Declaration
|
Edit this page
View Source
SetupPortalNeighborCircuits(Direction)
Sets up one circuit for each neighbor of a portal along
the given axis. The "top" partition set will have ID 0
and the "bottom" partition set will have ID 1. If there
is no neighbor in one of the directions, no partition set
will be created for that direction.
Declaration
private void SetupPortalNeighborCircuits(Direction portalDir)
Parameters
Type |
Name |
Description |
Direction |
portalDir |
The direction of the portal axis.
|
|
Edit this page
View Source
SetupSimplePortalCircuit(Direction)
Sets up a simple circuit connecting all pins along the given axis
into partition set 0.
Declaration
private void SetupSimplePortalCircuit(Direction portalDir)
Parameters
Type |
Name |
Description |
Direction |
portalDir |
The direction of the portal axis.
|
|
Edit this page
View Source
ShowPortalGraph(ParticleSystem, Particle)
Declaration
[StatusInfo("Show Portal Graph", "Draws the (implicit) portal graph during the first phase of the algorithm. The root portal is marked red, the destination portals are marked blue. If the root portal contains a destination, it is marked magenta.", false)]
public static void ShowPortalGraph(ParticleSystem system, Particle selectedParticle)
Parameters
|
Edit this page
View Source
ShowTree(ParticleSystem, Particle)
Declaration
[StatusInfo("Show SP Tree", "Draws the parent edges of all amoebots as soon as they are available. This will only work during the second phase of the algorithm.", false)]
public static void ShowTree(ParticleSystem system, Particle selectedParticle)
Parameters
|
Edit this page
View Source
UpdateParentCounter(Direction, int)
Increments the parent counter of the parent in
direction d
in case a beep
was received on the partition set with ID
pSet
and there is a neighbor
in that direction.
Declaration
private void UpdateParentCounter(Direction d, int pSet)
Parameters
Type |
Name |
Description |
Direction |
d |
The direction of the neighbor to update.
|
int |
pSet |
The partition set to check.
|