ENH: Monte Carlo Analysis Enhancements
Everyone loves the fact that RocketPy can be quite easily wrapped to run Monte Carlo simulations to carry on dispersion analysis.
However, this experience quickly becomes hard as the analysis complexity increases. Usually, lack of a good stopping criteria combined with long simulation times are the main issues.
Therefore, the following requirements are specified to improve general Monte Carlo simulations with RocketPy.
Requirements
New features
- [x] Support for multithreading in order to speed up calculations.
- [x] Speed up of each simulation to decrease total Monte Carlo analysis time. (PR #581 )
- [x] Allow users to input custom distribution functions for sampling [See Ref.1] (#803 )
- [ ] implement HybridMotor and LiquidMotor stochastic models (not sure how to do it yet)
Corrections:
- [ ] 1. Create evolution plots to analyze simulation convergence
- [ ] 2. Don't use built-in functions in new methods (words like "object", "getattr" and "type" are reserved)
- [ ] 3. Make lat and lon optional arguments in the
export_ellipses_to_kmlfunction - [ ] 4. Review fixed/variable attributes: prevent
timezone,number_of_grains,nose_kindto be varied - [ ] 5. Refactor the
StochasticFlight.create_objectto avoid unnecessary calls. - [ ] 6. Stop using assert in production code. Use exceptions instead.
- [ ] 7. Refactor and simplify the
StochasticModel.__init__()method - [ ] 8. Move the
_validate_airfoilmethod to a child class
Proposed Milestone
v1.X (This means we will avoid breaking changes as much as possible)
Additional comments
Ref.1 -> There are certain quantities, e.g. wind speed, that the user might have a more accurate distribution (maybe built empirically) that does not fit Numpy's provided distributions. The user could provide a "sampler," i.e. a function that takes an integer sample_size as input and outputs that amount of samples according to his distribution.)
For future reference:
- https://realpython.com/intro-to-python-threading/#conclusion-threading-in-python
- https://stackoverflow.com/questions/5442910/how-to-use-multiprocessing-pool-map-with-multiple-arguments