Skip to content

Commit 809ddc0

Browse files
committed
Better quantization, softer moving average
1 parent d2c45ae commit 809ddc0

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/nom/nom.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def initialize
3434
end
3535

3636
@weights.interpolate_gaps!
37-
@weights.precompute_moving_average!(0.1, 0.1, goal, rate)
37+
@weights.precompute_moving_average!(0.05, 0.05, goal, rate)
3838
@weights.predict_weights!(rate, goal, 30)
39-
@weights.precompute_moving_average!(0.1, 0.1, goal, rate)
39+
@weights.precompute_moving_average!(0.05, 0.05, goal, rate)
4040

4141
precompute_inputs_at
4242
precompute_base_rate_at
@@ -349,17 +349,16 @@ def separator
349349
def log_since start
350350
remaining = 0
351351
start.upto(Date.today) do |date|
352-
remaining += allowed_kcal(date)
353352
puts
354353
puts "#{format_date(date)}: (#{quantize(allowed_kcal(date))})"
355354
puts
356-
remaining = allowed_kcal(date)
355+
remaining = quantize(allowed_kcal(date))
357356
inputs_at(date).each do |i|
358357
entry(quantize(i.kcal), i.description)
359-
remaining -= i.kcal
358+
remaining -= quantize(i.kcal)
360359
end
361360
separator
362-
entry(quantize(remaining), "remaining (#{(100-100.0*quantize(remaining)/quantize(allowed_kcal(date))).round}% used)")
361+
entry(remaining, "remaining (#{(100-100.0*remaining/quantize(allowed_kcal(date))).round}% used)")
363362
end
364363
if kcal_balance > 0 and @config.has("balance_start")
365364
cost = if @config.has("balance_factor")

lib/nom/weight_database.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def interpolate_gaps!
2727
end
2828

2929
def precompute_moving_average!(alpha, beta, goal, rate)
30-
trend = dampened_rate(@weights[first], goal, rate)/7.0
30+
trend = 0
3131

3232
@moving_averages[first] = at(first)
3333
(first+1).upto(last).each do |d|

0 commit comments

Comments
 (0)