Class RunProtelisProgram
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.Action
,java.io.Serializable
public final class RunProtelisProgram<P extends Position<P>> implements Action<Any>
An Action that executes a Protelis program.
Requires the current randomGenerator and environment, a valid ProtelisDevice (device), and the local reaction hosting the computation.
The program can be created using a String (originalProgram), or, alternatively, by providing a ProtelisProgram (program).
retentionTime specifies whether, upon message usage, the received messages should be deleted (assuming a reasonable synchronization among devices) or if they should remain in memory for a specified amount of time. By default, retentionTime is Double.NaN, indicating that messages are deleted upon read.
It is possible to sumulate the loss of messages due to a higher connection distance by providing a RealDistribution (packetLossDistance) mapping distances to the loss probability. By default this feature is disabled.
-
-
Field Summary
Fields Modifier and Type Field Description private final Node<Object>
node
private final Boolean
isComputationalCycleComplete
private final transient AlchemistExecutionContext<P>
executionContext
private final RandomGenerator
randomGenerator
private final Environment<Object, P>
environment
private final ProtelisDevice<P>
device
private final Reaction<Object>
reaction
private final String
originalProgram
private final ProtelisProgram
program
private final Double
retentionTime
private final RealDistribution
packetLossDistance
-
Constructor Summary
Constructors Constructor Description RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, Double retentionTime)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, Double retentionTime, String packetLossDistributionName, Double packetLossDistributionParameters)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, String packetLossDistributionName, Double packetLossDistributionParameters)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, Double retentionTime)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, Double retentionTime, String packetLossDistributionName, Double packetLossDistributionParameters)
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, String packetLossDistributionName, Double packetLossDistributionParameters)
-
Method Summary
Modifier and Type Method Description final Node<Object>
getNode()
The Alchemist Node hosting the ProtelisDevice. final Boolean
isComputationalCycleComplete()
final AlchemistExecutionContext<P>
getExecutionContext()
Provides an access to the underlying org.protelis.vm.ExecutionContext. final RandomGenerator
getRandomGenerator()
final Environment<Object, P>
getEnvironment()
final ProtelisDevice<P>
getDevice()
final Reaction<Object>
getReaction()
final String
getOriginalProgram()
final ProtelisProgram
getProgram()
final Double
getRetentionTime()
final RealDistribution
getPacketLossDistance()
final Molecule
asMolecule()
RunProtelisProgram<P>
cloneAction(Node<Object> node, Reaction<Object> reaction)
Boolean
equals(Object other)
Unit
execute()
Context
getContext()
ImmutableListSet<Dependency>
getOutboundDependencies()
Integer
hashCode()
final Unit
prepareForComputationalCycle()
Resets the computation status (used for dependency management). String
toString()
-
-
Constructor Detail
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, Double retentionTime)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, Double retentionTime, String packetLossDistributionName, Double packetLossDistributionParameters)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, ProtelisProgram program, String packetLossDistributionName, Double packetLossDistributionParameters)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, Double retentionTime)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, Double retentionTime, String packetLossDistributionName, Double packetLossDistributionParameters)
-
RunProtelisProgram
RunProtelisProgram(RandomGenerator randomGenerator, Environment<Object, P> environment, ProtelisDevice<P> device, Reaction<Object> reaction, String program, String packetLossDistributionName, Double packetLossDistributionParameters)
-
-
Method Detail
-
getNode
final Node<Object> getNode()
The Alchemist Node hosting the ProtelisDevice.
-
isComputationalCycleComplete
final Boolean isComputationalCycleComplete()
- Returns:
true if the Program has finished its last computation, and is ready to send a new message (used for dependency management)
-
getExecutionContext
final AlchemistExecutionContext<P> getExecutionContext()
Provides an access to the underlying org.protelis.vm.ExecutionContext.
- Returns:
the current AlchemistExecutionContext
-
getRandomGenerator
final RandomGenerator getRandomGenerator()
-
getEnvironment
final Environment<Object, P> getEnvironment()
-
getDevice
final ProtelisDevice<P> getDevice()
-
getReaction
final Reaction<Object> getReaction()
-
getOriginalProgram
final String getOriginalProgram()
-
getProgram
final ProtelisProgram getProgram()
-
getRetentionTime
final Double getRetentionTime()
-
getPacketLossDistance
final RealDistribution getPacketLossDistance()
-
asMolecule
final Molecule asMolecule()
- Returns:
the molecule associated with the execution of this program
-
cloneAction
RunProtelisProgram<P> cloneAction(Node<Object> node, Reaction<Object> reaction)
-
getContext
Context getContext()
-
getOutboundDependencies
ImmutableListSet<Dependency> getOutboundDependencies()
-
prepareForComputationalCycle
final Unit prepareForComputationalCycle()
Resets the computation status (used for dependency management).
-
-
-
-