Search code examples
prologsicstus-prologclpfd

Prolog: Random Labeling


I have a program written in Sicstus Prolog using constraints. My goal is to use labeling/2 and some other method to obtain a random instantiation of my variables.

Example:

X #> 2, Y #= 2*X, Z #<10

If I use

List = [X,Y,Z],
labeling([], List)

The first result obtained will be X = Y = Z = 0. How do you think is the best way to return a random set of values for X, Y and Z?


Solution

  • I do not know much about the labeling options in recent SICStus versions, but with library(clpfd) of SWI-Prolog, there are the options random_variable(Seed) and random_value(Seed), you can use them for example with labeling([random_variable(10),random_value(10)], List). Maybe you can get the authors of SICStus to integrate similar options?