Constraint satisfaction

Short description: Process in artificial intelligence and operations research

In artificial intelligence and operations research, constraint satisfaction is the process of finding a solution through a set of constraints that impose conditions that the variables must satisfy.[1] A solution is therefore an assignment of values to the variables that satisfies all constraints--that is, a point in the feasible region.

The techniques used in constraint satisfaction depend on the kind of constraints being considered. Often used are constraints on a finite domain, to the point that constraint satisfaction problems are typically identified with problems based on constraints on a finite domain. Such problems are usually solved via search, in particular a form of backtracking or local search. Constraint propagation is another family of methods used on such problems; most of them are incomplete in general, that is, they may solve the problem or prove it unsatisfiable, but not always. Constraint propagation methods are also used in conjunction with search to make a given problem simpler to solve. Other considered kinds of constraints are on real or rational numbers; solving problems on these constraints is done via variable elimination or the simplex algorithm.

Constraint satisfaction as a general problem originated in the field of artificial intelligence in the 1970s (see for example (Laurière 1978)). However, when the constraints are expressed as multivariate linear equations defining (in)equalities, the field goes back to Joseph Fourier in the 19th century: George Dantzig's invention of the simplex algorithm for linear programming (a special case of mathematical optimization) in 1946 has allowed determining feasible solutions to problems containing hundreds of variables.

During the 1980s and 1990s, embedding of constraints into a programming language was developed. The first language devised expressly with intrinsic support for constraint programming was Prolog. Since then, constraint-programming libraries have become available in other languages, such as C++ or Java (e.g., Choco for Java[2]).

## Contents

* 1 Constraint satisfaction problem
* 1.1 Solving
* 1.2 Complexity
* 2 Constraint programming
* 2.1 Constraint logic programming
* 2.2 Constraint satisfaction toolkits
* 2.3 Other constraint programming languages
* 3 See also
* 4 References
* 5 External links
* 5.1 Videos

## Constraint satisfaction problem

Main article: Constraint satisfaction problem

As originally defined in artificial intelligence, constraints enumerate the possible values a set of variables may take in a given world. A possible world is a total assignment of values to variables representing a way the world (real or imaginary) could be.[3] Informally, a finite domain is a finite set of arbitrary elements. A constraint satisfaction problem on such domain contains a set of variables whose values can only be taken from the domain, and a set of constraints, each constraint specifying the allowed values for a group of variables. A solution to this problem is an evaluation of the variables that satisfies all constraints. In other words, a solution is a way for assigning a value to each variable in such a way that all constraints are satisfied by these values.

In some circumstances, there may exist additional requirements: one may be interested not only in the solution (and in the fastest or most computationally efficient way to reach it) but in how it was reached; e.g. one may want the "simplest" solution ("simplest" in a logical, non-computational sense that has to be precisely defined). This is often the case in logic games such as Sudoku.

In practice, constraints are often expressed in compact form, rather than enumerating all the values of the variables that would satisfy the constraint. One of the most-used constraints is the (obvious) one establishing that the values of the affected variables must be all different.

Problems that can be expressed as constraint satisfaction problems are the eight queens puzzle, the Sudoku solving problem and many other logic puzzles, the Boolean satisfiability problem, scheduling problems, bounded-error estimation problems and various problems on graphs such as the graph coloring problem.

While usually not included in the above definition of a constraint satisfaction problem, arithmetic equations and inequalities bound the values of the variables they contain and can therefore be considered a form of constraints. Their domain is the set of numbers (either integer, rational, or real), which is infinite: therefore, the relations of these constraints may be infinite as well; for example, X=Y+1 has an infinite number of pairs of satisfying values. Arithmetic equations and inequalities are often not considered within the definition of a "constraint satisfaction problem", which is limited to finite domains. They are however used often in constraint programming.

It can be shown that the arithmetic inequalities or equations present in some types of finite logic puzzles such as Futoshiki or Kakuro (also known as Cross Sums) can be dealt with as non-arithmetic constraints (see Pattern-Based Constraint Satisfaction and Logic Puzzles[4]).

### Solving

Constraint satisfaction problems on finite domains are typically solved using a form of search. The most-used techniques are variants of backtracking, constraint propagation, and local search. These techniques are used on problems with nonlinear constraints.

Variable elimination and the simplex algorithm are used for solving linear and polynomial equations and inequalities, and problems containing variables with infinite domain. These are typically solved as optimization problems in which the optimized function is the number of violated constraints.

### Complexity

Main article: Complexity of constraint satisfaction

