Gillee

232 Reputation

8 Badges

7 years, 159 days

MaplePrimes Activity


These are questions asked by Gillee

Hi,

I was hoping to run two procs: tgf3 and tgf4 in parallel using Grid, Run and get a faster execution time. As I understood the description of Grid Run, the first call to Grid Run will run in the background and before it is finished the second call Grid Run will start. I do not believe I have that situation in my script. I am not understanding Grid Run. How can this problem be fixed? Here is just a portion of the script using Grid Run:

Use Grid Run 0 for tgf3 and 1 for tgf4. Determine the real time and compare times. The Grid Runs do not appear to run in parallel.

rgt := time[real]();
Grid:-Run(0, `~`[tgf3@op](convert(L, listlist)), 'assignto' = ans3roots);
Grid:-Run(1, `~`[tgf4@op](convert(L, listlist)), 'assignto' = ans4roots);
ans3roots;
ans4roots;

GridRunTime := time[real]() - rgt;
                     GridRunTime := 44.074

Here is my script:

Grid_Run_2.mw

 

Thank you for your help.

Hi,

I was able to get Procedure 2 to work using a for - do loop. I was wondering if it is possible to speed up the calculation by using map to find the number of roots? I do not fully understand map and passing data.


tgf := proc(a, b, c, d, t, m, n)

          local X;

          X := [solve(abs(a*x + b) + abs(c*x + d) - t*x^2 + m*x - n = 0)]; 

          return nops(X);

end proc;

res := CodeTools:-Usage(map(tgf, L));
Error, (in CodeTools:-Usage) invalid input: tgf uses a 2nd argument, b, which is missing

The L Array is tripping me up, here is a partial display of the array:

Array(1..262, 1..7, [[5,2,3,9,1,1,1],[5,2,3,9,2,1,1],[5,4,3,7,1,1,1],[5,4,3,7,2,1,1],[5,5,3,6,1,1,1],[5,5,3,6,2,1,1],[5,5,4,8,1,1,2],[5,5,4,8,2,1,2], ... ,[10,10,5,10,2,2,2]], datatype = integer[4]).

I made L Array into a list of list, R. Somewhat works.

Here is the script:

Roots_with_map.mw 

Thanks for any help.

I was using the DirectSearch:-GlobalSearch function on a LaguerrelL for values of 4 and 5. At a value of 4 I get a solution, but at 5 I get an error message that the Kernel connection is lost. I ran this script on two different PCs using Maple 2019 and 2020 with WIN 10 and get the same results. Why does this happen?

 

Here is my worksheet. Thanks for looking.


mysearch2.mw


 

Hello,

I have noticed a small decrease in real time running 4 cpus versus 1 cpu. I am not sure if implemented the multi-threads  feature correctly or efficiently. Could you please show me some alternative coding methods with even more improvements? Thanks in advance.  

 

# Generative Model

n_trials := 16:
n_sample := 1:

subscribers := Vector[row](n_draw):
gen_model := proc(ib,ie)
        global n_trials, n_sample, prior_rate;
        local i, Y;
        for i from ib to ie do
          Y := RandomVariable(Binomial(n_trials, prior_rate(i)));
          subscribers(i) := apply(Sample(Y, n_sample), 1):
        end do:
        return subscribers:
end proc:

# Multi-threads, use 4 cpus
gm1 := Create(gen_model(1, n_draw/4), out1):
gm2 := Create(gen_model(n_draw/4 + 1, n_draw/2), out2):
gm3 := Create(gen_model(n_draw/2 + 1, 3*n_draw/4), out3):
gm4 := Create(gen_model(3*n_draw/4 + 1, n_draw), out4):


Usage(Wait(gm1, gm2, gm3, gm4));
memory used=1.97GiB, alloc change=0.52GiB, cpu time=83.56s, real time=45.52s, gc time=6.20s

 

ApproxBayesComp_Threads_2.mw

ApproxBayesComp_for_loop.mw

The observed data were 6 out 16 people signed up. Priors were defined by a uniform distribution. A Generative Model utilized a binomial distribution. A distribution of subscribers were generated, see plot below. By filtering the subscribers distribution for the value is equal 6, the posterior distribution was obtained. Why is the frequency the highest for subscribers = 16? Where did I go wrong in coding this problem?

1 2 3 4 5 Page 3 of 5