Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph editor can fail to warn of akrasia horizon violation #280

Open
3 tasks
dreeves opened this issue Sep 23, 2022 · 1 comment
Open
3 tasks

Graph editor can fail to warn of akrasia horizon violation #280

dreeves opened this issue Sep 23, 2022 · 1 comment

Comments

@dreeves
Copy link
Member

dreeves commented Sep 23, 2022

Desiderata

Preview Give feedback

Via Nicky and RPerce. Widely confirmed.

NICKY: Looks like you were trying to set a break from 9th July to 10th July, on the 3rd. So it's correct that you can't make that change: it's within the akrasia horizon of 7 days.

The bug is that the graph going red and saying "error" doesn't happen when you're on the cusp of the akrasia horizon.

Replicata

  1. Try to set a break on a goal that will kick in 6 days from now (e.g., on Sunday try to set a break for next Sunday). [wait, but Sunday to Sunday is 7 days]
  2. Expect to see the error flagged up on the graph preview (e.g. as would happen if on Sunday you tried to set a break for next Saturday).
  3. Press submit and receive an error.

Working as expected (violating the akrasia horizon):

image

Edge-case where the graph doesn't warn you but the API won't accept it:

image

Cognata

Verbata: akrasia horizon, graph editor, user confusion, baneful bugs,

@dreeves
Copy link
Member Author

dreeves commented Sep 27, 2022

Bee and I discussed this and found the place in the Beebody code (related to roadall in the API) where this needs to be fixed:

today = Date.today
eps = 0.000000001 # floating point epsilon
# diff the roads and return list of days w/in AKH at which the road is easier
t = (0..7).map{|v| today + v}
  .map{|v| {date: v, from: road_front_center_at(from, v, goal.siru),
                     to:   road_front_center_at(to,   v, goal.siru)}}
  .select{|v| goal.yaw==1 ? v[:to] + eps < v[:from] : v[:from] + eps < v[:to]}

t.empty? ? [nil, true] :
  ["Error: graph matrix can't get easier in akrasia horizon"]

It's the above that sometimes happens when it shouldn't.

def road_front_center_at(road,date,siru)
  # has same sketchiness as roadfunc: returns frontmost point on discontinuities
  start = road[0][:end]
  val = road[0][:endv]
  if date >= start
    road[1..-1].each{ |v|
      if (v[:type]=="ratedate" ||
          v[:type]=="valuedate") && v[:end] < date
        val = road_segment_endv(v,start,val,siru)
        start = v[:end]
      else
        val += road_segment_rate(v,start,val,siru) * (date - start)
        break
      end
    }
  end
  val
end

def road_segment_rate(v,start,startv,siru)
  # need to normalize rate we are comparing to daily rate:
  # dailyrate is rate/siru * siday
  v[:type]=="ratedate" || v[:type]=="ratevalue" ?
    (v[:rate]/siru.to_f)*1.day.seconds :
    (v[:endv]-startv)/(v[:end]-start).to_f
end

def road_segment_endv(v,start,startv,siru)
  # need to normalize rate we are comparing to daily rate:
  # dailyrate is rate/siru * siday
  v[:type]=="ratevalue"|| v[:type]=="valuedate" ?
    v[:endv] :
    startv + ((v[:rate]/siru.to_f)*1.day.seconds) * (v[:end]-start)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant