@@ -1276,13 +1276,18 @@ weighted_maximum(Ws, Vars, Max) :-
|
|||||||
maplist(var_with_index, Vars, IVs),
|
maplist(var_with_index, Vars, IVs),
|
||||||
pairs_keys_values(Pairs0, IVs, Ws),
|
pairs_keys_values(Pairs0, IVs, Ws),
|
||||||
keysort(Pairs0, Pairs1),
|
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_values(IVs1, VarsIndexOrder),
|
||||||
% Pairs is a list of Var-Weight terms, in index order of Vars
|
% Pairs is a list of Var-Weight terms, in index order of Vars
|
||||||
pairs_keys_values(Pairs, VarsIndexOrder, WeightsIndexOrder),
|
pairs_keys_values(Pairs, VarsIndexOrder, WeightsIndexOrder),
|
||||||
bdd_maximum(BDD, Pairs, Max),
|
bdd_maximum(BDD, Pairs, Max),
|
||||||
max_labeling(BDD, Pairs).
|
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(1, Pairs) :- max_upto(Pairs, _, _).
|
||||||
max_labeling(node(_,Var,Low,High,Aux), Pairs0) :-
|
max_labeling(node(_,Var,Low,High,Aux), Pairs0) :-
|
||||||
max_upto(Pairs0, Var, Pairs),
|
max_upto(Pairs0, Var, Pairs),
|
||||||
@@ -1517,8 +1522,8 @@ pairs_([], _) --> [].
|
|||||||
pairs_([B|Bs], A) --> [A-B], pairs_(Bs, A).
|
pairs_([B|Bs], A) --> [A-B], pairs_(Bs, A).
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Set the Prolog flag clpb_residuals to bdd to obtain the BDD nodes
|
Assert clpb:clpb_residuals(bdd) to obtain the BDD nodes as
|
||||||
as residuals. Note that they cannot be used as regular goals.
|
residuals. Note that they cannot be used as regular goals.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
nodes([]) --> [].
|
nodes([]) --> [].
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ element_gluevar(glue(_,V), N, N) --> [V].
|
|||||||
available space is distributed.
|
available space is distributed.
|
||||||
|
|
||||||
newline is used if ~n occurs in a format string.
|
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.
|
consume whitespace in the sense of format strings.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user