Merge pull request #2689 from triska/weighted_maybe
introduce and use weighted_maybe/2
This commit is contained in:
@@ -1550,11 +1550,15 @@ random_bindings(VNum, Node) -->
|
|||||||
{ node_var_low_high(Node, Var, Low, High),
|
{ node_var_low_high(Node, Var, Low, High),
|
||||||
bdd_count(Node, VNum, Total),
|
bdd_count(Node, VNum, Total),
|
||||||
bdd_count(Low, VNum, LCount) },
|
bdd_count(Low, VNum, LCount) },
|
||||||
( { maybe(LCount, Total) } ->
|
( { weighted_maybe(LCount, Total) } ->
|
||||||
[Var=0], random_bindings(VNum, Low)
|
[Var=0], random_bindings(VNum, Low)
|
||||||
; [Var=1], random_bindings(VNum, High)
|
; [Var=1], random_bindings(VNum, High)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
weighted_maybe(K, N) :-
|
||||||
|
random_integer(0, N, X),
|
||||||
|
X < K.
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Find solutions with maximum weight.
|
Find solutions with maximum weight.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|||||||
Reference in New Issue
Block a user