package de.ugoe.cs.eventbench.coverage; import java.security.InvalidParameterException; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import de.ugoe.cs.eventbench.data.Event; import de.ugoe.cs.eventbench.models.IStochasticProcess; /** *
* This class calculates various types of sequence coverage in relation to a * collection of observed sequences. *
* * @author Steffen Herbold * @version 1.0 */ public class CoverageCalculatorObserved { /** ** Sequences for which the coverage is calculated. *
*/ private final Collection* Observed sequences that are baseline for the coverage calculation. *
*/ private final Collection* Length of the subsequences in relation to which the covarage is * calculated. *
*/ private final int length; /** ** All subsequences of {@link #length} of {@link #sequences}. *
*/ private Collection* All subsequences of {@link #length} of {@link #observedSequences}. *
*/ private Collection* Constructor. Creates a new CoverageCalculatorObserved for given * collections of observed sequences and generated sequences. *
* * @param observedSequences * observed sequences in relation to which the coverage is * calculated; must not be null * @param sequences * sequences for which the coverage is calculated; must not be * null * @param length * length of the subsequences for which the coverage is analyzed; * must be >0 * @throws InvalidParameterException * thrown if observedSequences or sequences is null or length * less than or equal to 0 */ public CoverageCalculatorObserved( Collection* Calculates the percentage of subsequences of length k that occur, with * reference to those that were observed. *
* * @return coverage percentage */ public double getCoverageObserved() { createSubSeqs(); Collection* Calculates the weight of subsequences of length k that occur, with * reference to those that were observed. *
* * @param process * stochastic process in reference to which the weight is * calculated * @return coverage percentage */ public double getCoverageObservedWeigth(IStochasticProcess process) { createSubSeqs(); Map* Calculates the percentage of generated subsequences of length k that * occur and have not been observed, with reference to all generated * subsequences. *
* * @return coverage percentage */ public double getNewPercentage() { createSubSeqs(); Collection* Calculates the percentage of generated subsequences of length k that * occur and have not been observed, with references to all possible new * subsequences. *
* * @param process * stochastic process which is used to determine which * subsequences are possible * @return coverage percentage * @throws InvalidParameterException * thrown if process is null */ public double getCoveragePossibleNew(IStochasticProcess process) { if (process == null) { throw new InvalidParameterException("process must not be null"); } createSubSeqs(); Collection* Calculates the weight of generated subsequences of length k that occur * and have not been observed, with references to all possible new * subsequences. *
* * @param process * stochastic process which is used to determine the weights and * which subsequences are possible * @return coverage percentage * @throws InvalidParameterException * thrown if process is null */ public double getCoveragePossibleNewWeight(IStochasticProcess process) { if (process == null) { throw new InvalidParameterException("process must not be null"); } createSubSeqs(); Collection* Returns the number of covered subsequences of length k. *
* * @return number of covered subsequences */ public int getNumObserved() { createSubSeqs(); return subSeqsObserved.size(); } /** ** Returns the number of covered subsequences of length k. *
* * @return number of covered subsequences */ public int getNumCovered() { createSubSeqs(); return subSeqsGenerated.size(); } public int getNumNew() { createSubSeqs(); Collection* Helper function that calcuates the subsequences of length k that have * been observed and generated. *
*/ private void createSubSeqs() { if (subSeqsObserved == null) { subSeqsObserved = SequenceTools.containedSubSequences( observedSequences, length); } if (subSeqsGenerated == null) { subSeqsGenerated = SequenceTools.containedSubSequences(sequences, length); } } }