Class ExponentialDecayExpirationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P>
java.lang.Object
es.uam.eps.ir.relison.diffusion.expiration.ExponentialDecayExpirationMechanism<U,I,P>
- Type Parameters:
U- type of the users.I- type of the information.P- type of the parameters.
- All Implemented Interfaces:
ExpirationMechanism<U,I,P>
public class ExponentialDecayExpirationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P> extends java.lang.Object implements ExpirationMechanism<U,I,P>
Expiration mechanism that increases exponentially the probability of discarding
an information piece as the number of iterations since its creation increases.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ExponentialDecayExpirationMechanism(double halfLife)Constructor. -
Method Summary
Modifier and Type Method Description private doubleexpdecay(long time)Computes the probability that the information piece stays in the received list.java.util.stream.Stream<java.lang.Integer>expire(UserState<U> user, Data<U,I,P> data, int numIter, java.lang.Long timestamp)Obtains the information that has expired in the current iteration.
-
Field Details
-
Constructor Details
-
ExponentialDecayExpirationMechanism
public ExponentialDecayExpirationMechanism(double halfLife)Constructor.- Parameters:
halfLife- the time required for the piece to have p = 0.5 of being removed
-
-
Method Details
-
expire
public java.util.stream.Stream<java.lang.Integer> expire(UserState<U> user, Data<U,I,P> data, int numIter, java.lang.Long timestamp)Description copied from interface:ExpirationMechanismObtains the information that has expired in the current iteration.- Specified by:
expirein interfaceExpirationMechanism<U extends java.io.Serializable,I extends java.io.Serializable,P>- Parameters:
user- UserState to check.data- The full data.numIter- Current iteration.timestamp- moment of time represented by the iteration.- Returns:
- A stream with the identifiers of all the received information pieces that have expired.
-
expdecay
private double expdecay(long time)Computes the probability that the information piece stays in the received list.- Parameters:
time- the difference between creation time and current time.- Returns:
- the probability that the information piece stays in the received list.
-