Content deleted Content added
No edit summary |
|||
Line 3:
{{Programming paradigms}}
'''Constraint programming (CP)'''<ref name=":0">{{Cite book|url=https://books.google.com/books?id=Kjap9ZWcKOoC&q=handbook+of+constraint+programming&pg=PP1|title=Handbook of Constraint Programming|last1=Rossi|first1=Francesca|author1link = Francesca Rossi|last2=Beek|first2=Peter van|last3=Walsh|first3=Toby|author3link = Toby Walsh|date=2006-08-18|publisher=Elsevier|isbn=9780080463803|language=en}}</ref> is a paradigm for solving [[combinatorial]] problems that draws on a wide range of techniques from [[artificial intelligence]], [[computer science]], and [[operations research]]. In constraint programming, users declaratively state the [[Constraint (mathematics)|constraints]] on the feasible solutions for a set of decision variables. Constraints differ from the common [[Language primitive|primitives]] of [[imperative programming]] languages in that they do not specify a step or sequence of steps to execute, but rather the properties of a solution to be found. In addition to constraints, users also need to specify a method to solve these constraints. This typically draws upon standard methods like chronological [[backtracking]] and [[constraint propagation]], but may use customized code like a problem-specific branching [[Heuristic (computer science)|heuristic]].
Constraint programming takes its root from and can be expressed in the form of [[constraint logic programming]], which embeds constraints into a [[logic program]]. This variant of logic programming is due to Jaffar and Lassez,<ref>Jaffar, Joxan, and J-L. Lassez. "[https://dl.acm.org/citation.cfm?id=41635 Constraint logic programming]." Proceedings of the 14th [[ACM
Instead of logic programming, constraints can be mixed with [[functional programming]], [[term rewriting]], and [[imperative language]]s.
Line 24:
{{main|Constraint satisfaction problem}}
A constraint is a relation between multiple variables
{{math theorem
|Definition
Line 30:
* <math>\mathcal{X} = \{x_1, \dots, x_n \}</math> is the set of variables of the problem;
* <math>\mathcal{D} = \{\mathcal{D}_1, \dots, \mathcal{D}_n \}</math> is the set of domains of the variables, i.e., for all <math>k \in [1; n]</math> we have <math>x_k \in \mathcal{D}_k</math>;
* <math>\mathcal{C} = \{C_1, \dots, C_m \}</math> is a set of constraints. A constraint <math>C_i=(\mathcal{X}_i, \mathcal{R}_i)</math> is defined by a set <math>\mathcal{X}_i = \{x_{i_1}, \dots, x_{i_k}\}</math> of variables and a relation <math>\mathcal{R}_i \
}}
Line 36:
* extensional constraints: constraints are defined by enumerating the set of values that would satisfy them;
* arithmetic constraints: constraints are defined by an arithmetic expression, i.e., using <math><, >, \leq, \geq, =, \neq,...</math>;
* logical constraints: constraints are defined with an explicit
{{math theorem
|Definition
| An assignment (or model) <math>\mathcal{A}</math> of a CSP <math>P = (\mathcal{X},\mathcal{D},\mathcal{C})</math> is defined by the couple <math>\mathcal{A} = (\mathcal{X_{\mathcal{A}}}, \mathcal{V_{\mathcal{A}}})</math> where:
* <math>\mathcal{X_{\mathcal{A}}} \
* <math>\mathcal{V_{\mathcal{A}}} = \{ v_{\mathcal{A}_1}, \dots, v_{\mathcal{A}_k}\} \in \{ \mathcal{D}_{\mathcal{A}_1}, \dots, \mathcal{D}_{\mathcal{A}_k}\}</math> is the tuple of the values taken by the assigned variables.
}}
Line 49:
{{math theorem
|Property
|Given <math>\mathcal{A} = (\mathcal{X_{\mathcal{A}}}, \mathcal{V_{\mathcal{A}}})</math> an
}}
{{math theorem
|Definition
|A solution of a CSP is a total
During the search of the solutions of a CSP, a user can wish for:
|