Package net.sf.tweety.logics.pl.util
Class SyntacticRandomSampler
- java.lang.Object
-
- net.sf.tweety.commons.BeliefSetSampler<PlFormula,PlBeliefSet>
-
- net.sf.tweety.logics.pl.util.SyntacticRandomSampler
-
- All Implemented Interfaces:
Iterator<PlBeliefSet>,net.sf.tweety.commons.BeliefSetIterator<PlFormula,PlBeliefSet>
public class SyntacticRandomSampler extends net.sf.tweety.commons.BeliefSetSampler<PlFormula,PlBeliefSet>
This sampler implements a random generation algorithm for generating formulas, based on the syntax tree of propositional formulas. Consider the following BNF for a propositional logic formula:
F ::== !F | F >> F | F || F | Awith propositions A. The algorithm for constructing formulas takes four parameters:
- probneg: the probability to generate a negation
- probconj: the probability to generate a conjunction
- probdisj: the probability to generate a disjunction
- recDecrease: a value in (0,1) by which the above probabilities are multiplied in each recursive step to increase likelihood of termination.
From these parameters the probability to generate a proposition "probprop" is computed via probprop=1-probneg-probconj-probdisj (the actual proposition is selected with a uniform distribution). Then a formula is generated by randomly selecting which rule in the above BNF is followed wrt. these probabilities. Note that the algorithm is not guaranteed to terminate.
- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description SyntacticRandomSampler(net.sf.tweety.commons.Signature signature, net.sf.tweety.math.probability.Probability probneg, net.sf.tweety.math.probability.Probability probconj, net.sf.tweety.math.probability.Probability probdisj, double recDecrease)Creates a new sampler.SyntacticRandomSampler(net.sf.tweety.commons.Signature signature, net.sf.tweety.math.probability.Probability probneg, net.sf.tweety.math.probability.Probability probconj, net.sf.tweety.math.probability.Probability probdisj, double recDecrease, int minLength, int maxLength)Creates a new sampler.
-
Method Summary
Modifier and Type Method Description PlBeliefSetnext()Returns the next belief setPlFormulasampleFormula(net.sf.tweety.math.probability.ProbabilityFunction<Byte> prob)Samples a single formula.-
Methods inherited from class net.sf.tweety.commons.BeliefSetSampler
getMaxLength, getMinLength, getSamplerSignature, hasNext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Constructor Detail
-
SyntacticRandomSampler
public SyntacticRandomSampler(net.sf.tweety.commons.Signature signature, net.sf.tweety.math.probability.Probability probneg, net.sf.tweety.math.probability.Probability probconj, net.sf.tweety.math.probability.Probability probdisj, double recDecrease)Creates a new sampler.- Parameters:
signature- some set of propositionsprobneg- the probability to generate a negationprobconj- the probability to generate a conjunctionprobdisj- the probability to generate a disjunctionrecDecrease- a value in (0,1) by which the above probabilities are multiplied in each recursive step to increase likelihood of termination.
-
SyntacticRandomSampler
public SyntacticRandomSampler(net.sf.tweety.commons.Signature signature, net.sf.tweety.math.probability.Probability probneg, net.sf.tweety.math.probability.Probability probconj, net.sf.tweety.math.probability.Probability probdisj, double recDecrease, int minLength, int maxLength)Creates a new sampler.- Parameters:
signature- some set of propositionsprobneg- the probability to generate a negationprobconj- the probability to generate a conjunctionprobdisj- the probability to generate a disjunctionrecDecrease- a value in (0,1) by which the above probabilities are multiplied in each recursive step to increase likelihood of termination.minLength- the minimum length of knowledge basesmaxLength- the maximum length of knowledge bases
-
-
Method Detail
-
sampleFormula
public PlFormula sampleFormula(net.sf.tweety.math.probability.ProbabilityFunction<Byte> prob)
Samples a single formula.- Parameters:
prob- a probability function- Returns:
- a single formula.
-
next
public PlBeliefSet next()
Returns the next belief set- Specified by:
nextin interfacenet.sf.tweety.commons.BeliefSetIterator<PlFormula,PlBeliefSet>- Specified by:
nextin interfaceIterator<PlBeliefSet>- Specified by:
nextin classnet.sf.tweety.commons.BeliefSetSampler<PlFormula,PlBeliefSet>- Returns:
- the next belief set
-
-