Skip to content

Commit

Permalink
Merge pull request #2689 from triska/weighted_maybe
Browse files Browse the repository at this point in the history
introduce and use weighted_maybe/2
  • Loading branch information
mthom authored Dec 14, 2024
2 parents 5f035ec + abe1f37 commit a9a7777
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/clpb.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1550,11 +1550,15 @@
{ node_var_low_high(Node, Var, Low, High),
bdd_count(Node, VNum, Total),
bdd_count(Low, VNum, LCount) },
( { maybe(LCount, Total) } ->
( { weighted_maybe(LCount, Total) } ->
[Var=0], random_bindings(VNum, Low)
; [Var=1], random_bindings(VNum, High)
).

weighted_maybe(K, N) :-
random_integer(0, N, X),
X < K.

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Find solutions with maximum weight.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Expand Down

0 comments on commit a9a7777

Please sign in to comment.