allow backtracking over possible values of constraints.a

This commit is contained in:
Vitor Santos Costa 2012-12-13 15:53:01 +00:00
parent 8b996c5dc9
commit c4448d066a

View File

@ -109,7 +109,7 @@ collect(Keys, Factors) :-
queue_in(K) :- queue_in(K) :-
queue(K), !. queue(K), !.
queue_in(K) :- queue_in(K) :-
%writeln(+K), % writeln(q+K),
assert(queue(K)), assert(queue(K)),
fail. fail.
queue_in(_). queue_in(_).
@ -139,7 +139,7 @@ do_propagate(_K) :-
propagate. propagate.
add_factor(factor(Type, Id, Ks, _, _Phi, Constraints), NKs) :- add_factor(factor(Type, Id, Ks, _, _Phi, Constraints), NKs) :-
%writeln(+Ks), % writeln(+Ks),
( Ks = [K,Els], var(Els) ( Ks = [K,Els], var(Els)
-> ->
% aggregate factor % aggregate factor
@ -147,7 +147,7 @@ add_factor(factor(Type, Id, Ks, _, _Phi, Constraints), NKs) :-
avg_factors(K, Els, 0.0, NewKeys, NewId), avg_factors(K, Els, 0.0, NewKeys, NewId),
NKs = [K|NewKeys] NKs = [K|NewKeys]
; ;
once(run(Constraints)), run(Constraints),
NKs = Ks, NKs = Ks,
Id = NewId Id = NewId
), ),