[eclipse-clp-users] Trail stack overflow

From: <mskala_at_ansuz.sooke.bc.ca>
Date: Mon, 8 Jul 2013 10:26:58 -0500 (CDT)
Please note that I am not asking how to increase the size of the trail stack.

What pattern of use could cause excessive consumption of the trail, not
global, stack?  I have a piece of code that involves nested (for() do ())
loops containing code that is supposed to be deterministic, and it's
causing the trail stack to overflow - even when enlarged to as much as 3
gigabytes.  Global stack consumption is only a couple hundred K.

My understanding is that the trail stack records unifications, in order,
so that they can be undone in reverse order on backtracking.  Stray choice
points inside the loops might cause it to overflow, but then I would
expect the global stack to also become large, and probably overflow first,
and that's not happening.  I'll experiment with adding some cuts and
once() calls but I don't have high hopes for this.

My next guess is that because my loop is computing a cumulative sum using
fromto(), there's always a new unification that will be visible in the
next iteration added to the trail stack on each iteration; as a result,
the many unifications of local variables, which should be removable
because they are no longer visible once the iteration terminates, are
stuck below the non-removable cumulative sum variable, and can't be
removed.  If that's it, is there anything I can do about it?  One
possibility that occurred to me might be to use a non-logical variable to
store my cumulative sum, to keep it off the trail stack and avoid
fromto().  However, I'm updating a bunch of variables from iteration to
iteration using fromto() at the moment, and they won't all be easy to
switch to non-logical variables, so this might slow rather than stopping
the accumulation of trail stack entries, and I'm not sure I want to put
effort into it until I have more evidence that that's even a correct
diagnosis of the problem to begin with.

Any ideas?

Code on request off-list; I'd rather not post it here because it's
for a not-yet-published research application.
-- 
Matthew Skala
mskala_at_ansuz.sooke.bc.ca                 People before principles.
http://ansuz.sooke.bc.ca/
Received on Mon Jul 08 2013 - 15:27:06 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 08 2013 - 18:13:40 CEST