Class UserFeatureGiniComplement<U extends java.io.Serializable,​I extends java.io.Serializable,​F>

java.lang.Object
es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric<U,​I,​F>
es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureGlobalSimulationMetric<U,​I,​F>
es.uam.eps.ir.relison.diffusion.metrics.features.global.UserFeatureGiniComplement<U,​I,​F>
Type Parameters:
U - type of the users.
I - type of the information pieces.
F - type of the user / information pieces features.
All Implemented Interfaces:
GlobalSimulationMetric<U,​I,​F>, SimulationMetric<U,​I,​F>

public class UserFeatureGiniComplement<U extends java.io.Serializable,​I extends java.io.Serializable,​F>
extends AbstractFeatureGlobalSimulationMetric<U,​I,​F>
Metric that computes the complement of the Gini coefficient over the (user, feature) pairs. If we use information pieces features (i.e. hashtags) the (user, feature) value counts the number of times that the user has received information pieces using that feature. In case we use user features, it is just how many times the user has received information from users with that feature.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private double freqsum
    Sum of the frequencies.
    private java.util.Map<U,​java.util.Map<F,​java.lang.Double>> frequencies
    Map for storing the frequency of the user/feature pairs.
    private static java.lang.String GINI
    Metric name.
    private double mainsum
    Main sum for the Gini coefficient.
    private java.util.Map<java.lang.Double,​java.lang.Long> maximumPos
    Auxiliar map for computing Gini coefficient (contains the maximum position for each frequency).
    private java.util.Map<java.lang.Double,​java.lang.Long> minimumPos
    Auxiliar map for computing Gini coefficient (contains the minimum position for each frequency).
    private long size
    Total number of pairs.
    private boolean unique
    Indicates if a piece of information is considered once (or each time it appears if false).
    private java.util.TreeSet<java.lang.Double> values
    Auxiliar set containing the possible values

    Fields inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric

    data, initialized
  • Constructor Summary

    Constructors 
    Constructor Description
    UserFeatureGiniComplement​(java.lang.String feature, boolean userFeat, boolean unique)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    double calculate()
    Calculates the metric for the current state of the simulation.
    void clear()
    Resets the metric.
    private double increaseIntermediate​(double freq)
    Computes the increment for frequencies between old and new.
    private double increaseNew​(double newfreq)
    Computes the increment for new frequencies.
    private double increaseOld​(double oldfreq)
    Computes the increment for old frequencies.
    protected void initialize()
    Initializes all the variables needed for computing and updating the values of the metric.
    protected void updateInfoFeature​(Iteration<U,​I,​F> 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.
    protected void updateUserFeature​(Iteration<U,​I,​F> 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.

    Methods inherited from class es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureGlobalSimulationMetric

    getFeature, update, usesUserFeatures

    Methods inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric

    getName, initialize, isInitialized

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface es.uam.eps.ir.relison.diffusion.metrics.SimulationMetric

    calculate, initialize
  • Field Details

    • GINI

      private static final java.lang.String GINI
      Metric name.
      See Also:
      Constant Field Values
    • freqsum

      private double freqsum
      Sum of the frequencies.
    • mainsum

      private double mainsum
      Main sum for the Gini coefficient.
    • size

      private long size
      Total number of pairs.
    • frequencies

      private final java.util.Map<U extends java.io.Serializable,​java.util.Map<F,​java.lang.Double>> frequencies
      Map for storing the frequency of the user/feature pairs.
    • minimumPos

      private final java.util.Map<java.lang.Double,​java.lang.Long> minimumPos
      Auxiliar map for computing Gini coefficient (contains the minimum position for each frequency).
    • maximumPos

      private final java.util.Map<java.lang.Double,​java.lang.Long> maximumPos
      Auxiliar map for computing Gini coefficient (contains the maximum position for each frequency).
    • values

      private final java.util.TreeSet<java.lang.Double> values
      Auxiliar set containing the possible values
    • unique

      private final boolean unique
      Indicates if a piece of information is considered once (or each time it appears if false).
  • Constructor Details

    • UserFeatureGiniComplement

      public UserFeatureGiniComplement​(java.lang.String feature, boolean userFeat, boolean unique)
      Constructor.
      Parameters:
      userFeat - true if we are using a user feature, false if we are using an information piece feature.
      feature - the name of the feature.
      unique - true if a piece of information is considered once, false if it is considered each time it appears.
  • Method Details

    • updateUserFeature

      protected void updateUserFeature​(Iteration<U,​I,​F> iteration)
      Description copied from class: AbstractFeatureGlobalSimulationMetric
      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.
      Specified by:
      updateUserFeature in class AbstractFeatureGlobalSimulationMetric<U extends java.io.Serializable,​I extends java.io.Serializable,​F>
      Parameters:
      iteration - the new iteration.
    • updateInfoFeature

      protected void updateInfoFeature​(Iteration<U,​I,​F> iteration)
      Description copied from class: AbstractFeatureGlobalSimulationMetric
      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.
      Specified by:
      updateInfoFeature in class AbstractFeatureGlobalSimulationMetric<U extends java.io.Serializable,​I extends java.io.Serializable,​F>
      Parameters:
      iteration - the new iteration.
    • initialize

      protected void initialize()
      Description copied from class: AbstractGlobalSimulationMetric
      Initializes all the variables needed for computing and updating the values of the metric.
      Specified by:
      initialize in class AbstractGlobalSimulationMetric<U extends java.io.Serializable,​I extends java.io.Serializable,​F>
    • calculate

      public double calculate()
      Description copied from interface: SimulationMetric
      Calculates the metric for the current state of the simulation.
      Returns:
      the value of the metric for the current state of the simulation
    • clear

      public void clear()
      Description copied from interface: SimulationMetric
      Resets the metric.
    • increaseOld

      private double increaseOld​(double oldfreq)
      Computes the increment for old frequencies.
      Parameters:
      oldfreq - old frequency.
      Returns:
      the variation for the old frequency.
    • increaseNew

      private double increaseNew​(double newfreq)
      Computes the increment for new frequencies.
      Parameters:
      newfreq - new frequency.
      Returns:
      the variation for the new frequency.
    • increaseIntermediate

      private double increaseIntermediate​(double freq)
      Computes the increment for frequencies between old and new.
      Parameters:
      freq - new frequency.
      Returns:
      the variation for the new frequency.