# Improving the performance of ParallelTable[]

Mathematica Asked by Jak on December 19, 2020

# Questions

There are two things that I want to ask:

1. What is the relation between computation time of the ParallelTable[] and the length of the table?

This is meant to be a rough estimate of the time that will take my code to run, so I don’t mind approximations as long as they don’t differ much from reality. So far, I’m using a linear relation, which I’m not being very fortunate with.

1. Is there a way to further optimise the performance of the ParallelTable[]? Each entry is an array, where the first position is the output of some function (IMLEOArcA[...] in my case), and the remaining positions are the parameters for said function (2, tOutbound, tInbound, tStay, Isp, ToverWPropulsion, thrust, 3, tDepartureEarth, IspCargoI, ToverWPropulsionCargoI, thrustCargoI, IspCargoII, ToverWPropulsionCargoII, thrustCargoII in my case).

# Notes

1. I expect the performance to vary across machines. However, I also expect it to maintain roughly the same computation time vs length relation, with differences being confined to a certain constant. For instance, assuming a linear relation (I don’t know if this is true, and probably won’t be), I expected the slope to be constant across machines, with the actual line being defined after knowing one of the points.

2. The code below is meant as a guide to the question. It won’t run on its own, since there are definitions missing. I have included them, but they’re lengthy and ultimate need the import of .m files, which I don’t know how could I include them here. Since the code wouldn’t run without said .m files, and since the extra definitions didn’t bring anything useful to the problem, I decided against including them. Just think of IMLEOArcA[...] as a blackbox function of several parameters. In your answers, feel free to replace it with another function.

3. The function findIMLEO[...] has a bit more to it than the ParallelTable[], but ultimately I’m interested in optimising the ParallelTable[] usage.

# Code

findIMLEO[Isp_, ToverWPropulsion_, tStay_, tOutboundRange_, tInboundRange_, thrustRange_, tDepartureEarthRange_, architecture_, dataToRefine_] :=
Module[{IspCargoI, ToverWPropulsionCargoI, IspCargoII, ToverWPropulsionCargoII, thrustCargoI, thrustCargoII, pTable, refinement = False, dataToRefineParameters},
If[[email protected] != 0, dataToRefineParameters = dataToRefine[[All, 2 ;;]]; refinement = True];
IspCargoI = Isp;
IspCargoII = Isp;
ToverWPropulsionCargoI = ToverWPropulsion;
ToverWPropulsionCargoII = ToverWPropulsion;
pTable = ParallelTable[thrustCargoI = thrust;
thrustCargoII = thrust;
{IMLEOArcA[2, tOutbound, tInbound, tStay, Isp, ToverWPropulsion,
thrust, 3, tDepartureEarth, IspCargoI,
ToverWPropulsionCargoI, thrustCargoI, IspCargoII,
ToverWPropulsionCargoII, thrustCargoII, False],
2, tOutbound, tInbound, tStay, Isp, ToverWPropulsion, thrust, 3, tDepartureEarth, IspCargoI, ToverWPropulsionCargoI, thrustCargoI, IspCargoII, ToverWPropulsionCargoII, thrustCargoII},
{tOutbound, tOutboundRange},
{tInbound, tInboundRange},
{thrust, thrustRange},
{tDepartureEarth, tDepartureEarthRange}
];
pTable = Flatten[pTable, 3];
If[refinement == True, pTable = Join[dataToRefine, pTable]];
pTable = DeleteDuplicates[pTable]
] // AbsoluteTiming


## Related Questions

### Why does Simplify work diferently for (a+b)/e versus (a+b+c)/e?

1  Asked on October 2, 2021 by user74005

### Simplification of ArcTan

3  Asked on October 2, 2021 by billy-kalfus

### Large difference between algebraic and numerical eigenvector system

0  Asked on October 2, 2021

### Padding in an inset object

1  Asked on October 2, 2021

### How to find the eigenvalues of the abstract matrix satisfying the condition

2  Asked on October 1, 2021

### How can I plot these figures?

2  Asked on October 1, 2021

### Finding plane equations of planes in a convex hull

2  Asked on October 1, 2021 by samvid-mistry

### How can I plot the direction field for a differential equation?

7  Asked on October 1, 2021 by matt-groff

### Convert mathematica math expression form to python math expression?

3  Asked on September 30, 2021 by ka-wa-yip

### Discrepancy between the results of NIntegrate with different methods and options

0  Asked on September 30, 2021

### Variable order in InterpolatingFunction

0  Asked on September 30, 2021 by logosintegralis

### QPochhammer function simplification?

1  Asked on September 30, 2021

### Mathematica 12 HighlightImage doubles image dimensions ! Bug?

1  Asked on September 30, 2021

### How can I remove vanishing derivatives of hypergeometric functions?

1  Asked on September 29, 2021

### Python module error using Externalsession

1  Asked on September 29, 2021

### How can I combine NIntegrate with NDSolve?

1  Asked on September 29, 2021 by mksjd

### How to find the expectation $mathbb{E}left[ a mathcal{Q} left( sqrt{b } gamma right) right]$?

1  Asked on September 29, 2021

### Create a set of prime factor numbers given a set of tuples

0  Asked on September 29, 2021

### How to add a front-end to the free Wolfram Engine?

6  Asked on September 29, 2021 by alexey-golyshev

### How to evaluate a multidimensional NIntegral in a range where certain conditions must be satisfied by the variables

1  Asked on September 29, 2021