Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

Vallst Documentation

Home
Download
vallstAPI.h
API functions
Manual
Forums
Donate

Introduction

Vallst is a boolean constraint solver, solving problems where variables range over {0,1}. You can e.g. tell the solver to satisfy the following:

The solver will find a satisfying assignment to the variables, making all formulas true, or prove that there is no satisfying assignment.

(Confer 0-1 integer programming (0-1 ILP), pseudo-boolean constraints, propositional satisfiability (SAT)).

You can also tell the solver to maximize or minimize constraint constants.

Moreover there are "global" formula types available such as the tour type with the intended meaning that a solution corresponding to nodes and edges in a complete directed irreflexive graph must be a tour (i.e. a Hamiltonian cycle). This is useful for more efficient coding and solving of e.g. asymmetric traveling salesperson problems.

Vallst is available both as an API, see vallstAPI.h, and in a standalone, command line based, version.

License

osi-certified-90x75.png Vallst is distributed under the open source license RPL. (Informally, RPL is roughly like GPL but stricter; you are not allowed to use (e.g. link) RPLed programs within a company without making your work available.) For a copy of the whole license, including vallst's EXHIBIT A section, see LICENSE. (For more on open source, see http://www.opensource.org.)

Or you might prefer to use vallst under an alternativ commercial license instead.

Awards

The solver won two golds and one bronze in this year's SAT "world championships", http://www.satcompetition.org/2005/.

Host

BerliOS Developer Logo The solver is hosted at BerliOS.

Installation

make

To install vallst, download and unpack the tarball where you want the installation. Then run "make -s". If you want a different compiler or mode than the defaults, then, instead of "make -s", use e.g. "make -s -f makefile_icc_release_static".

Generating documentation

Running "make" should also have generated more fancy documentation using doxygen. If you don't have doxygen you can get it at http://www.doxygen.org. If you want to generate vallst documentation using doxygen without compiling vallst, run "make -k doc". If you generated documentation using doxygen, that documentation can be found at docs/html/index.html. If you also want documentaion in dvi, pdf or ps format, and have latex, run "make dvidoc", "make pdfdoc" or "make psdoc". You'll then find e.g. the pdf document at docs/latex/refman.pdf.

Getopt

Vallst standalone uses getopt which isn't included in the vallst distribution. If you don't have getopt, and don't want to install it, and don't care about command line options in standalone vallst you can get by by defining NoGetopt; you can do that by e.g. uncommenting the line "#CFLAGS += -DNoGetopt" in makefile_core. You can still use standalone vallst with default options and supplying the in-theory problem from stdin.

make install

If you want to install vallst not just privately, run "make install" as root. After that, anyone ought to be able to #include vallstAPI.h, link to the API using the compiler option -lvallst, run standalone vallst ("vallst ...") and have access to man pages --- even though the html documentation is probably better. There are also scripts, e.g. vallst.sh, utilizing the standalone solver, for harder problems.

If you don't do a "make install" and still want to use the scripts, you probably need to redefine the variable vallstcom at the top of the scripts that you want to use. Set it to "vallstcom=/dir/vallst" where dir is the full path of the directory where you installed the solver.

Known problems

Linux stack overflow

The startup face when running the solver involves the use of a recursive function. If the stack size is small, which it is by default for some reason on Linux systems (10MB), the solver might run out of stack memory and segfault on very large problems. Hence you might want to increase the stack size a bit. Under Linux you can run ulimit. "ulimit -s 30000" will set the size to about 30MB. "ulimit -a" lists the size.

Miscellaneous

Vallst is written in standard C and hence should be portable to most systems.

The API is fast, reentrant, supports incremental use, supports temporary assumptions, supports axiom strengthening, etc.

The intentions are to maintain vallst to be as fast and robust as possible, improving it by implementing any new good ideas, and to include into the API any useful functionality.

There is a short paper available giving an overview of some of the algorithms behind the solver.

Todo

No tests have been made to determine how to set the many available solver options in a good way. Right now the default settings are mostly some fixed ad hoc values, set when the init-function was written.

Symmetry (automorphism) detection isn't implemented yet. However, there is an outline of an implementation and it will be implemented within a few month or so.

It might very well be possible to relatively easily improve the important branching heuristic for the search. At the moment, basically the branching variable is just taken randomly from the last open formula (akin to part of the heuristic in Berkmin).

Formula types

Global types

The aim is that any useful boolean problem should be expressible in a straightforward way using vallst's types. Furthermore, the coding in vallst should be good (typically optimal) and vallst should solve the problem in a good way.

