Tag Info

Hot answers tagged

7

With eqn[{k_, r_, H0_, P0_}] := {H'[t] == r (1 - H[t]/k) - d H[t] P[t], P'[t] == -s P[t] + e H[t] P[t], H[0] == H0, P[0] == P0} d = 0.01; s = 0.3; e = 0.02; I would define one simulation as sim := Module[ {k = RandomVariate[NormalDistribution[150, 20]], r = RandomVariate[NormalDistribution[0.4, 0.003]], H0 = RandomVariate[UniformDistribution[{50, ...


6

You can use ParallelTable and generate the SparseArray form the table. f[i_, j_] := i + j; imax = 50; AbsoluteTiming[ M = SparseArray[{}, {imax, imax}]; SetSharedVariable[M]; ParallelDo[If[j < i, M[[i, j]] = f[i, j]], {i, 1, imax}, {j, 1, imax}] ] (*{8.259472, Null}*) AbsoluteTiming[ M2 = SparseArray[Flatten[ParallelTable[{{i, j} -> f[i, j]}, {i, ...


2

The reasons for the change in the behavior of ParallelTable are subtle. The main source of the problem is that in funcB, the argument k_ is not protected with ?NumericQ like this: funcB[t_?NumericQ, k_?NumericQ] := (* a solution *) funcB[t, k] = Exp[NIntegrate[funcA[et, k], {et, tini, t}]] But more on that later. The problem does not appear in the ...


2

As I mentioned in a comment, the code works fine the way it is. Here's a faster way: Clear[f]; f[x_] := x; integral = NDSolveValue[{y'[x] == f[x], y[0] == 0}, y, {x, -1, 1}]; Plot[integral[x], {x, -1, 1}]


1

My final solution After working on the code a little bit more, I've come up with a much better way to tackle the problem that I will leave here for posterity First I define the size of the simulation, create the seed and launch kernels if they aren't already running. (*Define some variables, generate the seed and launch the kernels.*) gridSize = 50; ...


1

As pointed in the comments by @Nasser, Monitor needs a front end, so it should be outside ParallelTable. It also needs a variable that acts as a "counter" and that is shared among all the kernels participating in the calculation, for that you can use SetSharedVariable. Therefore, a solution to your question would be: SetSharedVariable[iter] iter = 0 ...


1

The answer to my question is based on the answer to How to configure parallel remote kernels in Mathematica?. The solution is: Install Cygwin on the B machine to have ssh. For a password-less access we need to copy the public keys of A to the autorized_keys file in B. In A open Mathematica, go to Preferences->Parallel->Remote Kernels and hit Enable ...



Only top voted, non community-wiki answers of a minimum length are eligible