Solving a constraint satisfaction problem on a finite domain is an NP-complete problem with respect to the domain size. Research has shown a number of tractable subcases, some limiting the allowed constraint relations, some requiring the scopes of constraints to form a tree, possibly in a reformulated version of the problem. Research has also established relationships of the constraint satisfaction problem with problems in other areas such as finite model theory.

## Constraint programming

Main article: Constraint programming

Constraint programming is the use of constraints as a programming language to encode and solve problems. This is often done by embedding constraints into a programming language, which is called the host language. Constraint programming originated from a formalization of equalities of terms in Prolog II, leading to a general framework for embedding constraints into a logic programming language. The most common host languages are Prolog, C++, and Java, but other languages have been used as well.

### Constraint logic programming

Main article: Constraint logic programming

A constraint logic program is a logic program that contains constraints in the bodies of clauses. As an example, the clause `A(X):-X>0,B(X)` is a clause containing the constraint `X>0` in the body. Constraints can also be present in the goal. The constraints in the goal and in the clauses used to prove the goal are accumulated into a set called constraint store. This set contains the constraints the interpreter has assumed satisfiable in order to proceed in the evaluation. As a result, if this set is detected unsatisfiable, the interpreter backtracks. Equations of terms, as used in logic programming, are considered a particular form of constraints, which can be simplified using unification. As a result, the constraint store can be considered an extension of the concept of substitution that is used in regular logic programming. The most common kinds of constraints used in constraint logic programming are constraints over integers/rational/real numbers and constraints over finite domains.

Concurrent constraint logic programming languages have also been developed. They significantly differ from non-concurrent constraint logic programming in that they are aimed at programming concurrent processes that may not terminate. Constraint handling rules can be seen as a form of concurrent constraint logic programming, but are also sometimes used within a non-concurrent constraint logic programming language. They allow for rewriting constraints or to infer new ones based on the truth of conditions.

### Constraint satisfaction toolkits

Constraint satisfaction toolkits are software libraries for imperative programming languages that are used to encode and solve a constraint satisfaction problem.

* Cassowary constraint solver, an open source project for constraint satisfaction (accessible from C, Java, Python and other languages).
* Comet, a commercial programming language and toolkit
* Gecode, an open source portable toolkit written in C++ developed as a production-quality and highly efficient implementation of a complete theoretical background.
* Gelisp, an open source portable wrapper of Gecode to Lisp.[5] https://gelisp.sourceforge.net/
* IBM ILOG CP Optimizer: C++, Python, Java, .NET libraries (proprietary, free for academic use).[6] Successor of ILOG Solver/Scheduler, which was considered the market leader in commercial constraint programming software as of 2006[7]
* JaCoP, an open source Java constraint solver.
* Koalog, a commercial Java-based constraint solver.
* logilab-constraint, an open source constraint solver written in pure Python with constraint propagation algorithms.
* Minion, an open-source constraint solver written in C++, with a small language for the purpose of specifying models/problems.
* ZDC, an open source program developed in the Computer-Aided Constraint Satisfaction Project for modelling and solving constraint satisfaction problems.

### Other constraint programming languages

Constraint toolkits are a way for embedding constraints into an imperative programming language. However, they are only used as external libraries for encoding and solving problems. An approach in which constraints are integrated into an imperative programming language is taken in the Kaleidoscope programming language.

Constraints have also been embedded into functional programming languages.

## See also

* Constraint satisfaction problem
* Constraint (mathematics)
* Candidate solution
* Boolean satisfiability problem
* Decision theory
* Satisfiability modulo theories
* Knowledge-based configuration

## References

1. ↑ Tsang, Edward (13 May 2014). Foundations of Constraint Satisfaction: The Classic Text. BoD – Books on Demand. ISBN 978-3-7357-2366-6. https://books.google.com/books?id=UFmRAwAAQBAJ. Retrieved 25 August 2018.
2. ↑ Choco: An Open-Source java library for constraint programming. https://choco-solver.org Accessed Dec 12, 2021.
3. ↑ "4.1.1 Variables and Worlds‣ 4.1 Possible Worlds, Variables, and Constraints ‣ Chapter 4 Reasoning with Constraints ‣ Artificial Intelligence: Foundations of Computational Agents, 2nd Edition". https://artint.info/2e/html/ArtInt2e.Ch4.S1.SS1.html.
4. ↑ Script error: The function "in_lang" does not exist. Berthier, Denis (20 November 2012). "Pattern-Based Constraint Satisfaction and Logic Puzzles". Lulu Publishers. ISBN 978-1-291-20339-4. http://www.carva.org/denis.berthier/PBCS. Retrieved 24 October 2012.
5. ↑ Mauricio Toro, Carlos Agon, Camilo Rueda, Gerard Assayag. "GELISP: A FRAMEWORK TO REPRESENT MUSICAL CONSTRAINT SATISFACTION PROBLEMS AND SEARCH STRATEGIES ." Journal of Theoretical and Applied Information Technology 86 (2). 2016. 327-331.
6. ↑ "IBM ILOG CP optimizer for scheduling". Constraints 23 (2): 210–250. 2018. doi:10.1007/s10601-018-9281-x.
7. ↑ Rossi, Francesca; Peter Van Beek; Toby Walsh (2006). Handbook of constraint programming. Elsevier. p. 157. ISBN 978-0-444-52726-4. https://books.google.com/books?id=Kjap9ZWcKOoC&pg=PA157.

