diff --git a/src/lib/clpb.pl b/src/lib/clpb.pl index 75a382827..f41e2100b 100644 --- a/src/lib/clpb.pl +++ b/src/lib/clpb.pl @@ -1276,13 +1276,18 @@ maplist(var_with_index, Vars, IVs), pairs_keys_values(Pairs0, IVs, Ws), keysort(Pairs0, Pairs1), - pairs_keys_values(Pairs1, IVs1, WeightsIndexOrder), + % sum linear combinations of repeated variables + group_pairs_by_key(Pairs1, Groups), + maplist(group_sumweights_pair, Groups, Pairs2), + pairs_keys_values(Pairs2, IVs1, WeightsIndexOrder), pairs_values(IVs1, VarsIndexOrder), % Pairs is a list of Var-Weight terms, in index order of Vars pairs_keys_values(Pairs, VarsIndexOrder, WeightsIndexOrder), bdd_maximum(BDD, Pairs, Max), max_labeling(BDD, Pairs). +group_sumweights_pair((I-V)-Ws, (I-V)-W) :- sum_list(Ws, W). + max_labeling(1, Pairs) :- max_upto(Pairs, _, _). max_labeling(node(_,Var,Low,High,Aux), Pairs0) :- max_upto(Pairs0, Var, Pairs), @@ -1517,8 +1522,8 @@ pairs_([B|Bs], A) --> [A-B], pairs_(Bs, A). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set the Prolog flag clpb_residuals to bdd to obtain the BDD nodes - as residuals. Note that they cannot be used as regular goals. + Assert clpb:clpb_residuals(bdd) to obtain the BDD nodes as + residuals. Note that they cannot be used as regular goals. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ nodes([]) --> []. diff --git a/src/lib/format.pl b/src/lib/format.pl index 823c700ca..d873f2cc3 100644 --- a/src/lib/format.pl +++ b/src/lib/format.pl @@ -153,7 +153,7 @@ available space is distributed. newline is used if ~n occurs in a format string. - It is is used because a newline character does not + It is used because a newline character does not consume whitespace in the sense of format strings. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */