min_conflicts to
local_search by simply replacing the guess predicate by the
predicate move:
|
local_search with the predicate
hill_climb:
|
try_move is very inefficient, because it
repeatedly goes through the whole list of conflict constraints to
count the number of constraints in conflict.
The facility to propagate tentative values supports more efficient
maintenance of the number constraints in conflict.
This technique is known as maintenance of invariants (see
[18]).
For the propositional satisfiability example we can maintain the
number of satisfied clauses to make the hill climbing implementation
more efficient. BSum records for any tentative
assignment of the propositional variables, the number of satisfied
clauses.
This speeds up hill climbing because, after each move, its effect on
the number of satisfied clauses is automatically computed by the
propagation of tentative values.
|
BSum before and after the move is done.
Remember that, since the move operator changes the tentative values of
some variable, the tent_is primitive will automatically
update the BSum variable.
Local search can be implemented in ECLiPSe with the repair library. Invariants can be implemented by tentative value propagation using tent_is/2.
Figure 13.4: Local Search and Invariants