io

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package io gathers readers and writers for formulas in different formats in LogicNG.

To write a formula to a file, you can use the

io.WriteFormula(fac, "filename", formula)

To read the file again, simply use

read, err := io.ReadFormula(fac, "filename")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadDimacs

func ReadDimacs(fac f.Factory, filename string, prefix ...string) (*[]f.Formula, error)

ReadDimacs reads a CNF from the given filename in Dimacs format. The optional prefix parameter is used to generate the variable names. The default value is `v` therefore variable v1, v2, ... will be generated from the input problem. Returns the CNF as a list of clauses and an optional error if there was a problem reading the file.

func ReadDimacsFile

func ReadDimacsFile(fac f.Factory, file *os.File, prefix ...string) (*[]f.Formula, error)

ReadDimacsFile reads a CNF from the given file in Dimacs format. The optional prefix parameter is used to generate the variable names. The default value is `v` therefore variable v1, v2, ... will be generated from the input problem. Returns the CNF as a list of clauses and an optional error if there was a problem reading the file.

func ReadFormula

func ReadFormula(fac f.Factory, filename string) (f.Formula, error)

ReadFormula reads a formula from the given file. If the file contains more than one line, the conjunction of all lines is returned. Returns the formula and an optional error if there was a problem reading the file.

func ReadFormulaFile

func ReadFormulaFile(fac f.Factory, file *os.File) (f.Formula, error)

ReadFormulaFile reads a formula from the given file. If the file contains more than one line, the conjunction of all lines is returned. Returns the formula and an optional error if there was a problem reading the file.

func ReadFormulas

func ReadFormulas(fac f.Factory, filename string) ([]f.Formula, error)

ReadFormulas reads a list of formulas from the given file. Each line in the file is one formula in the result. Returns the list of formulas ad an optional error if there was a problem reading the file.

func ReadFormulasFile

func ReadFormulasFile(fac f.Factory, file *os.File) ([]f.Formula, error)

ReadFormulasFile reads a list of formulas from the given file. Each line in the file is one formula in the result. Returns the list of formulas ad an optional error if there was a problem reading the file.

func WriteDimacs

func WriteDimacs(fac f.Factory, filename string, formula f.Formula) (map[f.Variable]int, error)

WriteDimacs writes the given formula in CNF to a file with the given filename in the http://www.satcompetition.org/2009/format-benchmarks2009.html. Returns a mapping from each variable of the original problem to its index in the CNF file an optional error if there was a problem writing the file or the formula was not in CNF.

func WriteDimacsToFile

func WriteDimacsToFile(fac f.Factory, file *os.File, formula f.Formula) (map[f.Variable]int, error)

WriteDimacsToFile writes the given formula in CNF to the given file in the http://www.satcompetition.org/2009/format-benchmarks2009.html. Returns a mapping from each variable of the original problem to its index in the CNF file an optional error if there was a problem writing the file or the formula was not in CNF.

func WriteDimacsToWriter

func WriteDimacsToWriter(fac f.Factory, writer io.Writer, formula f.Formula) (map[f.Variable]int, error)

WriteDimacsToWriter writes the given formula to the given writer in the http://www.satcompetition.org/2009/format-benchmarks2009.html. Returns a mapping from each variable of the original problem to its index in the CNF file an optional error if there was a problem writing to the writer.

func WriteFormula

func WriteFormula(fac f.Factory, filename string, formula f.Formula, splitAnd ...bool) error

WriteFormula writes the given formula to a file with the given filename. The flag splitAnd indicates whether - if the formula is a conjunction - the single operands should be written to different lines without a conjoining operator. Returns an error if there was a problem writing the file.

func WriteFormulaToFile

func WriteFormulaToFile(fac f.Factory, file *os.File, formula f.Formula, splitAnd ...bool) error

WriteFormulaToFile writes the given formula to the given file. The flag splitAnd indicates whether - if the formula is a conjunction - the single operands should be written to different lines without a conjoining operator. Returns an error if there was a problem writing the file.

func WriteFormulaToWriter

func WriteFormulaToWriter(fac f.Factory, writer io.Writer, formula f.Formula, splitAnd ...bool) error

WriteFormulaToWriter writes the given formula to the given writer. The flag splitAnd indicates whether - if the formula is a conjunction - the single operands should be written to different lines without a conjoining operator. Returns an error if there was a problem writing the writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL