If all the constraints of a problem are monitored for conflicts, then the problem can be solved by:
Consider a satisfiability problem with each clause represented by an
ic constraint, whose form is illustrated by the following example:
(X1 or neg X2 or X3 $= 1.
This represents the clause X1 ∨ ¬ X2 ∨ X3.
To apply conflict minimisation to this problem use the predicate:
tent_init to find an initial solution
conflict_constraints and term_variables to find a
variable to label
set_to_tent to set the remaining variables to their
tentative values
The code is as follows:
|
The value choice predicate guess is naive. Since the variable
occurs in a conflict constraint it would arguably be better to label
it to another value. This would be implemented as follows:
|
To illustrate a combination of repair with ic propagation we tackle a scheduling example. The problem involves tasks with unknown start times, and known durations, which are related by a variety of temporal constraints. These temporal constraints are handled, for the purposes of this example, by ic. The temporal constraints are encoded thus:
|
TimePoint1 and TimePoint2 are variables (or numbers),
but we assume, for this example, that the
Interval is a number.
This constraint can enforce a minimum separation between start times,
or a maximum separation (if the Interval is negative). It can
also enforce constraints between end times, by adjusting the
Interval to account for the task durations.
Additionally we assume that certain tasks require the same resource and cannot therefore proceed at the same time. The resource constraint is encoded thus:
|
Suppose the requirement is to complete the schedule as early as
possible.
To express this we introduce a last time point End which is
constrained to come after all the tasks.
Ignoring the resource constraints, the temporal constraints are easily
handled by ic.
The optimal solution is obtained simply by posting the temporal
constraints and then instantiating each start
time to the lowest value in its domain.
To deal with the resource constraints conflict minimisation is used. The least (i.e. optimal) value in the domain of each variable is chosen as its tentative value, at each node of the search tree.
To fix a constraint in conflict, we simply invoke its nondetermistic
definition, and
ECLiPSe then unfolds the first clause and sends the new temporal
constraint Start2 #>= Start1+Duration1 to ic.
On backtracking, the second clause will be unfolded instead.
After fixing a resource constraint, and posting a new temporal constraint, ic propagation takes place, and then the tentative values are changed to the new ic lower bounds.
The code is simply this:
|
This code is much more robust than the traditional code
for solving the bridge scheduling example from [27].
The code is in the examples directory file bridge_repair.pl.
This algorithm uses the ic solver to:
This technique is called probing. The use of the eplex solver, instead of ic for probing is described in chapter 17 below.
Repair naturally supports conflict minimisation. This algorithm can be combined with other solvers, such as ic, and with optimization.
Figure 13.3: Conflict Minimisation