toulbar2
Variable and cost function modeling

Modeling a Weighted CSP consists in creating variables and cost functions.
Domains of variables can be of two different types:

Warning
Current implementation of toulbar2 has limited modeling and solving facilities for interval domains. There is no cost functions accepting both interval and enumerated variables for the moment, which means all the variables should have the same type.

Cost functions can be defined in extension (table or maps) or having a specific semantic.
Cost functions in extension depend on their arity:

Cost functions having a specific semantic (see Weighted Constraint Satisfaction Problem file format (wcsp)) are:

Note
The default semantics (using var keyword) of monolithic (flow and DAG-based propagators) global cost functions is to count the number of variables to change in order to restore consistency and to multiply it by the basecost. Other particular semantics may be used in conjunction with the flow-based propagator
The semantics of the network-based propagator approach is either a hard constraint ("hard" keyword) or a soft constraint by multiplying the number of changes by the basecost ("lin" or "var" keyword) or by multiplying the square value of the number of changes by the basecost ("quad" keyword)
A decomposable version exists for each monolithic global cost function, except grammar and MST. The decomposable ones may propagate less than their monolithic counterpart and they introduce extra variables but they can be much faster in practice
Warning
Each global cost function may have less than three propagators implemented
Current implementation of toulbar2 has limited solving facilities for monolithic global cost functions (no BTD-like methods nor variable elimination)
Current implementation of toulbar2 disallows global cost functions with less than or equal to three variables in their scope (use cost functions in extension instead)
Before modeling the problem using make and post, call ::tb2init method to initialize toulbar2 global variables
After modeling the problem using make and post, call WeightedCSP::sortConstraints method to initialize correctly the model before solving it