Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLP(B) correction #858

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/lib/clpb.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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([]) --> [].
Expand Down
2 changes: 1 addition & 1 deletion src/lib/format.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

Expand Down