public class SyntacticRandomSampler extends BeliefSetSampler<PropositionalFormula,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:
Modifier and Type | Field and Description |
---|---|
private static byte |
CONJ |
private static byte |
DISJ |
private static byte |
NEG |
private ProbabilityFunction<java.lang.Byte> |
prob
The probability function modeling the random decisions.
|
private ProbabilityFunction<Proposition> |
probProp
The probability function used to sample propositions
|
private static byte |
PROP |
private java.util.Random |
rand |
private double |
recDecrease |
DEFAULT_MAXIMUM_BELIEFBASE_LENGTH, DEFAULT_MINIMUM_BELIEFBASE_LENGTH
Constructor and Description |
---|
SyntacticRandomSampler(Signature signature,
Probability probneg,
Probability probconj,
Probability probdisj,
double recDecrease)
Creates a new sampler.
|
SyntacticRandomSampler(Signature signature,
Probability probneg,
Probability probconj,
Probability probdisj,
double recDecrease,
int minLength,
int maxLength)
Creates a new sampler.
|
Modifier and Type | Method and Description |
---|---|
private ProbabilityFunction<java.lang.Byte> |
decrease(ProbabilityFunction<java.lang.Byte> prob,
double value)
Adapts the given probability function by decreasing the probabilities of NEG, CONJ and DISJ.
|
PlBeliefSet |
next() |
PropositionalFormula |
sampleFormula(ProbabilityFunction<java.lang.Byte> prob)
Samples a single formula.
|
getMaxLength, getMinLength, getSignature, hasNext
private ProbabilityFunction<java.lang.Byte> prob
private ProbabilityFunction<Proposition> probProp
private double recDecrease
private static final byte NEG
private static final byte CONJ
private static final byte DISJ
private static final byte PROP
private java.util.Random rand
public SyntacticRandomSampler(Signature signature, Probability probneg, Probability probconj, Probability probdisj, double recDecrease)
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.public SyntacticRandomSampler(Signature signature, Probability probneg, Probability probconj, Probability probdisj, double recDecrease, int minLength, int maxLength)
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 basesprivate ProbabilityFunction<java.lang.Byte> decrease(ProbabilityFunction<java.lang.Byte> prob, double value)
prob
- a probability function.value
- some value in (0,1)public PropositionalFormula sampleFormula(ProbabilityFunction<java.lang.Byte> prob)
public PlBeliefSet next()
next
in interface java.util.Iterator<PlBeliefSet>
next
in interface BeliefSetIterator<PropositionalFormula,PlBeliefSet>
next
in class BeliefSetSampler<PropositionalFormula,PlBeliefSet>