Class Spreading

  • All Implemented Interfaces:

    
    public final class Spreading
    
                        
    • Constructor Detail

    • Method Detail

      • boundBroadcast

         final static <T extends Any> T boundBroadcast(Boolean region, T null, Boolean source, Object value)

        Constrain the spreading of broadcast function only within a region.

        Parameters:
        region - whether the function is spreaded or not
        null - default value where f is not spreaded
        source - whether the current device is a source
        Returns:

        broadcast inside the region, return null otherwise

      • boundG

         final static <T extends Any> T boundG(Boolean region, T null, Boolean source, T initial, Function1<Unit, Number> metric, Function1<T, T> accumulate)

        Constrain the spreading of G function only within a region.

        Parameters:
        region - whether the function is spreaded or not
        null - default value where f is not spreaded
        source - whether the current device is a source
        initial - initial value of the computation
        metric - estimate distance from other devices
        accumulate - how to manage the value
        Returns:

        accumulated value

      • channel

         final static Boolean channel(Boolean source, Boolean dest, Number thr)

        Dynamically computes distributed routes between regions of a network, and dynamically adapts to shape and changes of the network topology. The channel is a Boolean field that is true for devices near the shortest route from a given (distributed) source to a (distributed) destination.

        Parameters:
        source - whether the device is a source
        dest - whether the device is a destination
        thr - threshold for Double comparison (e.g.
        Returns:

        true if the device is on the shortest path, false otherwise

      • channelWithObstacle

         final static Boolean channelWithObstacle(Boolean source, Boolean dest, Boolean obstacle, Number thr)

        Dynamically computes distributed routes between regions of a network, and dynamically adapts to shape and changes of the network topology. The channel is a Boolean field that is true for devices near the shortest route from a given (distributed) source to a (distributed) destination.

        Parameters:
        source - whether the device is a source
        dest - whether the device is a destination
        obstacle - whether the device is an obstacle
        thr - threshold for Double comparison (e.g.
        Returns:

        true if the device is on the shortest path, false otherwise

      • channel2

         final static Boolean channel2(Boolean source, Object destination, Number width)

        Channel pattern.

        Parameters:
        source - whether the device is a source
        width - how much to dilate the channel
        Returns:

        true if the device is on the shortest path, false otherwise

      • channel2WithObstacle

         final static Boolean channel2WithObstacle(Boolean source, Object destination, Boolean obstacle, Number width)

        Channel pattern.

        Parameters:
        source - whether the device is a source
        obstacle - whether the device is an obstacle
        width - how much to dilate the channel
        Returns:

        true if the device is on the shortest path, false otherwise

      • closerThan

         final static Boolean closerThan(Boolean source, Number range)
        Parameters:
        source - whether the device is a source
        range - range
        Returns:

        true if the device is closer than range to the source

      • closerThanWithMetric

         final static Boolean closerThanWithMetric(Boolean source, Function1<Unit, Number> metric, Number range)
        Parameters:
        source - whether the device is a source
        metric - how to estimate the distance
        range - range
        Returns:

        true if the device is closer than range to the source

      • crfGradient

         final static Number crfGradient(Boolean source, Number maxHop)

        Self-healing gradient algorithm that reconfigures in O(diameter) time. Requires euclidean metric.

        Parameters:
        source - whether the device is a source
        maxHop - communication max range
        Returns:

        minimum distance from the source

      • crfGradientWithMetric

         final static Number crfGradientWithMetric(Boolean source, Function1<Unit, Number> metric, Number maxHop)

        Self-healing gradient algorithm that reconfigures in O(diameter) time. Requires euclidean metric.

        Parameters:
        source - whether the device is a source
        metric - how to estimate distances without lag
        maxHop - communication max range
        Returns:

        minimum distance from the source

      • bisGradient

         final static Number bisGradient(Boolean source, Number radius, Number speed)

        Self-healing gradient algorithm with single-path reaction speed.

        Parameters:
        source - whether the device is a source
        radius - communication max range
        speed - estimate of single-path speed
        Returns:

        minimum distance from the source

      • bisGradientWithMetric

         final static Number bisGradientWithMetric(Boolean source, Function1<Unit, Number> metric, Number radius, Number speed)

        Self-healing gradient algorithm with single-path reaction speed.

        Parameters:
        source - whether the device is a source
        metric - how to estimate distances without lag
        radius - communication max range
        speed - estimate of single-path speed
        Returns:

        minimum distance from the source

      • dilate

         final static Boolean dilate(Boolean region, Number width)

        Dilate a spatial region.

        Parameters:
        region - whether the device is inside the region
        width - how much to dilate
        Returns:

        dilated region

      • dilateWithMetric

         final static Boolean dilateWithMetric(Boolean region, Function1<Unit, Number> metric, Number width)

        Dilate a spatial region.

        Parameters:
        region - whether the device is inside the region
        metric - how to estimate the distance between devices
        width - how much to dilate
        Returns:

        dilated region

      • directProjection

         final static Boolean directProjection(Boolean source, Boolean obstacle)

        Forecast obstacles along a path to the source.

        Parameters:
        source - whether the device is a source
        obstacle - whether the device is an obstacle
        Returns:

        true if the device encounter an obstacle within the shortest path towards the closest source, false otherwise

      • directProjectionWithMetric

         final static Boolean directProjectionWithMetric(Boolean source, Boolean obstacle, Function1<Unit, Number> metric)

        Forecast obstacles along a path to the source.

        Parameters:
        source - whether the device is a source
        obstacle - whether the device is an obstacle
        metric - how to estimate neighbors distances
        Returns:

        true if the device encounter an obstacle within the shortest path towards the closest source, false otherwise

      • distanceBetween

         final static Number distanceBetween(Boolean source, Boolean dest)

        Smallest distance between source and destination devices.

        Parameters:
        source - whether the current device is a source
        dest - whether the current device is a destination
        Returns:

        smallest distance between source and destination devices

      • distanceBetweenWithMetric

         final static Number distanceBetweenWithMetric(Boolean source, Boolean dest, Function1<Unit, Number> metric)

        Smallest distance between source and destination devices.

        Parameters:
        source - whether the current device is a source
        dest - whether the current device is a destination
        metric - estimate distance from other devices
        Returns:

        smallest distance between source and destination devices

      • roundTripTime

         final static Unit roundTripTime(Number d)

        Estimate worst propagation time considering a message round trip.

        Parameters:
        d - network diameter
      • flexGradient

         final static Unit flexGradient(Boolean source, Number epsilon, Number rate, Number range, Number distortion)

        Flex-Gradient.

        Parameters:
        source - whether the device is a source
        epsilon - tolerance
        rate - communication rate
        range - communication range
        distortion - distortion
      • flexGradientWithMetric

         final static Unit flexGradientWithMetric(Boolean source, Number epsilon, Number rate, Number range, Number distortion, Function1<Unit, Number> metric)

        Flex-Gradient.

        Parameters:
        source - whether the device is a source
        epsilon - tolerance
        rate - communication rate
        range - communication range
        distortion - distortion
        metric - estimate distance from other devices
      • Gnull

         final static <T extends Any> T Gnull(T v, T default)

        Wrapper for G error. For example: G(aBool, aBool, aMetric, (v) -> { Gnull(v, false) ... } assure that G is not broken in case minHood(..., ...) returns Infinity.

        Parameters:
        v - value to be checked
        default - default value to avoid to broke G
        Returns:

        v or default

      • gradcast

         final static <T extends Any> T gradcast(Boolean source, T local, Number gradient, Function1<T, T> accumulate)

        Gradcast.

        Parameters:
        source - whether the device is a source
        local - local value
        gradient - gradient to follow
        accumulate - how to accumulate local values
        Returns:

        accumulated value

      • gradient

         final static <T extends Any> <Error class: unknown class> gradient(Boolean source, T init, Function1<Unit, Number> metric, Function1<T, T> accumulate)

        Spread and extend information with distance from the source region.

        Parameters:
        source - whether the current device is a source
        init - initial value of the computation
        metric - estimate distance from other devices
        accumulate - how to accumulate the value
        Returns:

        distance value and accumulated value

      • multiG

         final static <U extends Any, I extends Any, D extends Any, T extends Any> <Error class: unknown class> ,T,kotlin.jvm.functions.Function1,kotlin.jvm.functions.Function1)>multiG(<Error class: unknown class> sources, T init, Function1<Unit, Number> metric, Function1<T, T> accumulate)

        Run an instance of G from every source.

        Parameters:
        sources - list of active sources
        init - initial value of the computation
        metric - estimate distance from other devices
        accumulate - how to accumulate the value
        Returns:

        list of information from multiple sources

      • multiGradient

         final static <U extends Any, I extends Any, D extends Any, T extends Any> <Error class: unknown class> ,T,kotlin.jvm.functions.Function1,kotlin.jvm.functions.Function1)>multiGradient(<Error class: unknown class> sources, T init, Function1<Unit, Number> metric, Function1<T, T> accumulate)

        Spread and extend information with distance from multiple source regions.

        Parameters:
        sources - list of active sources
        init - initial value of the computation
        metric - estimate distance from other devices
        accumulate - how to accumulate the value
        Returns:

        list of information from multiple gradients

      • neighborhood

         final static Number neighborhood()

        Count the number of neighbors.

        Returns:

        number of neighbors

      • nbrDelay

         final static Number nbrDelay()

        Time forward view.

        Returns:

        expected time from the device computation to neighbor's next computation incorporating that information.

      • nbrLag

         final static Number nbrLag()

        Time backward view.

        Returns:

        how long ago information from neighbors was received.

      • descend

         final static Boolean descend(Boolean source, Number potential)

        Shortest path according to a potential.

        Parameters:
        source - whether the device is a source
        potential - potential
        Returns:

        true if the device is in the shortest path

      • rendezvous

         final static Boolean rendezvous(Boolean source, Boolean dest)

        Shortest path.

        Parameters:
        source - whether the device is the source
        dest - whether the device is the destination
        Returns:

        true if the device is in the shortest path

      • shortestPath

         final static Boolean shortestPath(Boolean source, Object destination)

        Dynamically computes the shortest route between regions of a network, and dynamically adapts to shape and changes of the network topology. The shortest path is a Boolean field that is true for devices near the shortest route from a given (distributed) source to a (distributed) destination.

        Parameters:
        source - whether the device is the source
        Returns:

        true if the device is in the shortest path

      • vm

         final static <T extends Any> T vm(Boolean source, Number range, Function1<Unit, T> f, T null)

        Entry point for a computation.

        Parameters:
        source - whether the device is a source
        range - spreading constraint
        f - entry point
        null - default value
        Returns:

        apply f if device is inside the spreading region, null outside

      • vmWithMetric

         final static <T extends Any> T vmWithMetric(Boolean source, Function1<Unit, Number> metric, Number range, Function1<Unit, T> f, T null)

        Entry point for a computation.

        Parameters:
        source - whether the device is a source
        metric - how to estimate neighbors distances
        range - spreading constraint
        f - entry point
        null - default value
        Returns:

        apply f if device is inside the spreading region, null outside

      • voronoiPatitioning

         final static <T extends Any> T voronoiPatitioning(Boolean source, T id)

        Computing a Voronoi partition is an operation that is frequently useful in distributed systems. Given an initial set of seed devices, a Voronoi partition assigns each device to the partition of the nearest seed, effectively breaking the network up into zones of influence around key elements.

        Parameters:
        source - whether the device is a seed
        id - partition id
        Returns:

        partition of the nearest seed

      • voronoiPatitioningWithMetric

         final static <T extends Any> T voronoiPatitioningWithMetric(Object seed, T id, Function1<Unit, Number> metric)

        Computing a Voronoi partition is an operation that is frequently useful in distributed systems. Given an initial set of seed devices, a Voronoi partition assigns each device to the partition of the nearest seed, effectively breaking the network up into zones of influence around key elements.

        Parameters:
        id - partition id
        metric - how to estimate the distances of the neighbors
        Returns:

        partition of the nearest seed