Group Abstract Group Abstract

Message Boards Message Boards

Why does the memory used keep going up and no output is given?

Posted 1 year ago

This actually eventually crashed my hard drive, after memory exceeded several Gigabytes. I wonder if it can be improved?

POSTED BY: Iuval Clejan
15 Replies
Posted 1 year ago

I ran with Memory constrain of 300 GBytes and still it was not enough, even without 0 for the smallest eigenvalue

POSTED BY: Updating Name

This should be a more concise way of setting up the problem.

mat = Table[m[i, j], {i, 1, 4}, {j, 1, 4}];
{eigs, vecs} = Eigensystem[mat];
c1 = Thread[vecs[[4, All]] >= 0];
c2 = Flatten[{eigs[[4]] == 0, Thread[Most[eigs] <= 0]}];
c3 = Thread[Flatten[mat] >= 0];
vars = Flatten[mat];
constraints = Join[c1, c2, c3]

So if I understand correctly you are seeking a matrix with all nonnegative entries such that three eigenvalues are nonpositive, one is zero, and a normalization of sorts is imposed wherein all fourth components of eigenvectors are nonnegative. (Or something got transposed and the intent was that the null vector have all nonnegative components). Assuming I have this much correct, the normalization can be dropped because it can be enforced after the fact, multiplying eigenvectors by -1 where needed. So I redo the constraints like so.

constraints = Join[(*c1,*)c2, c3];

This causes FindInstance to go a much faster route it seems. It finds the "obvious" solution.

Timing[inst = FindInstance[constraints, vars]]

(* Out[62]= {0.00738, {{m[1, 1] -> 0, m[1, 2] -> 0, m[1, 3] -> 0, 
   m[1, 4] -> 0, m[2, 1] -> 0, m[2, 2] -> 0, m[2, 3] -> 0, 
   m[2, 4] -> 0, m[3, 1] -> 0, m[3, 2] -> 0, m[3, 3] -> 0, 
   m[3, 4] -> 0, m[4, 1] -> 0, m[4, 2] -> 0, m[4, 3] -> 0, 
   m[4, 4] -> 0}}} *)

Requesting more solutions will hang it though.

Here is a different formulation. It might not perform any better but it does remove the Root objects from consideration, by setting up explicit vectors for the eigenvectors.

mat = Array[m, {4, 4}];
eigs = Array[e, 4];
vecs = Array[v, {4, 4}];
tvecs = Transpose[vecs];
eqns = Table[
   Thread[mat . vecs[[j]] == eigs[[j]]*tvecs[[j]]], {j, 4}];
c2 = Flatten[{eigs[[4]] == 0, Thread[Most[eigs] <= 0]}];
c3 = Thread[Flatten[mat] >= 0];
vars = Flatten[{mat, eigs, vecs}];
constraints = Flatten[{eqns, c2, c3}];

Again it is fast to find the trivial solution. I do not know if FindInstance or Reduce will go beyond that though.

POSTED BY: Daniel Lichtblau
Posted 1 year ago

No, you misunderstood, confusing the eigenvector matrix with its transpose. What I need is the fourth eigenvector (corresponding to the 0 eigenvalue) to be all positive components (the last component of any eigenvector seems to be positive by convention in Mathematica, so I only impose this on the first 3 components of the 4th eigenvector). Perhaps I should not set the 4th eigenvalue to 0, but to a small real number, so that this makes more sense. So c1 is not redundant.

POSTED BY: Iuval Clejan

I was wondering about that. In this case any nonzero component of the null eigenvector will force the corresponding column of the matrix to vanish (since you have a sum of products of nonnegatives equated to zero). Maybe that will help to simplify things, at least to a 3x3 case.

POSTED BY: Daniel Lichtblau
Posted 1 year ago

see my edit. Am I right about the last component of any eigenvector always being positive? Or maybe only the last component of the eigenvector associated with the smallest absolute eigenvalue?

Trying a slightly positive eigenvalue now for the 4th eigenvalue.

POSTED BY: Iuval Clejan
Posted 1 year ago

It worked (correcting by tevec->vec)! Thanks Now for the real problem of getting 2 eigenvalues to be near 0 and their corresponding eigenvectors to be non-negative.

mat = Array[m, {4, 4}];
eigs = Array[e, 4];
vecs = Array[v, {4, 4}];
c1 = Table[v[4, j] > 0, {j, 3}];
eqns = Table[Thread[mat . vecs[[j]] == eigs[[j]]*vecs[[j]]], {j, 4}];
c2 = Flatten[{eigs[[4]] == 0.01, Thread[Most[eigs] <= 0]}];
c3 = Thread[Flatten[mat] >= 0];
vars = Flatten[{mat, eigs, vecs}];
constraints = Flatten[{eqns, c1, c2, c3}];
Timing[inst = FindInstance[constraints, vars]]
POSTED BY: Iuval Clejan
Posted 1 year ago

I take it back. It didn't work. Another constraint is linear independence of all the eigenvectors...

POSTED BY: Iuval Clejan
Posted 1 year ago

Thanks, I am trying it, memory still going up, but only up to 8 Gig. How do I know that all 8 of my cores are being used? Do I need to tell Mathematica somewhere to do this, or is it automatic?

POSTED BY: Iuval Clejan
Posted 1 year ago

It stabilized around 15Gig in memory, but after an hour it was using 100% CPU and no output so I killed it.

POSTED BY: Iuval Clejan
Posted 1 year ago

I reopened the file I aborted and this was displaying, with changing numbers (what does it mean?):

AnimatorBox[Dynamic[Progress`ProgressDump`clock$$], {2., DirectedInfinity[1], 1.},
AnimationRate->1,
AnimationRunTime->123.19397640228271`,
AnimationTimeIndex->123.19397640228271`,
AppearanceElements->None,
ImageSize->{1, 1}]
POSTED BY: Iuval Clejan
Posted 1 year ago

Tried it again and let it run for longer. This time it seems to have finished, but no output at all. Not even an empty list.

POSTED BY: Iuval Clejan
Posted 1 year ago

I noticed that it had six kernels running, but only one was using most of the CPU and most of the memory.

POSTED BY: Iuval Clejan
Posted 1 year ago

I see you upped your core and memory requirement. I can certainly increase memory up to 32Gigs, but I only have 8 cores. I will try setting the "0" eigenvalue to a small real number and see if it works.

POSTED BY: Iuval Clejan
Posted 1 year ago

Is it a typo: 30^10? Isn't 30 Gigabytes 30^9?

POSTED BY: Iuval Clejan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard