TOULBAR2(1)
๐ TOULBAR2(1) โ the toulbar2 glow-up โจ
okay bestie, gather round, because we're about to talk about toulbar2 from the General Commands Manual and she is that girl. no cap, this tool exactly solves discrete optimization problems on graphical models. exactly. not approximately. not "close enough bestie". exactly. ๐
๐ธ NAME ๐ธ
toulbar2 โ exactly solves discrete optimization problems on graphical models ๐ฆ
โญ SYNOPSIS โญ
toulbar2 [options] file
๐ DESCRIPTION ๐
so like. toulbar2 solves discrete optimization problems defined by a graphical model. and when I say graphical model I mean the whole squad:
- Cost Function Networks โ which is solving the Weighted Constraint Satisfaction Problem ๐
- Markov Random Fields โ which is solving Maximum A Posteriori or MAP/MRF ๐ฟ
- Bayesian Networks โ which is solving Maximum Probability Explanation or MPE/BN ๐ฎ
- Quadratic Pseudo Boolean Optimization Problems โ a.k.a. QPBO or MAXCUT โ๏ธ
- Partial Weighted Maximum Satisfiabilityโฆ and honestly the list keeps going, she contains multitudes ๐
โจ OPTIONS โจ
๐ GENERAL CONTROL ๐
-a=[integer]โ finds at most a given number of solutions whose cost is strictly lower than the initial upper bound, then stops. and if you don't give her an integer at all? she finds all the solutions (or counts the number of zero-cost satisfiable solutions when you pair her up with BTD). iconic behavior honestly ๐ซถ-agap=[decimal]โ stops the search the moment the absolute optimality gap drops under the value you gave. tl;dr you get solutions with a guaranteed absolute approximation โ approximation with receipts ๐-Dโ approximate zero-cost solution count with BTD. like, she's estimating the count, be normal about it ๐-logzโ computes the log of probability of evidence (that's the log partition function, or log(Z), or the PR task if you're fancy). โ ๏ธ restricted to stochastic graphical models (.uaiformat only), so don't try it on anything else bestie, she will simply not ๐ซ-seed=[integer]โ seeds the pseudo-random generator insidetoulbar2with a fixed non-negative integer. give her a negative argument instead and she'll seed the generator from the current time. default value is1๐ฒ--stdin=[format]โ says "read the problem from standard input instead of a file." default format iscfn. like for example:cat example.uai | toulbar2 --stdin=uaiโ chef's kiss, pipes are her love language ๐-timer=[integer]โ a cpu-time limit in seconds.toulbar2stops once that much CPU time has been consumed. and listen โ this is a CPU user time limit, not a wall clock time limit. they are not the same thing and she will not pretend they are โฐ
๐งผ PREPROCESSING ๐งผ
-nopreโ deactivates all the preprocessing options. it's equivalent to-e: -p: -t: -f: -dec: -n: -mst: -dee: -trws:. a full skincare cleanse, everything off ๐งด-p=[integer]โ preprocessing only: activates variable elimination of variables with degree less than or equal to the value you give. default is-1, which means no elimination performed at all โ๏ธ-t=[integer]โ preprocessing only: simulates restricted path consistency by adding ternary cost functions on triangles of binary cost functions, within a given maximum space limit in MB ๐-f=[integer]โ preprocessing only: variable elimination of functional variables (f=1) or bijective variables (f=2). default value is1๐-decโ preprocessing only: pairwise decomposition of cost functions with arity larger than 3 into smaller arity cost functions. default: activated ๐ฐ (slice it up)-n=[integer]โ preprocessing only: projects n-ary cost functions onto all binary cost functions ifnis lower than the value given. default value is10๐งฎ-mstโ finds a maximum spanning tree ordering for DAC ๐ณ-M=[integer]โ applies the Min Sum Diffusion algorithm. default is off, with a number of iterations of0๐ซ
๐ฏ INITIAL UPPER BOUNDING ๐ฏ
-ub=[decimal]โ gives a primal bound (that's upper in minimization mode, lower otherwise) on the cost that a solution must satisfy. if the file also specifies a primal bound, then the tightest of the two wins. a tight primal bound can speed up the search, or you can pair it with-ato find all solutions of sufficient quality ๐-l=[integer]โ activates limited discrepancy search. use a negative value to stop the search after the given absolute number of discrepancies have been explored. discrepancy bound default is4๐-L=[integer]โ activates randomized search (quasi-random variable ordering) with restart. maximum number of nodes default is10000๐ฐ-i=["string"]โ uses the initial upper bound found by the INCOP local search solver. the string parameter is optional, and by default it's"0 1 3 idwa 100000 cv v 0 200 1 0 0", with this meaning:stoppinglowerbound randomseed nbiterations method nbmoves neighborhoodchoice neighborhoodchoice minnbneighbors maxnbneighbors neighborhoodchoice autotuning tracemode๐ง-pils=["string"]โ uses the initial upper bound found by the PILS local search solver. the string parameter is optional, and by default it's"3 0 0.333 100 500 10000 0.1 0.5 0.1 0.1", with this meaning:nbruns perturb_mode perturb_strength flatMaxIter nbEvalHC nbEvalMax strengthMin strengthMax incrFactor decrFactor๐-x=[(,i=a)*]โ assigns variable of indexito valuea. multiple assignments get separated by a comma and no space, she's strict about that. without any argument, a complete assignment is read from the default filesolโ or from a filename given directly as an additional input filename with a.solextension and without-xโ and it's used as an initial upper bound and as a value ordering heuristic ๐
๐ณ TREE SEARCH ALGORITHMS AND TREE DECOMPOSITION SELECTION ๐ณ
-hbfs=[integer]โ uses hybrid best-first search, restarting from the root after a given number of backtracks. default value is10000๐-open=[integer]โ sets the hybrid best-first search limit on the number of stored open nodes. default value is-1, which means no limit ๐ช-B=[integer]โ picks your algorithm:(0)DFBB,(1)BTD,(2)RDS-BTD,(3)RDS-BTD with path decomposition instead of tree decomposition. default value is0๐๏ธ-O=[filename]โ reads a variable elimination order from a file, in order to build a tree decomposition (if BTD-like and/or variable elimination methods are used). the order is also used as a DAC ordering ๐-O=[negativeinteger]โ builds a tree decomposition (if BTD-like and/or variable elimination methods are used) and a compatible DAC ordering, using one of these:(-1)maximum cardinality search ordering(-2)minimum degree ordering(-3)minimum fill-in ordering,(-4)maximum spanning tree ordering (see-mst),(-5)reverse Cuthill-Mckee ordering,(-6)approximate minimum degree ordering.
if you don't specify one, then the order in which variables appear in the problem file is used ๐๏ธ
-j=[integer]โ splits large clusters into a chain of smaller embedded clusters, with a number of proper variables less than this number. use options"-B=3 -j=1 -svo -k=1"for pure RDS, and use value0for no splitting. default value is0๐ช-r=[integer]โ sets a limit on the maximum cluster separator size (otherwise she merges the cluster with its father). use a negative value for no limit. default value is-1๐งฒ-X=[integer]โ sets a limit on the minimum number of proper variables in a cluster (otherwise she merges the cluster with its father). use0for no limit. default value is0๐-E=[float]โ merges leaf clusters with their fathers if the local treewidth is small (used together with option-eand a positive threshold value), or if the ratio of separator variables to cluster variables is above a given threshold (used together with option-vns). default value is0๐-R=[integer]โ chooses a specific cluster number as the root cluster ๐-I=[integer]โ solves only a specific rooted cluster subtree. RDS-BTD only, don't get any ideas elsewhere ๐
๐ฆ VNS SEARCH ๐ฆ
-vnsโ unified decomposition guided variable neighborhood search. a problem decomposition can be given as*.dec,*.cov, or*.orderinput files, or by using tree decomposition options such as-O๐บ๏ธ-vnsini=[integer]โ where the initial solution for VNS-like methods comes from:(-1)at random,(-2)min domain values,(-3)max domain values,(-4)first solution found by a complete method, or(k=0or more)tree search withkdiscrepancy max. default is-4๐ฒ-ldsmin=[integer]โ minimum discrepancy for VNS-like methods.1by default ๐-ldsmax=[integer]โ maximum discrepancy for VNS-like methods. default is the number of problem variables multiplied by maximum domain size, minus1๐-ldsinc=[integer]โ discrepancy increment strategy for VNS-like methods, using(1)Add1,(2)Mult2, or(3)Luby operator.2by default โ๏ธ-kmin=[integer]โ minimum neighborhood size for VNS-like methods.4by default ๐๏ธ-kmax=[integer]โ maximum neighborhood size for VNS-like methods. default is the number of problem variables ๐-kinc=[integer]โ neighborhood size increment strategy for VNS-like methods, using(1)Add1,(2)Mult2,(3)Luby operator, or(4)Add1/Jump.4by default ๐ช-best=[integer]โ stop VNS-like methods if a better solution is found. default value is0๐
๐ฅ NODE PROCESSING & BOUNDING OPTIONS ๐ฅ
-e=[integer]โ performs "on the fly" variable elimination of variables with small degree (less than or equal to a specified value). default is3, which creates a maximum of ternary cost functions ๐ฅ-k=[integer]โ sets the soft local consistency level enforced at preprocessing and at each node during search:0: Node Consistency with Strong Node Inverse Consistency for global cost functions,1: Generalized Arc Consistency2: Directed Generalized Arc Consistency3: Full Directed Generalized Arc Consistency4: (weak) Existential Directed Generalized Arc Consistency
default value is 4 ๐ง
-A=[integer]โ enforces Virtual Arc Consistency at each search node with a search depth less than the value given. default value is0, which enforces VAC only at the root node ๐ฑ-T=[decimal]โ threshold cost value for VAC. default value is1๐๏ธ-P=[decimal]โ threshold cost value for VAC during the preprocessing phase. default value is1๐๏ธ-C=[float]โ multiplies all costs internally by this number when loading the problem. default value is1โ๏ธ-Sโ preprocessing only: performs singleton consistency (only in conjunction with option-A) โ๏ธ-trws=[float]โ preprocessing only: enforces TRW-S until a given precision is reached. default value is0.00001๐ฏ--trws-n-iters=[integer]โ preprocessing only: enforces at mostNiterations of TRW-S. default value is1000๐
ok bestie we're not done yet, there's more where that came from, don't go anywhere ๐
--trws-n-iters-no-change=[integer]โ preprocessing only, bestie โจ stops TRW-S when N iterations did not move the lower bound up to the given precision. Default value is5, and-1=never(so-1means never stop, go off king ๐ ).--trws-n-iters-compute-ub=[integer]โ again preprocessing only: computes UB every N steps in TRW-S. Default value is100. ๐-dee=[integer]โ enforces restricted dead-end elimination, or value pruning by dominance rule from EAC value (dee>=1anddee<=3) and soft neighborhood substitutability, in preprocessing (dee=2ordee=4) or during search (dee=3). Default value is1. it's giving pruning, periodt โ๏ธ-oโ ensures an optimal worst-case time complexity of Directed and Existential Arc Consistency (can be slower in practice, no cap, just being honest ๐ซถ).
๐ BRANCHING, VARIABLE & VALUE ORDERING ๐
the glow-up section, truly ๐
-svoโ use a static variable ordering heuristic. The variable order used will be the same order as the DAC order. โจ-bโ use binary branching (as a default) instead of k-ary branching. Uses binary branching for interval domains and small domains and dichotomic branching for large enumerated domains (see option-d). ๐ฆ-cโ use binary branching with last conflict backjumping variable ordering heuristic. ๐-q=[integer]โ use weighted degree variable ordering heuristic if the number of cost functions is less than the given value (default value is10000). ๐-var=[integer]โ searches by branching only on the first [given value] decision variables, assuming the remaining variables are intermediate variables that will be completely assigned by the decision variables (use a zero if all variables are decision variables). Default value is0. ๐-m=[integer]โ use a variable ordering heuristic that preferably selects variables such that the sum of the mean (m=1) or median (m=2) cost of all incident cost functions is maximum (in conjunction with weighted degree heuristic-q). Default value is0: unused. ๐ธ-d=[integer]โ searches using dichotomic branching. The defaultd=1splits domains in the middle of domain range whiled=2splits domains in the middle of the sorted domain based on unary costs. โ๏ธ-sortdโ sort domains in preprocessing based on increasing unary costs (works only for binary CFN). ๐-solrโ use solution-based phase saving as a value ordering heuristic (default option). ๐-Vโ VAC-based value ordering heuristic (default option, only in conjunction with option"-A"). โญ
โจ CONSOLE OUTPUT โจ
-helpโ show default help message that toulbar2 prints when it gets no argument. ๐-v=[integer]โ set the verbosity level (default0). ๐ฅ-Z=[integer]โ debug mode (save problem at each node if verbosity option-v=num>= 1and-Z=num>=3). ๐-s=[integer]โ shows each solution found during search. The solution is printed on one line. The default-s=1gives the value (integer) of each variable successively in increasing order of definition in the model file. For-s=2, the value name is used instead, for-s=3,variable name=valuenameis printed instead. ๐
๐ FILE OUTPUT ๐
-w=[filename]โ writes last solution found in the specified filename (or"sol"if no parameter is given). The current directory is used as a relative path. ๐พ-z=[filename]โ saves problem in wcsp format in filename (or"problem.wcsp"if no parameter is given). Writes also the graphviz.dotfile and the degree distribution of the input problem. ๐-z=[integer]โ1: saves original instance (by default),2: saves after preprocessing (this option can be used in combination with-z=filename). โจ
๐ง PROBABILITY REPRESENTATION AND NUMERICAL CONTROL ๐ง
-precision=[integer]โ probability/real log10 precision conversion factor (a power of ten) for representing probabilities as fixed decimal point numbers. Default value is7. ๐-epsilon=[float]โ approximation factor for computing the partition function (default value is1000representingepsilon=1/1000). ๐ธ-qpmult=[double]โ coefficient multiplier for quadratic terms when reading qpbo format (default value is2). ๐
๐ฆ RANDOM PROBLEM GENERATION ๐ฆ
-random=[benchprofile]โ benchmark profile must be specified as follows, wherenanddare respectively the number of variable and the maximum domain size of the random problem. ๐ฒ
bin-{n}-{d}-{t1}-{p2}-{seed}
t1is the tightness in percentage of random binary cost functionsp2is the number of binary cost functions to include- the seed parameter is optional
binsub-{n}-{d}-{t1}-{p2}-{p3}-{seed}
binary random submodular cost functions
t1is the tightness in percentage of random cost functionsp2is the number of binary cost functions to includep3is the percentage of submodular cost functions amongp2cost functions (plus 10 permutations of two randomly-chosen values for each domain).
tern-{n}-{d}-{t1}-{p2}-{p3}-{seed}
p3is the number of ternary cost functions
nary-{n}-{d}-{t1}-{p2}-{p3}...-{pn}-{seed}
pnis the number of n-ary cost functions
salldiff-{n}-{d}-{t1}-{p2}-{p3}...-{pn}-{seed}
pnis the number of salldiff global cost functions (p2andp3still being used for the number of random binary and ternary cost functions). salldiff can be replaced by gcc or regular keywords with three possible forms (e.g.,sgcc,sgccdp,wgcc).
๐ FILE FORMATS ๐
toulbar2 can read .cfn, .wcsp, .uai, .LG, .cnf, .wcnf, .qpbo, .pre, .bep files. The files can be compressed with gzip or xz (e.g., .cfn.gz or .cfn.xz, except for pre and bep formats). See the full user documentation for a description of these file formats. ๐
quick vibe check: pre and bep do not do the compression thing, bestie, don't try it ๐
๐ SEE ALSO ๐
A more complete user documentation should be available on your system, in /usr/share/doc/toulbar2/userdoc.pdf or can be otherwise downloaded from http://miat.inrae.fr/toulbar2. ๐
๐ AUTHORS ๐
See https://github.com/toulbar2/toulbar2. ๐ซถ
and that's a wrap on TOULBAR2(1) bestie ๐ go forth and solve, you absolute main character โจ๐๐
๐ฆ where this page comes from
- debian trixie: toulbar2 1.2.1+dfsg-0.1 ยท MIT
- ubuntu noble: toulbar2 1.2.1+dfsg-0.1 ยท MIT
- ubuntu resolute: toulbar2 1.2.1+dfsg-0.1build2 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms