Module logicng

Class DimacsReader


  • public final class DimacsReader
    extends Object
    A reader for DIMACS CNF files.

    This reader reads all the clauses and variables - independent of the numbers given in the prefix. Also, it assumes that every clause is in its own line and ends with '0'. Comments are only allowed if the lines start with 'c'. No C style comments are supported (yes, we have actually seen these in DIMACS files).

    Since:
    1.2
    Version:
    1.3
    • Method Detail

      • readCNF

        public static List<Formula> readCNF​(File file,
                                            FormulaFactory f)
                                     throws IOException
        Reads a given DIMACS CNF file and returns the contained clauses as a list of formulas. The prefix v is used for the variables names.
        Parameters:
        file - the file
        f - the formula factory
        Returns:
        the list of formulas (clauses)
        Throws:
        IOException - if there was a problem reading the file
      • readCNF

        public static List<Formula> readCNF​(File file,
                                            FormulaFactory f,
                                            String prefix)
                                     throws IOException
        Reads a given DIMACS CNF file and returns the contained clauses as a list of formulas.
        Parameters:
        file - the file
        f - the formula factory
        prefix - the prefix for the variable names
        Returns:
        the list of formulas (clauses)
        Throws:
        IOException - if there was a problem reading the file
      • readCNF

        public static List<Formula> readCNF​(String fileName,
                                            FormulaFactory f)
                                     throws IOException
        Reads a given DIMACS CNF file and returns the contained clauses as a list of formulas. The prefix v is used for the variables names.
        Parameters:
        fileName - the file name
        f - the formula factory
        Returns:
        the list of formulas (clauses)
        Throws:
        IOException - if there was a problem reading the file
      • readCNF

        public static List<Formula> readCNF​(String fileName,
                                            FormulaFactory f,
                                            String prefix)
                                     throws IOException
        Reads a given DIMACS CNF file and returns the contained clauses as a list of formulas.
        Parameters:
        fileName - the file name
        f - the formula factory
        prefix - the prefix for the variable names
        Returns:
        the list of formulas (clauses)
        Throws:
        IOException - if there was a problem reading the file