TransWikia.com

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[Length@dataToRefine != 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

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP