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

es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureIndividualSimulationMetric 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.metrics.features;

import es.uam.eps.ir.relison.diffusion.metrics.AbstractIndividualSimulationMetric;
import es.uam.eps.ir.relison.diffusion.simulation.Iteration;

import java.io.Serializable;

/**
 * Class that represents an individual metric that considers the existence of several features.
 * We differ two types of features:
 * 
 * 
    *
  • User parameters: (Ex.: Communities) In this case, we take the values of the parameter * for the creators of the received information pieces.
  • *
  • Information parameters: (Ex: hashtags) In this case, we take the values of the parameters * for the different information pieces which are received and observed by each individual user.
  • *
* * @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 AbstractFeatureIndividualSimulationMetric extends AbstractIndividualSimulationMetric { /** * Indicates if the parameter we are analyzing depends on the user (true) or the information piece (false). */ private final boolean userParam; /** * Parameter name. */ private final String parameter; /** * Constructor. * @param name the name of the metric. * @param userParam true if it uses the parameters of the users, false if it uses the parameters of the information pieces. * @param parameter the name of the parameter. */ public AbstractFeatureIndividualSimulationMetric(String name, boolean userParam, String parameter) { super(name); this.userParam = userParam; this.parameter = parameter; } /** * Indicates if we are using a user parameter (true) or an information piece parameter (false). * @return true if we use a user parameter, false if we use an information piece parameter. */ protected boolean usesUserParam() { return userParam; } /** * Obtains the name of the parameter we are using. * @return the name of the parameter. */ protected String getParameter() { return parameter; } @Override public void update(Iteration iteration) { if(this.isInitialized()) { if(this.usesUserParam()) this.updateUserFeatures(iteration); else this.updateInfoFeatures(iteration); } } /** * Updates the necessary variables to compute a metric, in case the feature * values we are using belongs to the creators of the information pieces received * by the users in the network. * @param iteration the new iteration. */ protected abstract void updateUserFeatures(Iteration iteration); /** * Updates the necessary variables to compute a metric, in case the feature * values we are using belong to the information pieces received by the users in * the network. * @param iteration the new iteration. */ protected abstract void updateInfoFeatures(Iteration iteration); }