RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

BUG: Paralle Monte Carlo simulation giving incorrect iterations

Open emtee14 opened this issue 8 months ago • 3 comments

When running the parallel Monte Carlo simulations, there is a printout that shows the current iterations, iteration runtime, and estimated time left. When running in parallel, though, the value goes up and down due to this line https://github.com/RocketPy-Team/RocketPy/blob/4df0b383c2886c7804b6848bbe5b9cbe612b2cd5/rocketpy/simulation/monte_carlo.py#L431

This means that the message is printed with the same index as the last completed iteration, so when an earlier iteration takes longer, it updates it with a lower value.

I propose to fix this by having a counter that will keep track and just increment each time. This counter can be incremented when the output is written to a file, and can be thread-safe since it will only be accessed when the mutex is acquired. Also changing the printout of current iteration to iterations completed or something of that nature.

Screenshots

https://github.com/user-attachments/assets/984e895b-01e0-453e-a127-061a7ab269f0

emtee14 avatar Apr 18 '25 21:04 emtee14

I propose to fix this by having a counter that will keep track and just increment each time. This counter can be incremented when the output is written to a file, and can be thread-safe since it will only be accessed when the mutex is acquired. Also changing the printout of current iteration to iterations completed or something of that nature.

Thanks for reporting this bug, @emtee14 , it seems like you have a great idea of what should be done. Are you able to implement and test it on Python? Could you kindly submit a Pull Request so we can evaluate your solution please?

Thanks for helping!

Gui-FernandesBR avatar Apr 24 '25 21:04 Gui-FernandesBR

Yeah I'm happy to do that

emtee14 avatar Apr 24 '25 21:04 emtee14

Yeah I'm happy to do that

Great! @emtee14 I have assigned the issue to you then. Let us know in case you need any help to proceed.

Gui-FernandesBR avatar May 01 '25 17:05 Gui-FernandesBR

Now we need to check if the problem was really solved!

Gui-FernandesBR avatar Nov 27 '25 16:11 Gui-FernandesBR