Class PullStrategyPropagationMechanism<U extends java.io.Serializable,​I extends java.io.Serializable,​P>

java.lang.Object
es.uam.eps.ir.relison.diffusion.propagation.PullStrategyPropagationMechanism<U,​I,​P>
Type Parameters:
U - type of the users
I - type of the information pieces
P - type of the parameters.
All Implemented Interfaces:
PropagationMechanism<U,​I,​P>

public class PullStrategyPropagationMechanism<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
extends java.lang.Object
implements PropagationMechanism<U,​I,​P>
Propagation mechanism that follows the pull strategy propagation mechanism. Each iteration, each user selects a single neighbor in the network. It selects that neighbor among those who have not been visited in a certain amount of time. Then, the selected neighbor is the origin of the information pieces which arrive to the user in the current iteration (i.e. the user "pulls" the information from that user).

Reference: A. Demers, D. Greene, C. Hauser, W. Irish, J. Larson. Epidemic algorithms for replicated database maintenance. ACM PODC 1987, pp. 1-12 (1987)

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.Map<U,​java.util.List<U>> lastIterations
    The list of users in the last iterations
    private EdgeOrientation orientation
    The orientation for selecting the neighbors.
    private java.util.Map<U,​java.util.List<U>> propagationList
    For each user, the list of users that user will propagate the information to.
    private int waitTime
    Number of iterations to wait until a profile can be revisited
  • Constructor Summary

    Constructors 
    Constructor Description
    PullStrategyPropagationMechanism​(int waitTime, EdgeOrientation orientation)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    boolean dependsOnInformationPiece()
    This indicates whether the selection of the users depends or not on the information piece which we want to propagate.
    java.util.stream.Stream<U> getUsersToPropagate​(PropagatedInformation information, UserState<U> originUser, Data<U,​I,​P> data)
    Selects the users to which propagate a single piece of information.
    void resetSelections​(Data<U,​I,​P> data)
    It resets the selections that this mechanism did in past iterations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • waitTime

      private final int waitTime
      Number of iterations to wait until a profile can be revisited
    • propagationList

      private java.util.Map<U extends java.io.Serializable,​java.util.List<U extends java.io.Serializable>> propagationList
      For each user, the list of users that user will propagate the information to.
    • lastIterations

      private final java.util.Map<U extends java.io.Serializable,​java.util.List<U extends java.io.Serializable>> lastIterations
      The list of users in the last iterations
    • orientation

      private final EdgeOrientation orientation
      The orientation for selecting the neighbors.
  • Constructor Details

    • PullStrategyPropagationMechanism

      public PullStrategyPropagationMechanism​(int waitTime, EdgeOrientation orientation)
      Constructor.
      Parameters:
      waitTime - number of iterations to wait until a profile can be revisited.
      orientation - the orientation for selecting the neighbors.
  • Method Details

    • getUsersToPropagate

      public java.util.stream.Stream<U> getUsersToPropagate​(PropagatedInformation information, UserState<U> originUser, Data<U,​I,​P> data)
      Description copied from interface: PropagationMechanism
      Selects the users to which propagate a single piece of information.
      Specified by:
      getUsersToPropagate in interface PropagationMechanism<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
      Parameters:
      information - the information piece to propagate.
      originUser - the user who propagates the information piece.
      data - the complete data for the simulation.
      Returns:
      the stream of users to which propagate the single piece of information.
    • resetSelections

      public void resetSelections​(Data<U,​I,​P> data)
      Description copied from interface: PropagationMechanism
      It resets the selections that this mechanism did in past iterations.
      Specified by:
      resetSelections in interface PropagationMechanism<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
      Parameters:
      data - the data.
    • dependsOnInformationPiece

      public boolean dependsOnInformationPiece()
      Description copied from interface: PropagationMechanism
      This indicates whether the selection of the users depends or not on the information piece which we want to propagate.
      Specified by:
      dependsOnInformationPiece in interface PropagationMechanism<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
      Returns:
      true if it depends on the information piece, false if it does not.