Download ECLiPSe: Tutorial - Computer Science & Engineering
Transcript
Repair is used for:
• Re-solving problems which have been modified
• Combining subproblem solutions and algorithms
• Implementing local search
• Implementing powerful search heuristics
Figure 13.1: Uses of Repair
?- X tent_set 1,
X tent_get Tent1,
writeln(Tent1),
X tent_set 2,
X tent_get Tent2,
writeln(Tent2).
Throughout this query X remains a variable.
A tentative variable may violate constraints. The following query writes succeed, because
setting the tentative value to 1 does not cause a failure:
?- X $> 2,
X tent_set 1,
writeln(succeed).
13.2.2
Building and Accessing Conflict Sets
The relation between constraints and tentative values can be maintained in two ways. The first
method is by monitoring a constraint for conflicts.
?- X $> 2 r_conflict myset,
X tent_set 1,
writeln(succeed).
This query also succeeds - but additionally it creates a conflict set named myset. Because
X$ > 2 is violated by the tentative value of X, the constraint is recorded in the conflict set.
The conflict set written out by the following query is [X{1} $> 2]:
?- X $> 2 r_conflict myset,
X tent_set 1,
conflict_constraints(myset,Conflicts),
writeln(Conflicts).
The conflict can be repaired by changing the tentative value of the variable which causes it:
136