Class InconsistencyMeasureEvaluator<T extends Formula,​U extends BeliefSet<T,​?>>

  • Type Parameters:
    T - The type of formulas belief sets are made of
    U - The type of belief sets that are evaluated

    public class InconsistencyMeasureEvaluator<T extends Formula,​U extends BeliefSet<T,​?>>
    extends java.lang.Object
    This class provides functionality to quickly load or generate sample datasets and to use them to compare the results and performances of different inconsistency measure implementations.
    Author:
    Anna Gessler
    • Constructor Detail

      • InconsistencyMeasureEvaluator

        public InconsistencyMeasureEvaluator()
        Create a new empty InconsistencyMeasureEvaluator.
      • InconsistencyMeasureEvaluator

        public InconsistencyMeasureEvaluator​(BeliefSetInconsistencyMeasure<T> i)
        Create a new InconsistencyMeasureEvaluator with the given inconsistency measure.
        Parameters:
        i - an inconsistency measure
      • InconsistencyMeasureEvaluator

        public InconsistencyMeasureEvaluator​(java.util.Collection<BeliefSetInconsistencyMeasure<T>> measures)
        Create a new InconsistencyMeasureEvaluator with the given inconsistency measures.
        Parameters:
        measures - some inconsistency measures
      • InconsistencyMeasureEvaluator

        public InconsistencyMeasureEvaluator​(java.util.Collection<U> dataset,
                                             BeliefSetInconsistencyMeasure<T> i)
        Create a new InconsistencyMeasureEvaluator with the given dataset and the given inconsistency measure.
        Parameters:
        dataset - collection of belief bases
        i - an inconsistency measure
      • InconsistencyMeasureEvaluator

        public InconsistencyMeasureEvaluator​(java.util.Collection<U> dataset,
                                             java.util.Collection<BeliefSetInconsistencyMeasure<T>> measures)
        Create a new InconsistencyMeasureEvaluator with the given dataset and the given inconsistency measures.
        Parameters:
        dataset - collection of belief bases
        measures - some inconsistency measures
    • Method Detail

      • addInconsistencyMeasure

        public void addInconsistencyMeasure​(BeliefSetInconsistencyMeasure<T> i)
        Adds the given inconsistency measure.
        Parameters:
        i - BeliefSetInconsistencyMeasure
      • setTimeFunction

        public void setTimeFunction​(java.util.function.Supplier<java.lang.Long> timeFunction)
        Sets the function used to measure time in ms.
        Parameters:
        timeFunction - some time function
      • setTimeout

        public void setTimeout​(long timeout)
        Sets the timeout.
        Parameters:
        timeout - in ms, must be non-negative
      • addKnowledgeBase

        public void addKnowledgeBase​(U kb)
        Adds the given knowledge base to the testing dataset.
        Parameters:
        kb - knowledge base
      • addKnowledgeBases

        public void addKnowledgeBases​(java.util.List<U> kbs)
        Adds the given knowledge bases to the testing dataset.
        Parameters:
        kbs - knowledge bases
      • parseDatasetFromPath

        public void parseDatasetFromPath​(java.lang.String path,
                                         Parser<U,​T> p,
                                         int n)
                                  throws java.io.FileNotFoundException,
                                         ParserException,
                                         java.io.IOException
        Parse all knowledge bases from files in the given folder and add them to the testing dataset.
        Parameters:
        path - that contains knowledge bases (one knowledge base per file)
        p - appropriate parser for the format the knowledge bases are saved in (i.e. DimacsParser for files in Dimacs format, PlParser for files in TweetyProject pl Syntax)
        n - maximum number of knowledge bases to parse
        Throws:
        java.io.IOException - if some error occurs
        ParserException - if some error occurs
        java.io.FileNotFoundException - if some error occurs
      • addFromSampler

        public void addFromSampler​(java.util.Iterator<U> sampler,
                                   int n)
        Add n knowledge bases from the given iterator (e.g., a random sampler) to the testing dataset.
        Parameters:
        sampler - some sampler
        n - how many knowledge bases will be added at most
      • compareMeasures

        public InconsistencyMeasureReport<T,​U> compareMeasures()
        Computes inconsistency values for all belief bases in the dataset using all inconsistency measures and returns a report of the results.
        Returns:
        InconsistencyMeasureReport
      • getDataset

        public java.util.List<U> getDataset()
        Returns:
        the dataset of this evaluator
      • getDatasetWithNames

        public java.util.List<Pair<java.lang.String,​U>> getDatasetWithNames()
        Returns:
        the dataset of this evaluator, where each entry is the (file-)name and the corresponding kb