Labeling
The labeling literals are used on variables over finite domains to check satisfiability or partial satisfiability of the constraint store and to find a satisfying assignment. A labeling literal is of the form labeling
, where the argument is a list of variables over finite domains. Whenever the interpreter evaluates such a literal, it performs a search over the domains of the variables of the list to find an assignment that satisfies all relevant constraints. Typically, this is done by a form of backtracking: variables are evaluated in order, trying all possible values for each of them, and backtracking when inconsistency is detected.
The first use of the labeling literal is to actual check satisfiability or partial satisfiability of the constraint store. When the interpreter adds a constraint to the constraint store, it only enforces a form of local consistency on it. This operation may not detect inconsistency even if the constraint store is unsatisfiable. A labeling literal over a set of variables enforces a satisfiability check of the constraints over these variables. As a result, using all variables mentioned in the constraint store results in checking satisfiability of the store.
The second use of the labeling literal is to actually determine an evaluation of the variables that satisfies the constraint store. Without the labeling literal, variables are assigned values only when the constraint store contains a constraint of the form X=value
and when local consistency reduces the domain of a variable to a single value. A labeling literal over some variables forces these variables to be evaluated. In other words, after the labeling literal has been considered, all variables are assigned a value.
Typically, constraint logic programs are written in such a way labeling literals are evaluated only after as many constraints as possible have been accumulated in the constraint store. This is because labeling literals enforce search, and search is more efficient if there are more constraints to be satisfied. A constraint satisfaction problem is typical solved by a constraint logic program having the following structure:
solve(X):-constraints(X), labeling(X) constraints(X):- (all constraints of the CSP)When the interpreter evaluates the goal solve(args)
, it places the body of a fresh variant of the first clause in the current goal. Since the first goal is constraints(X')
, the second clause is evaluated, and this operation moves all constraints in the current goal and eventually in the constraint store. The literal labeling(X')
is then evaluated, forcing a search for a solution of the constraint store. Since the constraint store contains exactly the constraints of the original constraint satisfaction problem, this operation searches for a solution of the original problem.
Read more about this topic: Constraint Logic Programming
Famous quotes containing the word labeling:
“Although adults have a role to play in teaching social skills to children, it is often best that they play it unobtrusively. In particular, adults must guard against embarrassing unskilled children by correcting them too publicly and against labeling children as shy in ways that may lead the children to see themselves in just that way.”
—Zick Rubin (20th century)