blinry / nom

"Lose weight and hair through stress and poor nutrition"
GNU General Public License v2.0
64 stars 4 forks source link

cap rates to a minimum of 0.1 #8

Open rohieb opened 3 years ago

rohieb commented 3 years ago

With lower rates than 0.1, the algorithm to calculate the allowed kcal values can takes a very long time to run, and the plot also explodes in the y axis. Print a warning in that case, and cap the value to a minimum of 0.1.

blinry commented 3 years ago

As we discussed in-person, this feels like the wrong solution to me. Rates of 0 (and especially, negative rates, for people who want to gain weight) should be supported by the tool, and it should adapt the part which makes future predictions in that case.

What would be a better approach? Capping all future calculations to at most 3 years or something?

rixx commented 1 year ago

Is there a reason for the "allowed kcal" algorithm to explode with low rates? Apart from special-casing 0, it feels like the rate shouldn't influence the bare calculation for kalories, and only the prognosis part would take long?

Adding to the discussed options: Another (or maybe an additional?) version could be to disable future calculation ("you'll hit weight x in y time") with a flag, both for terminal and SVG display. I, for one, tend to ignore the future calculation (because it's unrealistic anyways, and I don't want to see an unrealistic prognosis), and I particularly dislike it in the SVG plot, where I usually just hide the prognosis dots.

Alternatively, you could do basically what this PR does, but add a special case for 0, and also allow negative values, so that 0 < x < 0.1 gets rounded up and -0.1 < x < 0 gets rounded down.

rohieb commented 1 year ago

Yes, I think I talked with @blinry about such a flag already (but sadly I don't remember the outcome of that discussion…)

blinry commented 1 year ago

I think what takes long for rates close to zero is the "prediction" part, which inserts prediction weights for each day until the target weight is reached. This both has an effect for doing the plot, as well as for printing the "you'll reach your goal in xx months".

My favorite solution would be to cap how far into the future the predictions are calculated - maybe not longer than two years or so? And in this case, we could just drop displaying the "you'll reach your goal in xx months" message.

I'd also welcome a flag to hide the future! :D