Class PushStrategyPropagationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P>
java.lang.Object
es.uam.eps.ir.relison.diffusion.propagation.PushStrategyPropagationMechanism<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 PushStrategyPropagationMechanism<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 push 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 destination of the information pieces in the current iteration (i.e. the user
"pushes" the information to 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>>lastIterationsThe list of users in the last iterations.private EdgeOrientationorientationThe orientation for selecting the neighbors.private java.util.Map<U,java.util.List<U>>propagationListFor each user, the list of users that user will propagate the information to.private intwaitTimeNumber of iterations to wait until a profile can be revisited. -
Constructor Summary
Constructors Constructor Description PushStrategyPropagationMechanism(int waitTime, EdgeOrientation orientation)Constructor. -
Method Summary
Modifier and Type Method Description booleandependsOnInformationPiece()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.voidresetSelections(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. -
propagationList
private 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. -
orientation
The orientation for selecting the neighbors.
-
-
Constructor Details
-
PushStrategyPropagationMechanism
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:PropagationMechanismSelects the users to which propagate a single piece of information.- Specified by:
getUsersToPropagatein 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:PropagationMechanismIt resets the selections that this mechanism did in past iterations.- Specified by:
resetSelectionsin interfacePropagationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P>- Parameters:
data- the data.
-
dependsOnInformationPiece
public boolean dependsOnInformationPiece()Description copied from interface:PropagationMechanismThis indicates whether the selection of the users depends or not on the information piece which we want to propagate.- Specified by:
dependsOnInformationPiecein 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.
-