make clp(bn) work again.
This commit is contained in:
parent
8f8ba6221e
commit
8690fb8ca0
20
C/attvar.c
20
C/attvar.c
@ -859,15 +859,19 @@ p_swi_all_atts(void) {
|
||||
return Yap_unify(ARG2,TermNil);
|
||||
while (!IsVarTerm(tatt)) {
|
||||
Functor f = FunctorOfTerm(tatt);
|
||||
UInt ar = ArityOfFunctor(f);
|
||||
|
||||
if (ArityOfFunctor(f) == 2) {
|
||||
if (H != h0)
|
||||
H[-1] = AbsAppl(H);
|
||||
H[0] = (CELL) attf;
|
||||
H[1] = MkAtomTerm(NameOfFunctor(f));
|
||||
H[2] = ArgOfTerm(2,tatt);
|
||||
H+=4;
|
||||
}
|
||||
if (H != h0)
|
||||
H[-1] = AbsAppl(H);
|
||||
H[0] = (CELL) attf;
|
||||
H[1] = MkAtomTerm(NameOfFunctor(f));
|
||||
/* SWI */
|
||||
if (ar == 2)
|
||||
H[2] = ArgOfTerm(2,tatt);
|
||||
else
|
||||
H[2] = tatt;
|
||||
H += 4;
|
||||
H[-1] = AbsAppl(H);
|
||||
tatt = ArgOfTerm(1,tatt);
|
||||
}
|
||||
if (h0 != H) {
|
||||
|
@ -169,7 +169,7 @@ add_evidence(V,K,_,V) :-
|
||||
clpbn_marginalise(V, Dist) :-
|
||||
attributes:all_attvars(AVars),
|
||||
project_attributes([V], AVars),
|
||||
vel:get_atts(V, posterior(_,_,Dist,_)).
|
||||
clpbn_display:get_atts(V, posterior(_,_,Dist,_)).
|
||||
|
||||
%
|
||||
% called by top-level
|
||||
|
@ -33,7 +33,7 @@ gen_eqs([V], D, (V=D)) :- !.
|
||||
gen_eqs([V|Vs], [D|Ds], ((V=D),Eqs)) :-
|
||||
gen_eqs(Vs,Ds,Eqs).
|
||||
|
||||
add_alldiffs([],Eqs,Eqs).
|
||||
add_alldiffs([],Eqs,Eqs) :- !.
|
||||
add_alldiffs(AllDiffs,Eqs,(Eqs/alldiff(AllDiffs))).
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
delayed_goals/4
|
||||
]).
|
||||
|
||||
:- dynamic attributes:attributed_module/3, attributes:modules_with_attributes/1.
|
||||
|
||||
prolog:get_attr(Var, Mod, Att) :-
|
||||
functor(AttTerm, Mod, 2),
|
||||
arg(2, AttTerm, Att),
|
||||
@ -201,6 +203,20 @@ attvar_residuals(att(Module,Value,As), V) -->
|
||||
-> % a previous projection predicate could have instantiated
|
||||
% this variable, for example, to avoid redundant goals
|
||||
[]
|
||||
; { attributes:attributed_module(Module, _, _) } ->
|
||||
% SICStus like run, put attributes back first
|
||||
{ Value =.. [Name,_|Vs],
|
||||
NValue =.. [Name,_|Vs],
|
||||
attributes:put_module_atts(V,NValue)
|
||||
},
|
||||
attvar_residuals(As, V),
|
||||
( { '$undefined'(attribute_goal(V, Goal), Module) }
|
||||
->
|
||||
[]
|
||||
;
|
||||
{ '$notrace'(Module:attribute_goal(V, Goal)) },
|
||||
dot_list(Goal)
|
||||
)
|
||||
; ( { current_predicate(Module:attribute_goals/3) }
|
||||
-> { '$notrace'(Module:attribute_goals(V, Goals, [])) },
|
||||
list(Goals)
|
||||
@ -208,9 +224,9 @@ attvar_residuals(att(Module,Value,As), V) -->
|
||||
-> { '$notrace'(Module:attribute_goal(V, Goal)) },
|
||||
dot_list(Goal)
|
||||
; [put_attr(V, Module, Value)]
|
||||
)
|
||||
),
|
||||
attvar_residuals(As, V).
|
||||
),
|
||||
attvar_residuals(As, V)
|
||||
).
|
||||
|
||||
list([]) --> [].
|
||||
list([L|Ls]) --> [L], list(Ls).
|
||||
@ -242,7 +258,7 @@ prolog:call_residue(Goal,Residue) :-
|
||||
call_residue(Goal,Module,Residue) :-
|
||||
prolog:call_residue_vars(Module:Goal,NewAttVars),
|
||||
(
|
||||
'$undefined'(modules_with_attributes(_),attributes)
|
||||
attributes:modules_with_attributes([_|_])
|
||||
->
|
||||
project_attributes(NewAttVars, Module:Goal)
|
||||
;
|
||||
@ -254,13 +270,12 @@ delayed_goals(G, Vs, NVs, Gs) :-
|
||||
project_delayed_goals(G),
|
||||
copy_term(G.Vs, _.NVs, Gs).
|
||||
|
||||
project_delayed_goals(G) :-
|
||||
'$undefined'(modules_with_attributes(_),attributes), !.
|
||||
project_delayed_goals(G) :-
|
||||
% SICStus compatible step,
|
||||
% just try to simplify store by projecting constraints
|
||||
% over query variables.
|
||||
% called by top_level to find out about delayed goals
|
||||
attributes:modules_with_attributes([_|_]), !,
|
||||
attributes:all_attvars(LAV),
|
||||
LAV = [_|_],
|
||||
project_attributes(LAV, G), !.
|
||||
@ -279,10 +294,9 @@ att_vars([_|LGs], AttVars) :-
|
||||
|
||||
% make sure we set the suspended goal list to its previous state!
|
||||
% make sure we have installed a SICStus like constraint solver.
|
||||
project_attributes(_, _) :-
|
||||
'$undefined'(modules_with_attributes(_),attributes), !.
|
||||
project_attributes(AllVs, G) :-
|
||||
attributes:modules_with_attributes(LMods),
|
||||
LMods = [_|_],
|
||||
term_variables(G, InputVs),
|
||||
pick_att_vars(InputVs, AttIVs),
|
||||
project_module(LMods, AttIVs, AllVs).
|
||||
|
Reference in New Issue
Block a user