* Apt, Krzysztof (2003). Principles of constraint programming. Cambridge University Press. ISBN 978-0-521-82583-2. https://archive.org/details/principlesofcons0000aptk.
* Dechter, Rina (2003). Constraint processing. Morgan Kaufmann. ISBN 978-1-55860-890-0. https://archive.org/details/constraintproces00rina.
* Dincbas, M.; Simonis, H.; Van Hentenryck, P. (1990). "Solving Large Combinatorial Problems in Logic Programming". Journal of Logic Programming 8 (1–2): 75–93. doi:10.1016/0743-1066(90)90052-7.
* Freuder, Eugene; Mackworth, Alan, eds (1994). Constraint-based reasoning. MIT Press. ISBN 978-0-262-56075-7. https://books.google.com/books?id=7EVjkM8_A_gC. Retrieved 2020-12-27.
* Frühwirth, Thom; Slim Abdennadher (2003). Essentials of constraint programming. Springer. ISBN 978-3-540-67623-2.
* Guesguen, Hans; Hertzberg Joachim (1992). A Perspective of Constraint Based Reasoning. Springer. ISBN 978-3-540-55510-0.
* Jaffar, Joxan; Michael J. Maher (1994). "Constraint logic programming: a survey". Journal of Logic Programming 19/20: 503–581. doi:10.1016/0743-1066(94)90033-7.
* Laurière, Jean-Louis (1978). "A Language and a Program for Stating and Solving Combinatorial Problems". Artificial Intelligence 10 (1): 29–127. doi:10.1016/0004-3702(78)90029-2.
* Lecoutre, Christophe (2009). Constraint Networks: Techniques and Algorithms. ISTE/Wiley. ISBN 978-1-84821-106-3. http://www.iste.co.uk/index.php?f=a&ACTION=View&id=250. Retrieved 2009-09-06.
* Marriott, Kim; Peter J. Stuckey (1998). Programming with constraints: An introduction. MIT Press. ISBN 978-0-262-13341-8.
* Rossi, Francesca, ed (2006). Handbook of Constraint Programming. Elsevier. ISBN 978-0-444-52726-4. http://www.elsevier.com/wps/find/bookdescription.cws_home/708863/description#description. Retrieved 2006-10-13.
* Tsang, Edward (1993). Foundations of Constraint Satisfaction. Academic Press. ISBN 978-0-12-701610-8. http://www.bracil.net/edward/FCS.html. Retrieved 2007-06-07.
* Van Hentenryck, Pascal (1989). Constraint Satisfaction in Logic Programming. MIT Press. ISBN 978-0-262-08181-8. https://archive.org/details/Constraint_00_VanH.
* Rashidi, Hassan.; Tsang, Edward. (2012). "Novel constraints satisfaction models for optimization problems in container terminals". Journal of Applied Mathematical Modelling 37 (6): 3601–34. doi:10.1016/j.apm.2012.07.042.

## External links

* CSP Tutorial

### Videos

* Constraint Satisfaction Lecture by Dr Madhu Sharma (3:47)
* Introduction of Constraint Satisfaction Problems by Edward Tsang (7:34)
* Constraint Satisfaction Problems by Wheeler Ruml (9:18)
* Lecture on Constraint Satisfaction Problems by Indian Institute of Technology Madras (51:59)
* Lecture on CSPs (1:16:39)
* Lecture on Constraint Satisfaction Problems by Berkeley AI (1:17:38)
* Graduate Course in AI 5: Constraint Satisfaction by Prof Mausam (1:34:29)

* v
* t
* e

Major subfields of optimization

* Convex programming
* Integer programming
* Quadratic programming
* Nonlinear programming
* Stochastic programming
* Robust optimization
* Combinatorial optimization
* Infinite-dimensional optimization
* Metaheuristics
* Constraint satisfaction
* Multiobjective optimization

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Constraint satisfaction. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Constraint_satisfaction&oldid=4346309"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template