- java.lang.Object
-
- org.logicng.util.FormulaRandomizer
-
public final class FormulaRandomizer extends Object
A randomizer for formulas.The formula types included in the generated formulas can be configured with a
FormulaRandomizerConfig.- Since:
- 2.0.0
- Version:
- 2.3.0
-
-
Constructor Summary
Constructors Constructor Description FormulaRandomizer(FormulaFactory f)Generates a new formula randomizer.FormulaRandomizer(FormulaFactory f, FormulaRandomizerConfig config)Generates a new formula randomizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Formulaamo()Returns a random at-most-one constraint.Formulaand(int maxDepth)Returns a random conjunction with a given maximal depth.Formulaatom()Returns a random atom.Formulacc()Returns a random cardinality constraint.Constantconstant()Returns a random constant.List<Formula>constraintSet(int numConstraints, int maxDepth)Returns a list ofnumConstraintsrandom formula with a given maximal depth.Formulaequiv(int maxDepth)Returns a random equivalence with a given maximal depth.Formulaexo()Returns a random exactly-one constraint.Formulaformula(int maxDepth)Returns a random formula with a given maximal depth.Formulaimpl(int maxDepth)Returns a random implication with a given maximal depth.Literalliteral()Returns a random literal.Formulanot(int maxDepth)Returns a random negation with a given maximal depth.Formulaor(int maxDepth)Returns a random disjunction with a given maximal depth.Formulapbc()Returns a random pseudo boolean constraint.Variablevariable()Returns a random variable.
-
-
-
Constructor Detail
-
FormulaRandomizer
public FormulaRandomizer(FormulaFactory f)
Generates a new formula randomizer. With the given formula factory and the randomizer configuration from the formula factory.- Parameters:
f- the formula factory
-
FormulaRandomizer
public FormulaRandomizer(FormulaFactory f, FormulaRandomizerConfig config)
Generates a new formula randomizer. With the given formula factory and configuration.- Parameters:
f- the formula factoryconfig- the formula randomizer configuration
-
-
Method Detail
-
constant
public Constant constant()
Returns a random constant.- Returns:
- the random constant
-
variable
public Variable variable()
Returns a random variable.- Returns:
- the random variable
-
literal
public Literal literal()
Returns a random literal. The probability of whether it is positive or negative depends on the configuration.- Returns:
- the random literal
-
atom
public Formula atom()
Returns a random atom. This includes constants, literals, pseudo boolean constraints, and cardinality constraints (including amo and exo).- Returns:
- the random atom
-
not
public Formula not(int maxDepth)
Returns a random negation with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random negation
-
impl
public Formula impl(int maxDepth)
Returns a random implication with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random implication
-
equiv
public Formula equiv(int maxDepth)
Returns a random equivalence with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random equivalence
-
and
public Formula and(int maxDepth)
Returns a random conjunction with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random conjunction
-
or
public Formula or(int maxDepth)
Returns a random disjunction with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random disjunction
-
cc
public Formula cc()
Returns a random cardinality constraint.- Returns:
- the random cardinality constraint
-
amo
public Formula amo()
Returns a random at-most-one constraint.- Returns:
- the random at-most-one constraint
-
exo
public Formula exo()
Returns a random exactly-one constraint.- Returns:
- the random exactly-one constraint
-
pbc
public Formula pbc()
Returns a random pseudo boolean constraint.- Returns:
- the random pseudo boolean constraint
-
formula
public Formula formula(int maxDepth)
Returns a random formula with a given maximal depth.- Parameters:
maxDepth- the maximal depth- Returns:
- the random formula
-
-