Class PullPushStrategyPropagationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P>
java.lang.Object
es.uam.eps.ir.relison.diffusion.propagation.PullPushStrategyPropagationMechanism<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 PullPushStrategyPropagationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P> extends java.lang.Object implements PropagationMechanism<U,I,P>
Propagation mechanism for the so-called rumour spreading propagation mechanism. Following this strategy, each user
selects a user each iteration: he catches the information from such user, and shares with him the information he has.
It is a combination of the pull and push propagation mechanisms. A certain amount of time has to pass before a
neighbor is selected again.
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
Edge direction of the neighbors to ask for information.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 PullPushStrategyPropagationMechanism(int waitTime)
Constructor.PullPushStrategyPropagationMechanism(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.
-
Field Details
-
waitTime
private final int waitTimeNumber of iterations to wait until a profile can be revisited. -
orientation
Edge direction of the neighbors to ask for information. -
propagationList
private final java.util.Map<U extends java.io.Serializable,java.util.List<U extends java.io.Serializable>> propagationListFor 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>> lastIterationsThe list of users in the last iterations.
-
-
Constructor Details
-
PullPushStrategyPropagationMechanism
public PullPushStrategyPropagationMechanism(int waitTime)Constructor.- Parameters:
waitTime
- number of iterations to wait until a profile can be revisited.
-
PullPushStrategyPropagationMechanism
Constructor.- Parameters:
waitTime
- number of iterations to wait until a profile can be revisited.orientation
- orientation for selecting the neighbors of the users.
-
-
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 interfacePropagationMechanism<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
Description copied from interface:PropagationMechanism
It resets the selections that this mechanism did in past iterations.- Specified by:
resetSelections
in interfacePropagationMechanism<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 interfacePropagationMechanism<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.
-