Professional Documents
Culture Documents
Soda00 Ps
Soda00 Ps
only statisti
ally. whi
h fall on the route of bus 1 . Suppose 1 runs
B B
plans: (i) Take 1 , (ii) Take 2 and then 3 , and and are
onse
utive bus stops on one or more routes,
t
fastest plan to go from point X to point Y is equiva- where is where the bus stops while is the next
s t
lent in our model to nding the least
ost tree from stop on its route. Let 1 2 be a sequen
e of
s ; s ; : : : ; sk
the set of trees orresponding to all the plans for trav- onse utive bus stops on a route . The time to go b
elling between X and Y. Our se
ond
ontribution is a from 1 to having already got into bus is denoted
s sk b
polynomial time algorithm for nding the least
ost as ( 1 ) and is of
ourse:
R b s ; sk
( )= ( )
stations it gives optimal plans se
onds after the user
R b s1 ; sk R si ; si+1
i=1
types in the starting and ending points.
We note that ( 1 ) need not equal 0 ( 1 ) if
R b s ; sk Rb s ; sk
We begin by des ribing our model for bus routes in the We model travel plans as trees. Ea h node u
and travel plans in Se tion 2. A detailed ritique tree has a label ( ) whi h must be a bus S u
of the model and possible extensions appears in stop. Ea
h edge ( ) has a label ( ) whi
h is
u; v B u; v
is:
v ; v ; : : : ; vk
1 2 any bus) only from the destination stop itself. We
des
ribe below the pro
ess of generating optimal
Wait at stop ( ) for buses height plans given optimal height 1 plans.
S u h h
( 1) ( 2)
B u; v ; B u; v ( ). If bus
; : : : ; B u; vk
We rst need the notion of a bus restri
ted plan.
( ) is the rst to arrive, then take it
B u; vi
A bus restri
ted plan is also a tree similar to an
to stop ( ). Then exe
ute the a
tion
S vi
ordinary plan, ex
ept the root has only one outgoing
indi
ated by .
r
vi
edge going to some node . There is also a dieren
e u
It should be
lear that the expe
ted time taken by Let ( ) denote the expe
ted time to rea
h
a plan
an be evaluated re
ursively, sin
e subtrees of the destination from stop using an optimal height
T s; h
a given plan tree are themselves plan trees. Let ( ) plan. Let ( ) denote the expe
ted time to rea
h
s
T u
denote the expe
ted time to rea
h the destination the destination using a bus restri
ted plan of height
h Tb s; h
T r Rb r; vi T vi
i
F bi
i i at some bus stop following on the route of and
F bi
si s b
The se
ond term gives the time after we get into some min( ( 1) minf ( ) + ( 1)g)
Tb s; h ; Rb s; si T si ; h
bus. Suppose bus is the rst to arrive, then the
bi
i
hen
e the weighting fa
tor in the expression above. set of buses , and having got into one of these buses B
s
Dene the height of a plan as the height of the 2 , following the
orresponding bus restri
ted plan
b B
asso
iated tree; the height is simply the maximum of height . Let denote the set of the buses passing h Bs
number of bus trips used in any exe
ution of the plan. through stop . Then we have: s
2 () 2 2 ()
H
s
Tb s; h
H is a parameter set by the user. We do this B B
b B
F b
b B b B
F b
01
; . For = 0 1
;::: ;H h 1 we
onstru
t for the buses, and the se
ond the expe
ted time spent
; ;::: ;H
optimal plans to rea
h the destination from every bus exe
uting the bus restri
ted plans.
The key question then is how to nd the subset x; y; a; q; r , we see that:
. Naively, it would seem that we need to expli
- P
1 +P 2 ( )
B
2 () + ( 1)
O Bs Bs
F b F bi
b B
P
Tbi (s; h). Without loss of generality let Tb1 Tb2 sin
e i i 1 . But the right hand side is simply
Tb Tb
: : : Tbm . Let the time for the plan involving waiting for the buses
in [f 1 g. Thus we may assume that the optimal
B bi
= 1 X
i
( ) plan involves waiting for buses 1 through for some b bk
Ti Pi + Pi
F bj
Tbj .
( ) ( )
k
F bj F bj
j =1 j =1 j =1
orresponding optimal bus restri ted height h plans. Tb l+1 needed to nish the journey even after +1 has bl
Let l be smallest su
h that Tl Tbl+1 . Then it already arrived is no less than the expe
ted waiting
suÆ
es to wait for buses b1 ; : : : ; bl , and ignore the and travelling time if we wait for 1 . Thus
T b ; : : : ; bl
earliest. In general:
( )= Pk
= 1 +P ( )
T s; h Tl
F b j Tbj
j =1
Tk
=1 ( ) k
j
F bj
involves waiting for a set of buses at stop . Then B s Sin
e l+1 l+2 k . But for positive
Tb Tb ::: Tb
P (3.2) =1
P
j
1+ b2B
() 1+ ( ) l
P =1
F b Tb F b j Tbj
j
P
2 P( ) ( ) l
F b F bj
b B =1 j
1+ ()
P 2 f ig ( )
F b Tb
by
hoosing:
b B b
2 f ig
b B b
F b
P
1+ 2 ( ) ( ) = 1P+ =1 ( )
Pk
=
F b Tb F b i Tbi w F b j Tbj
b B
P j
2 () ( ) b B
F b F bi z = =1P ( ) k
j
F bj
x = 1 + =1 ( ) l
F b j Tbj
=)
j
Noting that x
y
x
y
aq
q
x
y
x+ar
y +r
for positive a = l+1Tb
Pk
q = Pjl =l+1
( )P
F bj We note that even in theory the maximum value
y = F bj( ) + = +1 ( ) k
of is
ertainly no more than the number of bus
F bj H
j =1 j l
routes; hen
e the optimal travel plan (with un-
bounded )
an be
omputed in polynomial time. H
and observing that = l+1 = . But (3.2) However, in pra
ti
e we note that the maximum num-
a Tb T x=y
simply asserts . In a similar manner we
an ber of bus
hanges a traveller might tolerate would be
l
T T
of the stops on route ; if and +1 are
on- 3. End-to-end travel time for ea
h bus route. If the
b si si
se
utive bus stops on the route, it follows from stops on a route P are 1 2 , then we are b s ; s ; : : : ; sk
equation 3.1 that given the value of =11 ( +1 ). k
j
R sj ; sj
time proportional to the number of stops on the boundary stops on the route of bus and if b
at must rst be arranged in in
reasing order of For the algorithm des
ribed in the last se
tion, we
s
i(
Tb ). This
an be done in time ( log ) need the values of ( ) for every pair of
onse
utive
s; h O m m
time ( ). From this we
an determine . The
learstops and on every route . It should be
Ti
s t b
O m m
to determine these values pre
isely.
This des
ription only
onsiders the
omputation of may The question then is: of all the possible values that
( ) and ( ); however it may be noted that supplied be assigned to ( )
onsistent with the data R s; t
Tb s; h T s; h
the
orresponding plans
an be re
overed if auxiliary by BEST, whi
h ones should we use?
data stru
tures are maintained. Also, it will be We use a two phase approa
h for doing this. In
noted that the auxiliary data stru
tures
an be the rst phase, we generate estimates for distan
es
maintained without
hanging the algorithm exe
ution ( ) between
onse
utive bus stops d s; ton every s; t
time estimates given above. route. In the se
ond phase, we generate estimates
Let denote the maximum number of buses for ( ). Both phases use linear programming.
C
R s; t
stopping at any bus stop. Let denote the sum of Generating distan
e estimates: We
onsidered
L
the lengths of all bus routes. Then the time for step it reasonable to assume that adja
ent bus stops
1 above is ( ), and that for step 2 is ( log ).
ouldnt be arbitrarily
lose (say no
loser than some
O L O L C
The time for the algorithm over all phases is thus parameter min), nor arbitrarily far apart (say no d
( log ).
O HL C farther than some parameter max). We initialized d
dmin and max to values whi
h are
learly
orre
t,
d Please give the name of sour
e
e.g. 10 meters and 100 km respe
tively. This gives $->i.i.t.market
us inequalities of the form min ( ) max . We
d d s; t d
Please give the name of destination
$->vashibusstation
added these to the equations given under stage length A PLAN WITH 0 CHANGE OVERS
data above and
he
ked if resulting linear program Expe
ted travel time :
was feasible. If the linear program was feasible, then 66.231911 = 30.500000(w) + 35.731911(r)
we narrowed the gap between min and max and tried
d d
again. In this manner, the feasible solution for the 1: i.i.t.market to vashibusstation by 710ltd.
losest min and max was found and sele
ted as the
d d
A PLAN WITH 1 CHANGE OVERS
estimate. Expe
ted travel time :
45.505608 = 1.108896(w) + 44.396713(r)
Generating time estimates: We
onsidered it
reasonable to assume that bus speeds are bounded, 1: i.i.t.market to gandhinagar[kanjurmarg℄ by
say between min = 10 kmph and max = 60 kmph.
v v
459ltd., 409ltd., 425ltd., 403ltd., 460ltd.,
398ltd., 425, 461ltd., 445ltd., 424, 307,
This gives us inequalities of the form ( ) max
d s; t =v 185, 422, 346ltd., 496ltd., 396ltd.
( ) ( ) min . As before we try to tighten
R s; t d s; t =v 2: gandhinagar[kanjurmarg℄ to vashibusstation
these bounds while ensuring that the linear program by 511ltd., 710ltd.
remains feasible. Then we use the solution obtained 1: i.i.t.market to hindustan
o.[vikhroli-w℄ by
for tightest program possible { this
orresponds to 336, 392
2: hindustan
o.[vikhroli-w℄ to vashibusstation
saying that within a
ity we dont expe
t bus speeds by 511ltd., 710ltd.
to vary too mu
h. We feel that this assumption is 1: i.i.t.market to vashibusstation by 710ltd.
reasonable in absen
e of additional information.
Figure 2: Sample session with Mumbai Navigator
4.1 Problems due to data in
onsisten
ies
It turned out that the data given to us by BEST We have
oded the algorithm and strategies des
ribed
also had in
onsisten
ies, i.e. the system of equations above (about 2500 lines of C). The user interfa
e
given to us (without the inequalities we inserted) is
urrently text-based, though a menu-driven Java
didnt have a solution. We tried to get these resolved implementation is also almost ready. The C version
by reporting them ba
k to BEST and requesting has been tested substantially, and we plan to release
orre
t data; however be
ause of various reasons this it to general users shortly. Figure 2 shows a sample
didnt always work. So we had to resort to strategies session with the program, whi
h we
all Mumbai
to work around in
onsisten
ies. Navigator.
Our approa
h was to in
orporate an error vari- In the sample session the program is asked to
able into ea
h equation. We then added in the in- plan a journey analogous to the example in Figure 1.
equalities as des
ribed above and attempted to solve The journey is to start at I. I. T. Market and end
the resulting program, this time looking for a solution at Vashi Bus Station (typed by the user after the
with small total error. We looked at the individual prompt \$->"). The program
an generate plans
error values and this on o
asions alerted us to obvi- of arbitrary height, the output only shows plans of
ous and
orre
table errors in the data (e.g. the end height 1 (0
hangeovers) and height 2 (1
hangeovers).
to end timing for some route being an absurdly small For ea
h plan the total travel time is given, as well
value). But in the end we were not able to
orre
t as its breakup into the waiting time for the rst bus
all errors and had to live with some in
onsisten
ies. and the time for the rest of the journey. Noti
e the
We expe
t that these are all teething troubles, soon relatively large waiting time in the 0
hange over plan
enough we will get
onsistent data from BEST so that (30.5 miutes).
we dont have to worry about this issue.
The program print outs the generated plan tree
in a depth rst manner, with indentation to aid
readability. Some amount of
ommon subexpression
elimination is also done. For example, if and v w
are the
hildren of node in the plan tree with
u The operational reason for assuming Poisson
( ) = ( ), then we are guaranteed that the subtree
S v S w arrivals is that this provides a rule for estimating
beneath and are identi
al. Thus in the printout,
v w waiting time when we are waiting for arrival of a bus
we only give one of the trees, say the one below , and
v on any of a given set of routes. If we
an be given a
set the new label for ( ) to be the
on
atenation of
u; v suitable rule for estimating the waiting time for other
the old labels ( ) ( ).
B u; v ; B u; w distributions, we expe
t that should be adequate for
Ea
h step of the printed plan is of the form our purposes. We spe
ulate that the
ombining rule
for other distributions will be very similar to the one
i: stop1 to stop2 by busno1, busno2, ...
we use.
Our assertion that \it usually takes a predi
table
Here indi
ates the level number (root is 1). amount of time (for a bus) to rea
h its destination
on
e you have
limbed aboard, but the amount of
i