encyclopegia.org

constraint programming

Constraint programming (CP) 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 constraints on the feasible solutions for a set of decision variables. Constraints differ from the common 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. 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, who extended in 1987 a specific class of constraints that were introduced in Prolog II. The first implementations of constraint logic programming were Prolog III, CLP(R), and CHIP. Instead of logic programming, constraints can be mixed with functional programming, term rewriting, and imperative languages.…

Constraint programming (CP) 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 constraints on the feasible solutions for a set of decision variables. Constraints differ from the common 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. 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, who extended in 1987 a specific class of constraints that were introduced in Prolog II. The first implementations of constraint logic programming were Prolog III, CLP(R), and CHIP. Instead of logic programming, constraints can be mixed with functional programming, term rewriting, and imperative languages. Programming languages with built-in support for constraints include Oz (functional programming) and Kaleidoscope (imperative programming). Mostly, constraints are implemented in imperative languages via constraint solving toolkits, which are separate libraries for an existing imperative language. ==Constraint logic programming== Constraint programming is an embedding of constraints in a host language. The first host languages used were logic programming languages, so the field was initially called constraint logic programming. The two paradigms share many important features, like logical variables and backtracking. Today most Prolog implementations include one or more libraries for constraint logic programming. The difference between the two is largely in their styles and approaches to modeling the world. Some problems are more natural (and thus, simpler) to write as logic programs, while some are more natural to write as constraint programs. The constraint programming approach is to search for a state of the world in which a large number of constraints are satisfied at the same time. A problem is typically stated as a state of the world containing a number of unknown variables. The constraint program searches for values for all the variables. Temporal concurrent constraint programming (TCC) and non-deterministic temporal concurrent constraint programming (MJV) are variants of constraint programming that can deal with time. ==Constraint satisfaction problem== A constraint is a relation between multiple variables that limits the values these variables can take simultaneously. {{math theorem |Definition |A constraint satisfaction problem on finite domains (or CSP) is defined by a triplet (\mathcal{X},\mathcal{D},\mathcal{C}) where: \mathcal{X} = \{x_1, \dots, x_n \} is the set of variables of the problem; \mathcal{D} = \{\mathcal{D}_1, \dots, \mathcal{D}_n \} is the set of domains of the variables, i.e., for all k \in [1; n] we have x_k \in \mathcal{D}_k ; \mathcal{C} = \{C_1, \dots, C_m \} is a set of constraints. A constraint C_i=(\mathcal{X}_i, \mathcal{R}_i) is defined by a set \mathcal{X}_i = \{x_{i_1}, \dots, x_{i_k}\} of variables and a relation \mathcal{R}_i \subseteq \mathcal{D}_{i_1} \times \dots \times \mathcal{D}_{i_k} that defines the set of values allowed simultaneously for the variables of \mathcal{X}_i . }} Three categories of constraints exist: 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 , \leq, \geq, =, \neq,... ; logical constraints: constraints are defined with an explicit semantics, i.e., AllDifferent, AtMost,... {{math theorem |Definition | An assignment (or model) \mathcal{A} of a CSP P = (\mathcal{X},\mathcal{D},\mathcal{C}) is defined by the couple \mathcal{A} = (\mathcal{X_{\mathcal{A}}}, \mathcal{V_{\mathcal{A}}}) where: \mathcal{X_{\mathcal{A}}} \subseteq \mathcal{X} is a subset of variable; \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}\} is the tuple of the values taken by the assigned variables. }} Assignment is the association of a variable to a value from its domain. A partial assignment is when a subset of the variables of the problem has been assigned. A total assignment is when all the variables of the problem have been assigned. {{math theorem|Property|Given \mathcal{A} = (\mathcal{X_{\mathcal{A}}}, \mathcal{V_{\mathcal{A}}}) an assignment (partial or total) of a CSP P = (\mathcal{X},\mathcal{D},\mathcal{C}) , and C_i = (\mathcal{X}_i, \mathcal{R}_i) a constraint of P such as \mathcal{X}_i \subseteq \mathcal{X_{\mathcal{A}}} , the assignment \mathcal{A} satisfies the constraint C_i if and only if all the values \mathcal{V}_{\mathcal{A}_i} = \{ v_i \in \mathcal{V}_{\mathcal{A}} \mbox{ such that } x_i \in \mathcal{X}_{i} \} of the variables of the constraint C_i belongs to \mathcal{R}_i . }} During the search of the solutions of a CSP, a user can wish for: finding a solution (satisfying all the constraints); finding all the solutions of the problem; proving the unsatisfiability of the problem. ==Perturbation vs refinement models== Languages for constraint-based programming follow one of two approaches: Refinement model: variables in the problem are initially unassigned, and each variable is assumed to be able to contain any value included in its range or domain. As computation progresses, values in the domain of a variable are pruned if they are shown to be incompatible with the possible values of other variables, until a single value is found for each variable. Perturbation model: variables in the problem are assigned a single initial value. At different times one or more variables receive perturbations (changes to their old value), and the system propagates the change trying to assign new values to other variables that are consistent with the perturbation. Constraint propagation in constraint satisfaction problems is a typical example of a refinement model, and formula evaluation in spreadsheets are a typical example of a perturbation model. The refinement model is more general, as it does not restrict variables to have a single value, it can lead to several solutions to the same problem. However, the perturbation model is more intuitive for programmers using mixed imperative constraint object-oriented languages. ==Domains== The constraints used in constraint programming are typically over some specific domains. Some popular domains for constraint programming are: Boolean domains, where only true/false constraints apply (SAT problem) integer domains, rational domains interval domains, in particular for scheduling problems linear domains, where only linear functions are described and analyzed (although approaches to non-linear problems do exist) finite domains, where constraints are defined over finite sets mixed domains, involving two or more of the above Finite domains is one of the most successful domains of constraint programming. In some areas (like operations research) constraint programming is often identified with constraint programming over finite domains. The syntax for expressing constraints over finite domains depends on the host language. The following is a Prolog program that solves the classical alphametic puzzle SEND+MORE=MONEY in constraint logic programming: % This code works in both YAP and SWI-Prolog using the environment-supplied % CLPFD constraint solver library. It may require minor modifications to work % in other Prolog environments or using other constraint solvers. - use_module(library(clpfd)). sendmore(Digits) :- Digits = [S,E,N,D,M,O,R,Y], % Create variables Digits ins 0..9, % Associate domains to variables S #\= 0, % Constraint: S must be different from 0 M #\= 0, all_different(Digits), % all the elements must take different values 1000*S + 100*E + 10*N + D % Other constraints + 1000*M + 100*O + 10*R + E #= 10000*M + 1000*O + 100*N + 10*E + Y, label(Digits). % Start the search The interpreter creates a variable for each letter in the puzzle. The operator ins is used to specify the domains of these variables, so that they range over the set of values {0,1,2,3, ..., 9}. The constraints S#\=0 and M#\=0 means that these two variables cannot take the value zero. When the interpreter evaluates these constraints, it reduces the domains of these two variables by removing the value 0 from them. Then, the constraint all_different(Digits) is considered; it does not reduce any domain, so it is simply stored. The last constraint specifies that the digits assigned to the letters must be such that "SEND+MORE=MONEY" holds when each letter is replaced by its corresponding digit. From this constraint, the solver infers that M=1. All stored constraints involving variable M are awakened: in this case, constraint propagation on the all_different constraint removes value 1 from the domain of all the remaining variables. Constraint propagation may solve the problem by reducing all domains to a single value, it may prove that the problem has no solution by reducing a domain to the empty set, but may also terminate without proving satisfiability or unsatisfiability. The label literals are used to actually perform search for a solution. ==See also== Combinatorial optimization Concurrent constraint logic programming Constraint logic programming Heuristic algorithms List of constraint programming languages Mathematical optimization Nurse scheduling problem Regular constraint Satisfiability modulo theories Traveling tournament problem ==References== ==External links== International Conference on Principles and Practice of Constraint Programming. Association for Constraint Programming. , an Oz-based free software (X Window System style)

References

  1. constraint programming · retrieved 2026-11-23 · rev 1369233996
    Cite this reference

    MLA "constraint programming." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1369233996. Accessed 24 November 2026.

    Chicago "constraint programming." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1369233996.

    APA encyclopegia.org. (2026). constraint programming. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1369233996

Cite this article

MLA

"constraint programming." encyclopegia.org, 2026, https://encyclopegia.org/wiki/constraint-programming. Accessed 24 November 2026.

Chicago

"constraint programming." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/constraint-programming.

APA

encyclopegia.org. (2026). constraint programming. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/constraint-programming

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
definitiona paradigm for solving combinatorial problems that draws on a wide range of techniques from artificial intelligence, computer science, and operations research.article body
year mentioned1987article body
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1369233996 · 0.55 · snapshot constraint-programming-060882-08903c29b331588e · QID Q528588

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.