Research Article

Usage Patterns of Electric Bicycles: An Analysis of the WeBike Project

Algorithm 1

Activity detection.
activity NULL
function DETECT_ACTIVITY(sample)
if activity = NULL then
  if BELONGS_TO_ACTIVITY(sample) then          check if an activity has started
   activity INITIALIZE_ACTIVITY
   activity.ACCUMULATE(sample)
   activity.SET_START(sample)                    set start timestamp
  end if
else if ¬ activity.HAS_ENDED(sample) then     activity is ongoing: did current activity stop?
  if BELONGS_TO_ACTIVITY(sample) then   no, check if sample satisfies activity requirements
   activity.ACCUMULATE(sample)
   activity.SET_END(sample)              yes, set as preliminary end timestamp
  end if
else                                  yes, check validity
  if activity.CHECK_IS_VALID then
   WRITE_TO_DATABASE(activity)
  end if
   activity NULL
end if
end function