Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4202

NMinimize eats all memory b/c of unnecessary symbolic work

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!newsfeeds.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Daniel Jensen <jensend@iname.com>
Newsgroups comp.soft-sys.math.mathematica
Subject NMinimize eats all memory b/c of unnecessary symbolic work
Date Sun, 7 Aug 2011 10:17:50 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <j1looe$nn8$1@smc.vnet.net> (permalink)
Lines 37
NNTP-Posting-Date 07 Aug 2011 09:19:58 GMT
NNTP-Posting-Host 200e94aa.news.twtelecom.net
X-Trace DXC=PLU<\<<h8]PNEg=@eQK2QZC_A=>8kQj6]=_1NR_H?JP]JC=TVc1<HJQEFiONJ7[GoVG;DUn1jKBWY
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:4202

Show key headers only | View raw


The following code is a fairly naive way to find the least number whose 
square has n divisors (the minimum should be its log and the x_i the 
powers in its prime factorization). If I look at the case n00 and use 
ten variables instead of twenty, this uses somewhere around 600MB of 
memory. With the value of n I'm actually trying to find the answer for, 
I need around 20 variables to be sure of not missing the actual 
solution, and it quickly uses up all available memory and then thrashes 
swap.

n=8*10^6;
a = Table[N[Log[Prime[i]]], {i, 20}];
b = Table[Subscript[x, i], {i, 20}];
cond = Fold[And, Product[2 Subscript[x, i] + 1, {i, 20}] > n,
    Table[Subscript[x, i] >= 0, {i, 20}]] && b \[Element] Integers;
NMinimize[{a.b, cond}, b, MaxIterations -> 1000]

It turns out that the problem isn't related to integer programming etc 
at all (removing the restriction to the integers doesn't help).

My best guess is that the problem is that Mathematica is wasting all 
that memory expanding Product[2 Subscript[x, i] + 1, {i, 20}]. If I 
replace the product with just Product[Subscript[x, i],{i,20}] and change 
the constraints to be >= 1 rather than 0 I get results without a hassle 
and without the kernel using more than 50MB of memory. (Though that 
preserves the inequality constraint and doesn't change the task of 
minimizing the objective function, it does mess up the integrality 
requirement- I get even results, which correspond to half-integers in 
the actual problem.)

Searching the Web, I found one person who had a somewhat similar 
problem; in their case, they had an objective function which was getting 
evaluated symbolically at a huge cost. They were able to remedy it by 
making the function only accept numeric input. I don't seem to be able 
to do that with the constraint.

Any thoughts on how to fix this?

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

NMinimize eats all memory b/c of unnecessary symbolic work Daniel Jensen <jensend@iname.com> - 2011-08-07 10:17 +0000

csiph-web