All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.uam.eps.ir.relison.diffusion.protocols.TemporalProtocol Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2020 Information Retrieval Group at Universidad Autónoma
 * de Madrid, http://ir.ii.uam.es
 * 
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  License, v. 2.0. If a copy of the MPL was not distributed with this
 *  file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package es.uam.eps.ir.relison.diffusion.protocols;

import es.uam.eps.ir.relison.diffusion.expiration.AllNotRealPropagatedTimestampExpirationMechanism;
import es.uam.eps.ir.relison.diffusion.propagation.AllNeighborsPropagationMechanism;
import es.uam.eps.ir.relison.diffusion.selections.LooseTimestampBasedSelectionMechanism;
import es.uam.eps.ir.relison.diffusion.selections.PureTimestampBasedSelectionMechanism;
import es.uam.eps.ir.relison.diffusion.sight.AllNotDiscardedNorPropagatedSightMechanism;
import es.uam.eps.ir.relison.diffusion.update.NewestUpdateMechanism;
import es.uam.eps.ir.relison.graph.edges.EdgeOrientation;

import java.io.Serializable;

/**
 * Simulation protocol that considers the timestamps. This protocol aims at showing the true propagation
 * of information through the network: it only propagates new information when the simulation iteration
 * represents the timestamp of creation of the information piece, and a user propagates contents from
 * other users only if they had been previously propagated in real life.
 *
 * @author Javier Sanz-Cruzado ([email protected])
 * @author Pablo Castells ([email protected])
 *
 * @param  type of the users.
 * @param  type of the information pieces.
 * @param  type of the user and information pieces features.
 */
public class TemporalProtocol extends Protocol
{
    /**
     * Constructor.
     * @param pure true if information received from other users cannot be repropagated after the timestamp
     * of the repropagation has been visited, false if it can.
     */
    public TemporalProtocol(boolean pure)
    {
        super ((pure) ? new PureTimestampBasedSelectionMechanism<>() : new LooseTimestampBasedSelectionMechanism<>(),
               new AllNotRealPropagatedTimestampExpirationMechanism<>(),
               new NewestUpdateMechanism(),
               new AllNeighborsPropagationMechanism<>(EdgeOrientation.IN),
               new AllNotDiscardedNorPropagatedSightMechanism<>());
    }
}