BreakingBytes / simkit

Model Simulation Framework
http://breakingbytes.github.io/simkit/
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Easy repeated calculations #75

Open mikofski opened 8 years ago

mikofski commented 8 years ago

In order to take advantage of parallel computing, implement methods to easily handle repeat or loop calculation.

For example, multi layout dressings can be done in parallel.

mikofski commented 7 years ago

One idea, create a MapCalculator that calls map() on formula with arrays as input args.

mikofski commented 7 years ago

Along the same lines as the MapCalculator - I've implemented a LazyLoopCalculator that just loops over the calculations and then reassigns the output for each return. Probably using map() somehow would have been better, but since the calculators don't return anything, they take the output registry as an argument and change it in place, that might make it difficult to use map().

The problem with the lazy-loop or map calculators as @anomam pointed out in #99 is that they don't leverage concurrency because they aren't exposed as separate calculations in the DAG. Therefore another idea, and it doesn't necessarily need a super calculation as #99 proposes, would be to make a ParameterizedCalculation (or RepeatCalculation maybe to avoid confusion with Carousel "parameters"?) in which the arguments repeated in the calculation are specified as repeat_args just like in the lazy-loop calculator, but instead of as calculator arguments, they would be calculation parameters at the class level. Then in the simulation when the DAG is made, the RepeatCalculation gets split into separate independent calculations that could be executed concurrently.

The problem with this calculation concept is that there isn't currently a stub in the simulation that can do this. This would require either a new simulation layer, or a place in the simulation before the dag where layers can execute arbitrary methods on the model or registries.