dimacs

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package dimacs provides support for reading dimacs cnf files and variants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommentFilter

func NewCommentFilter(r io.Reader) io.Reader

func ReadCnf

func ReadCnf(r io.Reader, vis CnfVis) error

ReadCnf reads a dimacs CNF outputing the info to vis.

func ReadCnfStrict

func ReadCnfStrict(r io.Reader, vis CnfVis, strict bool) error

ReadCnfStrict reads a dimacs CNF file with strict (count of vars/clauses in header) specified.

func ReadICnf

func ReadICnf(r io.Reader, vis ICnfVis) error

ReadICnf reads an icnf file which is a file format for incremental sat solving.

func ReadSolve

func ReadSolve(r io.Reader, vis SolveVis) error

Types

type CnfVis

type CnfVis interface {

	// Init is called on a problem line defining number of variables and
	// number of clauses.  If this is not given and strict enforcement
	// of their presence is lacking, then this is called with some defaults.
	Init(v, c int)

	// Add adds a dimacs literal as an int
	Add(m z.Lit)

	// Called at end of file.
	Eof()
}

Type Vis provides a visitor interface to reading dimacs files.

Anything implementing Vis can read a dimacs file.

type CommentFilter

type CommentFilter struct {
	// contains filtered or unexported fields
}

CommentFilter is a wrapper around reader which filters out dimacs comments.

func (*CommentFilter) Read

func (f *CommentFilter) Read(buf []byte) (n int, e error)

type ICnfVis

type ICnfVis interface {

	// Add adds a literal like inter.Adder.
	Add(m z.Lit)

	// Assume is called in a sequence and 0-terminated.
	// 0-termination will normally trigger a solve
	Assume(m z.Lit)

	// EOF
	Eof()
}

Interface ICnfVis is an interface for eading icnf files.

type SolveVis

type SolveVis interface {

	// Solution is called for a solution line of a solver output.
	//
	// As usual
	//  1 is sat, -1 is unsat, 0 is unknown
	Solution(r int)

	// Value gives a value
	Value(m z.Lit)

	// End of output
	Eof()
}

Interface SolveVis is a visitor for reading solver outputs.

Jump to

Keyboard shortcuts

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