I have adapted and simplified my code to use the runExternalM2 command, but I have a new problem and the old one still seems to exist in a different form. The main thing now is that the code is taking 20 times longer to run using the runExternalM2 command than it does without it. Also I am still eating up memory, just not as quickly as before. I am just doing test runs right now and haven't really put any debugging in but the loop I am running for my runExternalM2 part is attached below:
compClassList={};
for ii from 1 to n do(
h:=runExternalM2("/home/jpainter/Documents/KoszulStructureFinder_Ver1_0_1.m2",BuildGens3,(a,b,c,r));
if length(compClassList)==0 then(
compClassList=append(compClassList,h#value);)
else(
jj=0;
while jj<length(compClassList) do(
if h#value#1==compClassList#jj#1 then(
jj=length(compClassList);)
else (
if jj==length(compClassList)-1 then(
compClassList=append(compClassList,h#value);)
else(jj=jj+1);););););
I have a sort feature that runs after this but it hasn't started yet. I have left this loop running all night, about 11 hour now and it has only gone through about 150000 reps of the main loop. For more clarification, the BuildGens3 function is a function that I wrote to build a certain type of random monomial ideal and returns the generators of the ideal and its Tor Algebra structure in a list. Every time a new Tor Algebra structure is found the while loop in the code below adds it to the compClassList, I am thinking that while loop is where I am still eating up memory I guess. So the speed problem, comes into focus when I run this code without the runExternalM2 command with 100000 reps it takes less than an hour to complete. Any suggestions on how to speed this up further? I suppose I could do another runExternalM2 in the while loop, but haven't had time to think that one through yet.
Thanks.