Jump to content

need an algrithm

Featured Replies

Need an algorithm to approximate the traveling time for a trip. For a shorter trip, under 120 miles time is based on miles, more than 120 miles it is adjusted by 10%

Need an algorithm to approximate the traveling time for a trip. For a shorter trip, under 120 miles time is based on miles, more than 120 miles it is adjusted by 10%

 

define "adjusted by 10%", is it that 10% is an error ?

safety margin. the longer a journey, the more likely you will encounter delays

the algorithm is simple then,

 

IF [math]DISTANCE < 120[/math] THEN [math]TIME = \frac{DISTANCE}{SPEED}[/math]

 

ELSE [math]TIME = [ \frac{DISTANCE}{SPEED} - \epsilon \; , \; \frac{DISTANCE}{SPEED} + \epsilon ][/math] END

 

.. where [math]\epsilon \; = \; 0.1 \times \frac{DISTANCE}{SPEED}[/math],

Edited by khaled

  • 4 weeks later...

Just curious here. Why only include the 10% safety margin for trips longer than 2 hours? The margin for error should apply for any distance.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.