![JAR search and dependency download from the Maven repository](/logo.png)
es.uam.eps.ir.relison.diffusion.metrics.AbstractIndividualSimulationMetric 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;
import es.uam.eps.ir.relison.diffusion.data.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* Abstract class for representing global simulation metrics.
*
* @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 features.
*/
public abstract class AbstractIndividualSimulationMetric implements IndividualSimulationMetric
{
/**
* The name of the metric.
*/
private final String name;
/**
* Indicates if the metric has been initialized or not.
*/
protected boolean initialized;
/**
* The data.
*/
protected Data data;
/**
* Constructor.
* @param name the name of the metric.
*/
public AbstractIndividualSimulationMetric(String name)
{
this.name = name;
this.initialized = false;
this.data = null;
}
@Override
public String getName()
{
return name;
}
@Override
public boolean isInitialized()
{
return this.initialized;
}
@Override
public Map calculateIndividuals()
{
Map map = new HashMap<>();
data.getAllUsers().forEach(u -> map.put(u, this.calculate(u)));
return map;
}
@Override
public void initialize(Data data)
{
this.data = data;
this.initialize();
}
/**
* Initializes all the variables needed for computing and updating the
* values of the metric.
*/
protected abstract void initialize();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy