AnswerBun.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[[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

Add your own answers!

Related Questions

Simplification of ArcTan

3  Asked on October 2, 2021 by billy-kalfus

     

Padding in an inset object

1  Asked on October 2, 2021

   

How can I plot these figures?

2  Asked on October 1, 2021

   

Variable order in InterpolatingFunction

0  Asked on September 30, 2021 by logosintegralis

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir