[eclipse 1]: lib(repair), lib(fd). % libraries needed here
yes.
[eclipse 2]:
fd:([X,Y,Z]::1..3), % the problem variables
fd:(Y #\= X) r_conflict_prop confset, % state the constraints
fd:(Y #\= Z) r_conflict_prop confset,
fd:(Y #= 3) r_conflict_prop confset,
[X,Y,Z] tent_set [1,2,3], % set initial assignment
[X,Y,Z] tent_get [NewX,NewY,NewZ], % get repaired solution
conflict_constraints(confset, Cs), % see the conflicts
conflict_vars(Vs).
X = X{fd:[1..3], repair:1}
Y = 3
Z = Z{fd:[1, 2], repair:3}
NewX = 1
NewY = 3
NewZ = 3
Cs = [3 #\= Z{fd:[1, 2], repair:3}]
Vs = [Z{fd:[1, 2], repair:3}]
Delayed goals:
...
yes.
Initially only the third constraint
repair(ConflictSet) :-
( conflict_vars([C|_]) -> % label conflict
indomain(C), % variables first
repair(ConflictSet)
; conflict_constraints(ConflictSet, [C|_]) ->
term_variables(C, Vars), % choose one variable in
deleteffc(Var,Vars, _), % the conflict constraint
Var tent_get Val,
(Var = Val ; fd:(Var #\= Val)),
repair(ConflictSet)
; % no more conflicts:
true % a solution is found.
).
The predicate is recursive and terminates when there are no more variables
or constraints in conflict.