0

I've seen it's possible to label cplfd variables using a random method by adding the following options to labeling/2:

labeling([random_variable(N),random_value(M)],List). 

Where M and N are supposed to be integers, I think. However I am not able to find any information about those options in SWI-Prolog's documentation page. How can they be used?

Carles Araguz
  • 1,157
  • 1
  • 17
  • 37

1 Answers1

0

In the CLP(FD) library there's this:

selection(random_variable(Seed)) :-
        must_be(integer, Seed),
        set_random(seed(Seed)).

% TODO: random_variable and random_value currently both set the seed,
% so exchanging the options can yield different results.
order(random_value(Seed)) :-
        must_be(integer, Seed),
        set_random(seed(Seed)).

select_var(random_variable(_), Vars0, Var, Vars) :-
        length(Vars0, L),
        I is random(L),
        nth0(I, Vars0, Var),
        delete_eq(Vars0, Var, Vars).

So the options would only set the seed for randomly generated numbers, although it is not clear what's the purpose of having different values for random_value(N) and random_variable(M).

Carles Araguz
  • 1,157
  • 1
  • 17
  • 37
  • 1
    Looks much like work in progress. It does make sense to have different random generators for value and variable selection — this would require a more sophisticated interface to random/1. To see this, try getrand(X). – false Jan 09 '14 at 15:21