es.uam.eps.ir.relison.diffusion.selections.AbstractSelectionMechanism Maven / Gradle / Ivy
/*
* 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.selections;
import es.uam.eps.ir.relison.diffusion.data.Data;
import es.uam.eps.ir.relison.diffusion.data.PropagatedInformation;
import es.uam.eps.ir.relison.diffusion.simulation.SimulationState;
import es.uam.eps.ir.relison.diffusion.simulation.UserState;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Stream;
/**
* Abstract implementation of a selection mechanism.
*
* @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 parameters.
*/
public abstract class AbstractSelectionMechanism implements SelectionMechanism
{
@Override
public Selection select(UserState user, Data data, SimulationState state, int numIter, Long timestamp)
{
// For each user, we select:
// a) some pieces of information originally owned by the user.
List ownInfo = this.getOwnInformation(user, data, state, numIter, timestamp);
// b) some pieces of information received by the user.
List recInfo = this.getReceivedInformation(user, data, state, numIter, timestamp);
// c) some pieces of information that the user did propagate earlier, but now wants to propagate again.
List repropInfo = this.getRepropagatedInformation(user, data, state, numIter, timestamp);
return new Selection(ownInfo,recInfo,repropInfo);
}
/**
* Obtains the list of own information pieces to repropagate.
* @param user the user to analyze.
* @param data the full data.
* @param state current simulation state.
* @param numIter the iteration number.
* @param timestamp the timestamp for the current simulation.
* @return a selection of the own information pieces to be propagated.
*/
protected abstract List getOwnInformation(UserState user, Data data, SimulationState state, int numIter, Long timestamp);
/**
* Obtains the list of received information pieces to repropagate.
* @param user the user to analyze.
* @param data the full data.
* @param state the iteration number.
* @param numIter number of the iteration.
* @param timestamp the timestamp for the current simulation.
* @return a selection of the received information pieces to be propagated.
*/
protected abstract List getReceivedInformation(UserState user, Data data, SimulationState state, int numIter, Long timestamp);
/**
* Obtains the list of propagated information pieces to repropagate.
* @param user the user to analyze.
* @param data the full data.
* @param state current simulation state.
* @param numIter number of the iteration.
* @param timestamp the timestamp for the current simulation.
* @return a selection of the information pieces to repropagate.
*/
protected abstract List getRepropagatedInformation(UserState user, Data data, SimulationState state, int numIter, Long timestamp);
@Override
public Stream getSelectableUsers(Data data, SimulationState state, int numIter, Long timestamp)
{
return data.getAllUsers();
}
}