- java.lang.Object
-
- org.tweetyproject.logics.commons.analysis.InconsistencyMeasureEvaluator<T,U>
-
- Type Parameters:
T
- The type of formulas belief sets are made ofU
- 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 Summary
Constructors Constructor Description InconsistencyMeasureEvaluator()
Create a new empty InconsistencyMeasureEvaluator.InconsistencyMeasureEvaluator(java.util.Collection<BeliefSetInconsistencyMeasure<T>> measures)
Create a new InconsistencyMeasureEvaluator with the given inconsistency measures.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.InconsistencyMeasureEvaluator(java.util.Collection<U> dataset, BeliefSetInconsistencyMeasure<T> i)
Create a new InconsistencyMeasureEvaluator with the given dataset and the given inconsistency measure.InconsistencyMeasureEvaluator(BeliefSetInconsistencyMeasure<T> i)
Create a new InconsistencyMeasureEvaluator with the given inconsistency measure.
-
Method Summary
Modifier and Type Method Description 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.void
addInconsistencyMeasure(BeliefSetInconsistencyMeasure<T> i)
Adds the given inconsistency measure.void
addKnowledgeBase(U kb)
Adds the given knowledge base to the testing dataset.void
addKnowledgeBases(java.util.List<U> kbs)
Adds the given knowledge bases to the testing dataset.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.java.util.List<U>
getDataset()
java.util.List<Pair<java.lang.String,U>>
getDatasetWithNames()
void
parseDatasetFromPath(java.lang.String path, Parser<U,T> p, int n)
Parse all knowledge bases from files in the given folder and add them to the testing dataset.void
setTimeFunction(java.util.function.Supplier<java.lang.Long> timeFunction)
Sets the function used to measure time in ms.void
setTimeout(long timeout)
Sets the timeout.
-
-
-
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 basesi
- 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 basesmeasures
- 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 occursParserException
- if some error occursjava.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 samplern
- 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
-
-