Module logicng

Class 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 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 factory
        config - 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
      • constraintSet

        public List<Formula> constraintSet​(int numConstraints,
                                           int maxDepth)
        Returns a list of numConstraints random formula with a given maximal depth.
        Parameters:
        numConstraints - the number of constraints to be generated
        maxDepth - the maximal depth
        Returns:
        the random formula