On 31/01/2014 23:24, Martin Michalowski wrote: > Hi, > I’m trying to get the repair library from the documentation to work. The following is my ECLiPSe code: > > :- lib(repair). > > test(X,Y,Z) :- > ( > Vars = [X,Y,Z], > fd:(Vars :: 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 > > repair(confset), > writeln("------------\nDone\n------------") > ). > > 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 problem is that indomain throws a type error, even though it is being passed a variable returned by conflict_vars. I get: > > type error in indomain(Z{fd : [1, 2], repair : 3}) > Abort > > Any help would be greatly appreciated. I'm no sure how you managed to get the type error, I don't get that. But if you add a :- lib(fd). directive at the beginning of your code, it will be fine. -- JoachimReceived on Mon Feb 03 2014 - 13:10:02 CET
This archive was generated by hypermail 2.2.0 : Tue Feb 11 2014 - 06:13:50 CET