[eclipse-clp-users] Out of memory in constraint setup

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Mon, 08 Oct 2012 00:02:31 +0200
On 07/10/2012 15:28, Anshu Shankar Prasad wrote:
> I am getting a error like this
>
> *** Overflow of the global/trail stack in spite of garbage collection!
> You can use the "-g kBytes" (GLOBALSIZE) option to have a larger stack.
> Peak sizes were: global stack 3071552 kbytes, trail stack 96064 kbytes.
 >
> I have changed the value of Global/trail stack size to 3500 Megabytes and Local/Control Stack size
> to 2000 megabytes under TkECLiPsE  preference editor menu.
> The program compiled successfully but while running produces above errror.
> Please help me in this.It is very urgent reply soon.
> Program is attached with the mail.
>

Please do not post large programs to the mailing list -- your posting was
blocked because of the large attachment.  The mailing list is for topics
of general interest.

If you had used the tracer, you would have found that the problem occurs
in line 68, where you post your first big constraint:

   N_LAMHAT_1 #= (1-X1)*N_L1 + X1*
     (
	 (N_L2+N_L4+N_L8+N_L10+N_L20)*(1-X2)*(1-X4)*(1-X8)*(1-X10)*(1-X20)
	+(N_L2+N_L3+N_L20)*(1-X2)*(1-X3)*(1-X20)
	+(N_L2+N_L4+N_L6+N_L7+N_L10+N_L16+N_L18+N_L20+N_L23)*(1-X2)*(1-X4)*...

         + <another 80 similar multiplicative subterms>
     )

This is a big nonlinear arithmetic expression.  Eclipse tries to decompose that
into linear and nonlinear components.  Apparently, we are not doing a very good
job at this, because the size of the decomposition seems to explode and cause
your memory overflow.

You can help by doing some decomposition manually, e.g. by factoring out the
large sum:

   N_LAMHAT_1 #= (1-X1)*N_L1 + X1*AuxVar,
   AuxVar #=
     (
	 (N_L2+N_L4+N_L8+N_L10+N_L20)*(1-X2)*(1-X4)*(1-X8)*(1-X10)*(1-X20)
	+(N_L2+N_L3+N_L20)*(1-X2)*(1-X3)*(1-X20)
	+(N_L2+N_L4+N_L6+N_L7+N_L10+N_L16+N_L18+N_L20+N_L23)*(1-X2)*(1-X4)*...

         + <another 80 similar multiplicative subterms>
     )

With these changes, the constraint setup finishes quickly, and search begins.


However, it is still unlikely that this kind of model will solve efficiently.
Your Xi are 0..1 variables, and you are using multiplication to implement
a logical AND operation.  This is not efficient with a solver like lib(ic).
I would recommend that you replace your subexpressions like

   (1-X4)*(1-X8)*(1-X10)*(1-X20)

with

   (sum([X4,X8,X10,X20]) #= 0)

Both are 1 iff all Xi are 0, but the latter is linear and much more efficient.


Good luck,
-- Joachim
Received on Sun Oct 07 2012 - 22:02:42 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST