RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Monte Carlo Analysis Enhancements

Open giovaniceotto opened this issue 2 years ago • 1 comments

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] 1. Support for multithreading in order to speed up calculations.
  • [ ] 2. Support for confidence interval estimation using bootstrapping.
  • [ ] 3. Have a convergence criteria based on maximum confidence interval rather then number of simulations.
  • [x] 4. Speed up of each simulation to decrease total Monte Carlo analysis time. (PR #581 )
  • [x] 5. Implement the MRS method (issue #162)
  • [x] 6. Allow users to input custom distribution functions for sampling [See Ref.1] (#803 )
  • [ ] 7. implement HybridMotor and LiquidMotor stochastic models (not sure how to do it yet)
  • [ ] 8. Save the outputs in different file formats and file structure: https://github.com/RocketPy-Team/RocketPy/issues/242
  • [ ] 9. Improve the ellipses image generation: automatically downloads satellite images from the internet

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_kml function
  • [ ] 4. Review fixed/variable attributes: prevent timezone, number_of_grains, nose_kind to be varied
  • [ ] 5. Refactor the StochasticFlight.create_object to 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_airfoil method 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.)

giovaniceotto avatar Nov 05 '22 03:11 giovaniceotto

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

Gui-FernandesBR avatar Feb 27 '24 07:02 Gui-FernandesBR