Here is an example to illustrate the point: Suppose that we want to solve the asymmetric traveling salesperson problem, atsp. A way to code the problem is to represent each edge (i,j) by a variable p(i,j) which is true iff the edge (i,j) is to be part of the tour. Then the goal is to minimize the sum of all edges. To ensure that the solution is a tour one can add that each node must have at most 1 in-edge and 1 out-edge, and at least 1 in-edge and 1 out-edge. However, that's not enough since a tour is not guaranteed. A solution with many cycles would be permissible, e.g. 0->1->0, 2->3->2. AFAIK it's not possible to express that the solution must be a tour in an optimal way (i.e. quadratic in the number of nodes) using some limited ("local"?) language. What one can do is to simply introduce a new "global" type saying that, given the (local) atsp situation described above, the solution must code a tour. This is what is done in vallst, see VallstFormulaType_ggcdiTour. With this new type one would be able to code the problem optimally and the prover can also solve the problem in a good way.

Now the question arise which problems could be useful to solve with vallst and which formula types that should be added. Admittedly, attacking (a)tsp with vallst might not have been the smartest choice since the methods used by usual tsp solvers obviously seem better suited to solve tsp than the methods used in vallst (at least currently). There are some impressive and intimidating results like a proved optimal tour for all cities in Sweden, about 25k cities, and a close to optimal tour for all cities in the world. But as an example, a proof of concept, the adding of a special tour type in vallst works fine. And there are many problems where the methods used by vallst are the best suited.

Local types

One could of course also add more usual types (in addition to \/, <->, <, <*,...).

Segmentation fault

The solver contains a recursive sorting function. As a result, if the stack size is small, you may encounter segfault for huge problems.

Maybe one should convert the recursive sorting function into an iterative one. You can also avoid the segfault by enlarging the stack size (e.g. by 'ulimit' under linux; 'unlimit' under solaris).

Manual

For the default option settings, both for the API and standalone vallst, see standalone vallst's --help text.

API

You will find vallst's API, including documentation, in vallstAPI.h. See API functions grouped for a list of all API functions grouped into categories. Or see the module categorization.

If you did a "make install" anyone ought to be able to #include vallstAPI.h and link to the API with the compiler option -lvallst.

Example

The standalone version of vallst, vallst.c, constitutes an example of use of the API.

Vallst standalone

Command line options

See standalone vallst's --help text for a description of the command line options. For a fuller explanation of each option, see vallstAPI.h. E.g., for a detailed explanation of the command line option --convert-3-clauses, see vallst_setConvert3ClausesIntoEqus().

Input syntax

The input is constituted by an optional prologue, which you can just ignore, and a body which is a list of axioms. The format for in-theory files is like DIMACS' cnf format but extended to allow more formula types than just plain disjunctions and to allow more prologue info.

Other input formats can also be read. See Traveling salesperson problem and Pseudo boolean input format.

Prologue
Prologues look like this:

c This is a comment.
cv [<nrOf3Clauses> [<nrOfLitOccs>]]
p [nrOfVars] [optional text that will be skipped]

There is usually no need to include prologues. If you don't, vallst will if possible read the file an extra time, before the actual parse phase, to estimate prologue values. Even if you supply a prologue, vallst will ignore it if the --ignore-prologue flag is true, which it is by default. See Vallst prologue for more.

Body
See also the API documentation of vallst_addAxiom() and Formula types.

Variables are written 1, 2, 3... Negated variables are written -1, -2, -3,... Note that this is in contrast to the API/internal representation of literals where the nth variable is 2n and its negation is 2n+1.

Here are examples of axioms:

c Clause 1 \/ -2 \/ 4
1 -2 4  0

