Closed dsclassen closed 10 months ago
If rg_min=35
and rg_max=36
, your step calculation:
const step = Math.round((params.rg_max - params.rg_min) / 5)
would result in a step
value of 0
because (36 - 35) / 5 = 0.2
, and Math.round(0.2)
is 0
. This would lead to an infinite loop because rg
would be initialized to 35
and then you attempt to increment it by 0
in each iteration (rg += step
), which means rg
would never reach rg_max
to exit the loop.
To prevent this, you should ensure that step
is at least 1
to make progress in the loop and avoid an infinite loop. You could modify the step calculation like this:
const step = Math.max(Math.round((params.rg_max - params.rg_min) / 5), 1);
This way, you ensure that step
is at least 1
, allowing the loop to progress and eventually terminate. This adjustment is crucial for handling cases where the difference between rg_max
and rg_min
is too small to be divided into five segments, or in general, to ensure that your loop increments properly.
This is an odd one, and I might not be entirely correct, btu at the moment I think there is a bug in the code that determines how many
dynamics_rg##.inp
files to make based on the range ofrg_max
-rg_min
.Here is the logger output from a couple of failed runs:
and