This second (and yet clumsy!) tutorial deals with basic modeling techniques in Answer Set Programming (ASP). We illustrate these techniques by modeling the n-Queens puzzle in various ways. The first part discusses a basic encoding along with some arising pitfalls. The add-on to part one motivates the choice of this encoding. The second part provides a more advanced encoding illustrating the advantage of using cardinality constraints; it discusses their impact on grounding and searching (by inspecting clasp’s statistics). The first add-on gives an even more compact encoding. The second add-on discusses clasp’s treatment of cardinality constraints. The third part talks about issues with declarativity and scalability. The fourth part presents a further improved encoding, obtained by replacing a source of combinatorial search within grounding by pre-computation. The fifth part explores a new experimental feature of gringo that allows for expressing finite linear constraint satisfaction problems within its modeling language and for passing them on to off-the-shelf ASP solvers. The sixth and final part wraps up the tutorial by applying the most promising encodings to more demanding problems, namely the 1000-Queens puzzle.

Video (part one 11:39; one+ 2:59, part two 8:59; two+ 3:06; two++ 4:02, part three 4:51, part four 8:35, part five 11:35, part six 4:38), Script (org, html, tex, pdf, txt), Files (tgz, zip)