method_pfd_constract_act_many( [], [], _Op, _Active, [] ). method_pfd_constract_act_many( [Mt|Mts], [Fd|Fds], Op, Active, [PsH|PsT] ) :- method_pfd_constract_act( Mt, Fd, Active, Dm, Pr ), ord_zip( Pr, Dm, Op, [], PsH ), method_pfd_constract_act_many( Mts, Fds, Op, Active, PsT ). method_pfd_constract_act( Method, Fd, Active, NewFd, Prs ) :- ( Method = (SMtd,Var,Cns,CPr) -> active_selects( [Var], Active, [Var-VarData] ), data_choose( dmn(Dmn), VarData ), ( is_val( Dmn ) -> method_synthesis(Cns,CPr,SMtd,Dmn,Fd,NewFd,Prs) ; % (probably) an internal error % print_message( error, unable_to_construct_domain( % depending_on(Var), which_has_domain(Dmn), instead_of_value) ) throw( pfd(construct_domain_fails(Var,Dmn)) ) ) ; % March 2000 addition, trying to cope with instatiation to pfd vars. ( singleton(Fd) -> % here we assume all things in store are Lists .... Prs = [1/1] % logicaly speaking this is sound. ; method_apply( Method, Fd, Prs ) ), NewFd = Fd % method_apply( Method, Fd, Prs ), % NewFd = Fd ). method_pfd_constract( Method, Fd, Probed, NewFd, Prs ) :- ( Method = (SMtd,Var,Cns,CPr) -> probed_find( Var, Probed, Val ), is_only_rational( CPr, Method, 4 ), method_synthesis( Cns, CPr, SMtd, Val, Fd, NewFd, Prs ) ; method_apply( Method, Fd, Prs ), NewFd = Fd ). method_synthesis( cond_diff, CPr, Mtd, Val, Fd, SynthFd, AllPrs ) :- ( CPr = 0/1 -> % that means vars should be = SynthFd = [Val], AllPrs = [1/1] ; ( aux_ord_del_element( Fd, Val, Nth, ClFd ) -> true ; ClFd = Fd, Nth is 0 ), method_apply( Mtd, ClFd, MtPrs ), ( CPr = 1/1 -> % vars shall be # SynthFd = ClFd, AllPrs = MtPrs ; ( Nth =\= 0 -> rationals_subtraction( 1/1, CPr, ComplPr ), measure_constraint( MtPrs, CPr, Ms ), aux_add_element_on_nth( ClFd, Nth, Val, SynthFd ), aux_add_element_on_nth( Ms, Nth, ComplPr, AllPrs ) ; SynthFd = ClFd, AllPrs = MtPrs ) ) ). method_apply( Method, Fd, Probs ) :- Method =.. MethList, append( MethList, [Fd,Probs], AllArgsList ), MethTerm =.. AllArgsList, % ( call(probabilistic_method(MethTerm)) -> ( probabilistic_method(MethTerm) -> true ; % fail throw( pfd(probabilistic_method_fails(MethTerm)) ) ). method_apply_pairs( Method, Fd, FdProbs ) :- method_apply( Method, Fd, Probs ), kv_compose( Fd, Probs, FdProbs ). method_normalise( Method, NormMethod, Set ) :- Method =.. MethList, ( (MethList=[Fnc,Dom|RestArgs], remove_duplicates(Dom,Set) ) -> true ; % fixme Set was Dom print_message( error, domain_error(Method,1,list_of_atoms,Set) ) ), NormMethod =.. [Fnc|RestArgs]. n_term_list( 0, _Term, [] ) :- !. n_term_list( N, Term, [Term|MoreTermS] ) :- N1 is N - 1, n_term_list( N1, Term, MoreTermS ). % label methods, label_method( dmn_order(Dmn,Prs,Val,ValPr) ) :- nth1( Idx, Dmn, Val ), nth1( Idx, Prs, ValPr ). label_method( pr_order(Dmn,Prs,Val,ValPr) ) :- order_accordingly( Prs, Dmn, ShflPrs, ShflDmn ), probe( ShflPrs, ShflDmn, Val, ValPr ). order_accordingly( Prs, Dmn, ShflPrs, ShflDmn ) :- aux_cartesian( Prs, Dmn, Cart ), sort( Cart, SortCart ), aux_cartesian( ShflPrs, ShflDmn, SortCart ). % method_finite_geometric_sum_denom( I, Zeronembs, Acc, Denom ) :- % NxAcc is Acc + (2 ** I), % ( I = Zeronembs -> % Denom is integer( NxAcc ) % % ; % NxI is I + 1, % method_finite_geometric_sum_denom( NxI, Zeronembs, NxAcc, Denom ) % ). method_finite_geometric_nominators( J, Nembers, Factor, Noms ) :- ( J > Nembers -> Noms = [] ; Nom is integer( Factor ** ( Nembers - J ) ), Noms = [Nom|TNoms], NxJ is J + 1, method_finite_geometric_nominators( NxJ, Nembers, Factor, TNoms ) ). methods_integers_to_rationals( [], _Denom, [] ). methods_integers_to_rationals( [H|T], Denom, [H/Denom|TPrbs] ) :- methods_integers_to_rationals( T, Denom, TPrbs ).