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

vs_random_violated_index(+VS, -I)

Retrieve a random violated variable index from a varset
VS
A varset
I
An integer variable (output)

Description

Retrieve a variable index 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_index(VS, I).
    Vars = [A{a -> 2}, B{b -> 0}, C{c -> 1}]
    VS = ...
    I = 1		% 1 or 3, the result is random!
    Yes (0.00s cpu)
    

See Also

vs_all_violated_index / 2, vs_violated_index / 2, vs_random_violated / 2