'0' marks the end of a formula (formulas don't have to be contained to one line).

Constraints are written like "< c p0 p1 p2 ... 0" meaning that more than c of p0, p1, ... must be true. Example:

c More than 1 of 2, 3 and -6 must be true, i.e. 1 < '2'+'3'+'-6':
< 1  2 3 -6  0

c 3 < 4*'2' + 3*'3' + 1*'-6':
<* 3  4 2  3 3  1 -6  0

c More-than disjunction:
c  '5'  \/  1 < '-2'+'4'+'7'+'9'
<\/ 5 1 -2 4 7 9  0

c <->{ -8, 9, 10, 11 }   (i.e -8<->9<->10<->11)
c (This says that an even number of the literals are true.)
c (If there are an odd number of literals, an odd number of them must be true.)
<-> -8 9 10 11  0

c -<->{ 12, 13, -14 }
xor 12 13 -14  0

The following types of constraints are also allowed and will be transformed into their equivalent constraints using <* and <. Below, p, q,... are numbers, possibly negated.

c 3 >= 2p+3q+1r
>=* 3 2 p 3 q 1 r

c 2 >= p+q+r
>= 2 p q r

You can also tell vallst to optimize things as e.g. in:

c Maximize the constraint constant c, c >= 4, s.t. c < 3p + 7q + 2r + 1s.
<* max 4  3 p 7 q 2 r 1 s
You can use 'max' with formulas of type <, <* and <\/ --- though "max" for <\/ might not make much sense. Use 'min' with >= and >=*. Depending on the settings (--breadth-fst-opt-strat), either all formulas marked with min or max will be pushed in a breadth first manner, starting with the last formula, going from last toward first; or only the constraint constant in the last axiom containing 'max' or 'min' will be pushed. Note though that all formulas marked with min or max, not just the formula currently being pushed, will also be altered/maximized/minimized/optimized as much as the current model allows (see vallst_maxConstraints()). This applies to both the breadth first case and the depth first/last axiom case. If you want more or something else, use the API or hack vallst.c.

There are also non-local (Global) formula types. This one --- together with its complementing local part --- says that literals representing edges in a Graph with n nodes where the graph is Complete, Directed and Irreflexive should constitute a tour (visiting all nodes in the graph).

c Any solution must be a tour. q is the first literal representing an edge,
c e.g. 1 or -2. n is the number of nodes in the graph (the dimension (dim)).
ggcdit q n
See VallstFormulaType_ggcdiTour for more. Note that if you use the ggcdit type you must also explicitly add the complementing local part, as described in the description of VallstFormulaType_ggcdiTour.

Special comments

There are three comment types with special meaning. These three special comments --- cva, cvn and cve --- have their special meaning only in the body, not in the prologue (including any part above the prologue).

Axioms and consequences: "cva" and "cvn" toggles between axioms and non-axioms. For example:

p
-1 3 6 0  c This is an axiom by default.
cvn Formulas below this comment are non-axioms (consequences of the axioms).
2 5 -6 0  c This is a non-axiom.
4 5 -9 0  c This is a non-axiom too.
cva Formulas below this comment are axioms.
1 2 -3 0  c Axiom.
2 7 -9 0  c Axiom.
...
All formulas occurring after a cvn comment are interpreted as non-axioms, i.e. consequences of the axioms. Formulas after a cva comment are taken to be axioms. If nothing is said, formulas are taken to be axioms. Only clauses (disjunctions) are affected. Non-clauses will always be considered to be axioms. If the cva or cvn comment occur inside a formula, that formula is also affected by the toggle change.

Variable definitions: There is also a special comment to define historic equivalences between variables:

c Peripheral historic literal equivalences: 2<->-2113; 3<->337; 4<->337
cve -2113 2  337 3  337 4
The cve list is a list of literal pairs p0 q0, p1 q1,... where all qi in the list must be non-negated and should not occur in axioms or non-axioms (formulas).

Note that if you use a global formula type, that type covers a range of variables which therefor in effect occur in formulas. Hence you shouldn't use a cve definition "cve r p" to define an equivalence p<->r if p is covered by a global type.

If a model is printed, what is printed will be an expanded model where also the cve definitions hold.

You can use a cve definition "cve r p" even if p occurs in formulas but then you must have a theory that entails the equivalence of r and p (e.g. have an axiom r<->p). And then the point of the cve definition "cve r p" is lost.

Traveling salesperson problem
If the --atsp command line option is present, the input file is expected to contain an asymmetric traveling salesperson problem. For an example of an atsp file, see ??.

The --tsp option specifies that the input file is a tsp problem. Actually, the implementation of support for tsp is currently not finished! (But support for atsp is.)

If the input file name ends with .atsp or .tsp, it is assumed that the problem is an atsp respectively a tsp and the --atsp or --tsp command line option won't be necessary.

Pseudo boolean input format
If the --pb command line option is present, the input file is expected to be on the (o)pb format. For an example of a pb file, see ??.

If the input file name ends with .opb or .pb, it is assumed that the problem is a pb problem and the --pb command line option won't be necessary.

The pb-problem will be converted to the internal format. A kink is that min: +{c_i*p_i} will be transformed into (max) 0 < +{c_i*-p_i}. Hence, if all models are such that p_i need to be true, no models will be found. If this scenario could actually be possible, you need to take care of it. This problem is automatically taken care of if you use the script vallstSAT2005PB.sh (and you can look at vallstSAT2005PB.sh for one way of handling this).

Scripts

For harder problems it's probably better to use a script than plain standalone vallst. The script vallst.sh repeatedly calls vallst to solve a problem. The options to vallst.sh are the same as to vallst, with some minor changes, see vallst.sh.

There is also vallstlocal.sh. If you haven't installed vallst globally (using make install), you could use vallstlocal.sh, perhaps after modifying it.

If you are optimizing you might prefer to use vallstSAT2005PB.sh. (If you are using ordinary, non-pb, files you can add the option --pb=no.)


Copyright (C) 2004-2005 Daniel Vallstrom. See the various vallst files for license notices.

Generated on Mon Jul 18 11:34:14 2005 for Vallst by doxygen 1.4.3.