[ library(tentative) | Reference Manual | Alphabetic Index ]

vs_random_violated(+VS, -X)

Retrieve a random violated variable from a varset
VS
A varset
X
Tentative variable (output)

Description

Retrieve a variable from a varset whose violation count is nonzero. If there are more than one, a random candidate is returned.

Modes and Determinism

Fail Conditions

The varset does not contain a violated variable

Examples

    ?- Vars=[A,B,C], tent_set(Vars, [a,b,c]), vs_create(Vars, VS),
       var_inc_violations(A, 2),
       var_inc_violations(C, 1),
       vs_random_violated(VS, Var).
    Vars = [Var{a -> 2}, B{b -> 0}, C{c -> 1}]
    VS = ...
    Var = Var{a -> 2}	% A or C, the result is random!
    Yes (0.00s cpu)
    

See Also

vs_all_violated / 2, vs_violated / 2, vs_random_violated_index / 2