CLPFD questions: randomized labeling?

89 views
Skip to first unread message

Lukas Degener

unread,
May 26, 2014, 5:05:01 AM5/26/14
to swi-p...@googlegroups.com
Hi list,

I am trying to use the CLP(FD) library to model valid configurations of
ships in the classic Battleship game
(http://en.wikipedia.org/wiki/Battleship_%28game%29).

I would like to iterate over all possible configurations and create a
histogram function that tells me for each field in the board the number
of valid configurations that involve this particular field.
This may not be a particularly brilliant idea; it's just the first thing
that came to my mind ;-)

My problem is this: the number of possible configurations seems to be
huge, so iterating all of them might not be feasible. (I tried counting
them using aggregate/3 but I aborted after a couple of minutes.)

Now I am wondering: is there a way to somehow tell the labeling
algorithm to pick solutions in random order? This would help, because
then I could build an arbitrarily precise approximation based on a
random sample of solutions.

Or is there maybe some way that I can efficiently skip over the first N
solutions? The idea here would be that I could implement the random
sampling myself, at least if I can somehow find out the total number of
solutions.

Kind Regards,
--lu

Markus Triska

unread,
May 26, 2014, 4:08:32 PM5/26/14
to swi-p...@googlegroups.com

Hi Lukas,


On Monday, May 26, 2014 11:05:01 AM UTC+2, Lukas Degener wrote:
 
Now I am wondering: is there a way to somehow tell the labeling
algorithm to pick solutions in random order? This would help, because
then I could build an arbitrarily precise approximation based on a
random sample of solutions.

You can use the undocumented labeling options random_value(Seed) and random_variable(Seed), where you can specify different Seeds (integers) for sampling. For the total number of solutions, calculating an upper bound may be a useful approximation. See fd_dom/2.

I hope this helps. Please keep me posted.

All the best,
Markus
 
Reply all
Reply to author
Forward
0 new messages