-
public final class accumulationKt
-
-
Method Summary
Modifier and Type Method Description final <T extends Any> Unit
aggregation(T local, Function2<T, T, T> reduce)
Aggregation of local information. final Number
average(Boolean sink, Object value)
Estimate and broadcast the average value within a spatial region. final Number
boundAverage(Boolean sink, Number local, Number range, Number null)
Estimate the average value across a bounded spatial region. final <T extends Any> T
C(Number potential, Function2<T, T, T> reduce, T local, T null)
Aggregate a field of type T within a spanning tree built according to the maximum decrease in potential. final <T extends Any> T
cMultiDivisible(Number potential, T local, T null, Function2<T, T, T> reduce, Function1<T, T> dividend, Function1<T, T> divisor, Function2<T, T, T> fraction)
final <T extends Any> T
cMultiIdempotent(Number potential, Function2<T, T, T> f, T local, T default)
final Number
cMultiMin(Number potential, Number local)
The potential-source converges to the min value. final Number
cMultiMax(Number potential, Number local)
The potential-source converges to the max values. final Number
cMultiSum(Number potential, Number local)
The potential-source converges to the sum of other device values. final Number
consensus(Number init, Function1<Number, Number> f)
Devices agree on a common value. final <T extends Any> T
cossip(Boolean sink, T value, Function2<T, T, T> f)
Gossip a value manipulated according to f. final Number
countDevices(Number potential)
Count the devices. final Number
countDevicesInRegion(Number potential, Boolean condition, Boolean region)
Count the devices in a region. final Number
countDevicesWithCondition(Number potential, Boolean condition)
Count the devices with a given condition. final Object
diameter(Boolean source)
Gossip and estimate the diameter of the connected component joined by the current device. final Object
diameterWithMetric(Boolean source, Function1<Unit, Number> metric)
Gossip and estimate the diameter of the connected component joined by the current device. final Object
diameterInRegion(Boolean source, Object region)
Gossip and estimate the diameter of the connected component joined by the current device. final Object
diameterInRegionWithMetric(Boolean source, Object region, Object metric)
Gossip and estimate the diameter of the connected component joined by the current device. final <T extends Any> <ERROR CLASS>
getAllChildren(Number potential, Object f, Object g, T default)
Apply function to the all the children which potential is greater or equale to the potential of the current device. final <ERROR CLASS>
getAllChildrenIds(Number potential)
Get the ids of all the children with a potential greater or equal the pontential of the current device. final <E extends Any, C extends Any, U extends Any, T extends Any> <ERROR CLASS>
getChildren(Number potential, Function1<ExecutionContext, U> f, Function1<T, T> g, T default)
Apply function to the children of the current device. final <E extends Any, C extends Any, U extends Any, T extends Any> <ERROR CLASS>
getChildrenExtended(Number potential, Function1<Unit, Boolean> condition, Function1<ExecutionContext, U> f, Function1<T, T> g, T default)
Apply function to the children of the current device. final <ERROR CLASS>
getChildrenIds(Number potential)
Get the ids of all the children of the current device. final <E extends Any, C extends Any, T extends Any> Object
getParent(Number potential, Function1<ExecutionContext, T> f)
Find the parent of the current device following the maximum decrease in potential. final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS>
getParentExtended(Number potential, Function1<ExecutionContext, T> f, Function1<U, U> g, U local)
Find the parent of the current device following the maximum decrease in potential. final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS>
getParents(Number potential, Function1<ExecutionContext, T> f, Function1<U, U> g, U local, Object default)
Find the parents of the current device following the decrease in potential. final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS>
getParentsExtended(Number potential, Function1<Number, Boolean> condition, Function1<ExecutionContext, T> f, Function1<U, U> g, U local, Object default)
Find the parents of the current device following the decrease in potential. final Number
getParentId(Number potential)
Find the ID of the current-device parent by following the maximum decrease in potential. final <ERROR CLASS>
getParentIds(Number potential)
Find the IDs of the current-device parents by following a potential decrease. final Boolean
hasNoParent(Number id)
final Boolean
hasParent(Number id)
final Number
imRoot()
final Unit
idUnion(Object idField)
This function MUST NOT be public as it is an utilities for both protelis:coord:accumulation and protelis:coord:tree. final Number
laplacianConsensus(Number init, Number epsilon)
Laplacian consensus. final Number
noParent()
final <T extends Any> T
summarize(Boolean sink, Function2<T, T, T> reduce, T local, T null)
Broadcast the value accumulated by the sink. final <T extends Any> T
summarizeWithMetric(Boolean sink, Function1<Unit, Number> metric, Object accumulate, T local, T null)
Broadcast the value accumulated by the sink. final <T extends Any> T
summarizeWithPotential(Number potential, Number zero, Object accumulate, T local, T null)
Broadcast the value accumulated by the sink. final Unit
summarizeWithPotentialExt(Object potential, Object zero, Object accumulate, Object f, Object local, Object null)
final <T extends Any> T
quorumSensing(Number potential, Object zero, Number thr, Function1<Number, T> under, Function1<Number, T> over)
Quorum sensing. final <T extends Any> T
quorumSensingWithCondition(Number potential, Object zero, Number thr, Boolean condition, Function1<Number, T> under, Function1<Number, T> over)
Quorum sensing. -
-
Method Detail
-
aggregation
final <T extends Any> Unit aggregation(T local, Function2<T, T, T> reduce)
Aggregation of local information.
- Parameters:
local
- local informationreduce
- how to aggregate information
-
average
final Number average(Boolean sink, Object value)
Estimate and broadcast the average value within a spatial region.
- Parameters:
sink
- whether the device is the root of the spanning tree
-
boundAverage
final Number boundAverage(Boolean sink, Number local, Number range, Number null)
Estimate the average value across a bounded spatial region.
- Parameters:
sink
- whether the device is the root of the spanning treelocal
- local valuerange
- region rangenull
- default value
-
C
final <T extends Any> T C(Number potential, Function2<T, T, T> reduce, T local, T null)
Aggregate a field of type T within a spanning tree built according to the maximum decrease in potential. Accumulate the potential according to the reduce function.
- Parameters:
potential
- gradient of which gives aggregation directionreduce
- functionlocal
- local valuenull
- evaluated when the field is empty
-
cMultiDivisible
final <T extends Any> T cMultiDivisible(Number potential, T local, T null, Function2<T, T, T> reduce, Function1<T, T> dividend, Function1<T, T> divisor, Function2<T, T, T> fraction)
- Parameters:
potential
- gradient of which gives aggregation directionlocal
- local valuenull
- null valuereduce
- how to aggregate valuesdividend
- dividenddivisor
- divisorfraction
- how to divide dividend by the divisor
-
cMultiIdempotent
final <T extends Any> T cMultiIdempotent(Number potential, Function2<T, T, T> f, T local, T default)
- Parameters:
potential
- accumulate values descending this potentialf
- how to accumulate valueslocal
- local valuedefault
- default value
-
cMultiMin
final Number cMultiMin(Number potential, Number local)
The potential-source converges to the min value.
- Parameters:
potential
- minimize values descending this potentiallocal
- value
-
cMultiMax
final Number cMultiMax(Number potential, Number local)
The potential-source converges to the max values.
- Parameters:
potential
- minimize values descending this potentiallocal
- value
-
cMultiSum
final Number cMultiSum(Number potential, Number local)
The potential-source converges to the sum of other device values. C collects values over a spanning tree. Even small perturbations can cause loss or duplication of values with major transient impact on its result. When the accumulation operation for C is either idempotent (e.g., logical and, or) or separable (e.g., summation), this can be mitigated by using all paths down the potential function rather than just one. Can implement any other idempotent or separable function.
- Parameters:
potential
- sum values descending this potentiallocal
- value
-
consensus
final Number consensus(Number init, Function1<Number, Number> f)
Devices agree on a common value.
- Parameters:
init
- initial device valuef
- how to determine consensus
-
cossip
final <T extends Any> T cossip(Boolean sink, T value, Function2<T, T, T> f)
Gossip a value manipulated according to f.
- Parameters:
sink
- whether the device is the root of the spanning treevalue
- what to gossipf
- how to manipulate value
-
countDevices
final Number countDevices(Number potential)
Count the devices.
- Parameters:
potential
- gradient of which gives aggregation direction
-
countDevicesInRegion
final Number countDevicesInRegion(Number potential, Boolean condition, Boolean region)
Count the devices in a region.
- Parameters:
potential
- gradient of which gives aggregation directioncondition
- device discriminantregion
- region discriminant
-
countDevicesWithCondition
final Number countDevicesWithCondition(Number potential, Boolean condition)
Count the devices with a given condition.
- Parameters:
potential
- gradient of which gives aggregation directioncondition
- discriminant
-
diameter
final Object diameter(Boolean source)
Gossip and estimate the diameter of the connected component joined by the current device.
- Parameters:
source
- source of the connected component
-
diameterWithMetric
final Object diameterWithMetric(Boolean source, Function1<Unit, Number> metric)
Gossip and estimate the diameter of the connected component joined by the current device.
- Parameters:
source
- source of the connected componentmetric
- metric
-
diameterInRegion
final Object diameterInRegion(Boolean source, Object region)
Gossip and estimate the diameter of the connected component joined by the current device.
- Parameters:
source
- source of the connected component
-
diameterInRegionWithMetric
final Object diameterInRegionWithMetric(Boolean source, Object region, Object metric)
Gossip and estimate the diameter of the connected component joined by the current device.
- Parameters:
source
- source of the connected component
-
getAllChildren
final <T extends Any> <ERROR CLASS> getAllChildren(Number potential, Object f, Object g, T default)
Apply function to the all the children which potential is greater or equale to the potential of the current device. A child may have multiple parents.
- Parameters:
potential
- potential to be followeddefault
- default value for devices which are not children
-
getAllChildrenIds
final <ERROR CLASS> getAllChildrenIds(Number potential)
Get the ids of all the children with a potential greater or equal the pontential of the current device.
- Parameters:
potential
- potential to be followed
-
getChildren
final <E extends Any, C extends Any, U extends Any, T extends Any> <ERROR CLASS> getChildren(Number potential, Function1<ExecutionContext, U> f, Function1<T, T> g, T default)
Apply function to the children of the current device. Use this function if every child has a single parent, see getAllChildren otherwise.
- Parameters:
potential
- potential to be followedf
- function to be applied to the childg
- function to be applied to the child valuedefault
- default value for devices which are not children
-
getChildrenExtended
final <E extends Any, C extends Any, U extends Any, T extends Any> <ERROR CLASS> getChildrenExtended(Number potential, Function1<Unit, Boolean> condition, Function1<ExecutionContext, U> f, Function1<T, T> g, T default)
Apply function to the children of the current device. A child may have multiple parents.
- Parameters:
potential
- potential to be followedcondition
- which children should be consideredf
- function to be applied to the childg
- function to be applied to the child valuedefault
- default value for devices which are not children
-
getChildrenIds
final <ERROR CLASS> getChildrenIds(Number potential)
Get the ids of all the children of the current device.
- Parameters:
potential
- potential to be followed
-
getParent
final <E extends Any, C extends Any, T extends Any> Object getParent(Number potential, Function1<ExecutionContext, T> f)
Find the parent of the current device following the maximum decrease in potential.
- Parameters:
potential
- potentialf
- what to do with the parent
-
getParentExtended
final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS> getParentExtended(Number potential, Function1<ExecutionContext, T> f, Function1<U, U> g, U local)
Find the parent of the current device following the maximum decrease in potential.
- Parameters:
potential
- potentialf
- what to do with the parentg
- what to do with the valuelocal
- local value
-
getParents
final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS> getParents(Number potential, Function1<ExecutionContext, T> f, Function1<U, U> g, U local, Object default)
Find the parents of the current device following the decrease in potential.
- Parameters:
potential
- potentialf
- what to do with the parentg
- what to do with the valuelocal
- local value
-
getParentsExtended
final <E extends Any, C extends Any, T extends Any, U extends Any> <ERROR CLASS> getParentsExtended(Number potential, Function1<Number, Boolean> condition, Function1<ExecutionContext, T> f, Function1<U, U> g, U local, Object default)
Find the parents of the current device following the decrease in potential.
- Parameters:
potential
- potentialcondition
- how to determine parent devicesf
- what to do with the parentg
- what to do with the valuelocal
- local value
-
getParentId
final Number getParentId(Number potential)
Find the ID of the current-device parent by following the maximum decrease in potential.
- Parameters:
potential
- potential
-
getParentIds
final <ERROR CLASS> getParentIds(Number potential)
Find the IDs of the current-device parents by following a potential decrease.
- Parameters:
potential
- potential
-
hasNoParent
final Boolean hasNoParent(Number id)
- Parameters:
id
- device id
-
idUnion
final Unit idUnion(Object idField)
This function MUST NOT be public as it is an utilities for both protelis:coord:accumulation and protelis:coord:tree. This function reduces a field of ids
-
laplacianConsensus
final Number laplacianConsensus(Number init, Number epsilon)
Laplacian consensus.
- Parameters:
init
- initial valueepsilon
- epsilon
-
summarize
final <T extends Any> T summarize(Boolean sink, Function2<T, T, T> reduce, T local, T null)
Broadcast the value accumulated by the sink. Example: 'summarize(distanceTo(sink), sum, 1, 0)' broadcast the sum number of devices in a region.
- Parameters:
sink
- whether the device should collect the aggregated informationreduce
- how to aggregatelocal
- local valuenull
- default value
-
summarizeWithMetric
final <T extends Any> T summarizeWithMetric(Boolean sink, Function1<Unit, Number> metric, Object accumulate, T local, T null)
Broadcast the value accumulated by the sink.
- Parameters:
sink
- whether the device should collect the aggregated informationmetric
- how to estimate distance to the other devicelocal
- local valuenull
- default value
-
summarizeWithPotential
final <T extends Any> T summarizeWithPotential(Number potential, Number zero, Object accumulate, T local, T null)
Broadcast the value accumulated by the sink.
- Parameters:
potential
- potentialzero
- value representing null potentiallocal
- local valuenull
- default value
-
summarizeWithPotentialExt
final Unit summarizeWithPotentialExt(Object potential, Object zero, Object accumulate, Object f, Object local, Object null)
-
quorumSensing
final <T extends Any> T quorumSensing(Number potential, Object zero, Number thr, Function1<Number, T> under, Function1<Number, T> over)
Quorum sensing.
- Parameters:
potential
- gradient of which gives aggregation directionthr
- thresholdunder
- what to do if quorum is under thresholdover
- what to do otherwise
-
quorumSensingWithCondition
final <T extends Any> T quorumSensingWithCondition(Number potential, Object zero, Number thr, Boolean condition, Function1<Number, T> under, Function1<Number, T> over)
Quorum sensing.
- Parameters:
potential
- gradient of which gives aggregation directionthr
- thresholdcondition
- whether to count a device or notunder
- what to do if quorum is under thresholdover
- what to do otherwise
-
-
-
-