Question: More efficient way? (quicker, less memory used, good practise of programming?)

Hi all,

##################################################################

restart:

K:=50;C:=20;

st:=time():

    for j from 2 to K do
        for c to C do
            solve({log(cat(p,j,'C',c)/(1-cat(p,j,'C',c)))=mu+cat(tau,j)+cat(eta,c)+cat(mix,j,c)},cat(p,j,'C',c));
            assign(%);
        end do;
    end do;
    
time()-st;

ppar:=[cat(p,2..K,'C',19)]:
# ppar:
# cat(p,'C',1..20);
# seq([cat(p,2..K,'C',m)],m=1..20);

cat(p,'C',1..20):=seq([cat(p,2..K,'C',m)],m=1..20):
pC1;pC2;pC12;pC20;
##################################################################

 

The time it took to run (about 9 or 10 sec) on my machine is more or less OK. But it seems that about 200MB is used.

I wonder is there a way to 'improve' this coding? Quicker and less memory used?

 

Basically, the sequence of pC1,...,pC20 in the toy example is what i wanted.

 

Also, the CPU does not seem to be 'fully' used. I have a quard core processor, I wonder if Maple has some sort of parrallel computing?

Please Wait...