|
Constraint programming occurs as programming paradigm in which a placed of constraints that the guide must meet come specified like than placed of steps to obtain such a guide.
Constraint programming is related to logic programming and, since both come Turing-complete, any logic program can be translated into an tantamount constraint program & the other way around. This is another time utile within practice, since the constraint solving program could locate an guide sooner than the logic derivation program, & it will exist as suitable to perform this translation before executing a logic program.
The difference between them is largely in their styles & approaches to modeling the world. Occasionally problems come additional natural (& so, simpler) to write when logic softwcome download, when occasionally are other natural to write when constraint software download.
a constraint programming approach is to seek for the state of the globe where a heavy total of constraints come satisfied at the equivalent period. The condition is usually stated as the state of the globe containing a total of unknown variables. A constraint program searches for values for all the variables.
Temporal concurrent constraint programming (TCC) & non-deterministic temporal concurrent constraint programming (NTCC) come variants of constraint programming that may treat by having instance.
Occasionally popular application domains for constraint programming come:
boolean domains, where just true/false constraints apply
Integer domains, rational domains
linear domains, where just linear functions are described & analyzed (although approaches to non-linear problems do survive)
finite domains, where constraints come defined all over countable sets
Mixed domains, involving 2 or sir thomas more of the above
Constraint languages come occasionally embedded around the hikers language. the foremost hikers language utilized was a logic language (Prolog), so a field was at the start known as Constraint Logic Programming. Them paradigms part numerous significant features, prefer logical variables (i personally.e., when the variable is assigned the value, it can't become changed), backtracking. Today, virtually all Prolog implementations include one or even extra libraries for constraint logic programming.
A few popular constraint languages come:
[http://www.probp.com/ B-Prolog] (Prolog based)
[http://choco.sourceforge.net/ Choco] (Java based)
[http://clip.dia.fi.upm.es/Software/Ciao/ Ciao Prolog] (Prolog based)
[http://www.icparc.ic.ac.uk/eclipse/ ECLiPSe] (Prolog based)
[http://www.ilog.com/products/solver/ ILOG Solver] (C++ based)
[http://www.mozart-oz.org/ Mozart] (Oz based)
[http://www.sics.se/isl/sicstuswww/site/index.html SICStus] (Prolog based)
[http://www.koalog.com/ Koalog Constraint Solver] (Java based)
Finite Domain
Finite Domains is one of a virtually all successful domains of Constraint Programming. Inside a few areas (rather Operations The food and drug administration) Constraint Programming is typically identified by owning Constraint Programming across Finite Domains.
Finite domain convergent thinker come utile for solving Constraint satisfaction problems, and come typically according to Arc-Consistency (look at AC-3 algorithm), or one of its approximations.
A syntax of CP(FD) languages depends on the carrier language. A below occurs as program that solves a puzzle SEND+MORE=MONEY inside CLP (i personally.e., Constraint Programming according to the logic language):
sendmore(Digits) :-
Digits = [S,E,N,D,M,O,R,Y], % Produce variables
Digits :: [0..9], % Associate domains to variables
S #\= Cipher, % Constraint: S must become different from either 0
Thousand #\= Zero,
alldifferent(Digits), % all the elements must require different values
1000*S + 100*E + 10*N + 500 % More constraints
+ 1000*M + 100*O + 10*R + E
#= 10000*M + 1000*O + 100*N + 10*E + Y,
labeling(Digits). % Run a search
A constraint problem solver creates a variables, & a domains, then all a variables range above the placed of values . S#\=Cipher (which means ) is imposed, & value Cipher is flushed from either a domain of variable S. Equivalent for variable M. and then, a constraint alldifferent(Digits) is imposed: it just can't propagate any deletion, so it just suspends. So a endure constraint is imposed. From either a survive constraint, a problem solver infers that M=Single. All a constraints involving variable M come wake up: particularly alldifferent potty dislodge value Ace from either the domain of all the leftover variables. Whilst a AC-3 algorithm reached quiescence, a domains keep close at h& been reduced, and the condition is hopefully gentler to solve.
Predicate labeling starts a depth number one research: it will require a foremost value in the domain of the foremost variable, & assigns it to the variable. So, a AC-3 algorithm is resumed and performs farther domain reductions. Whenever 1 domain becomes empty, labeling backtracks & attempt a 2nd value in the domain of the 1st variable. Otherwise, it seeks the number 1 value in the domain of the 2nd variable, then in, until a guide is encountered.
|