mm-visualization tools for real-time search algorithms

Upload: lados-ludomir

Post on 14-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    1/45

    Visualization Tools forReal-time Search Algorithms

    Yoshi t aka Kuwata1& Paul R. Cohen

    Computer Science Technical Report 93-57

    A b s t r a c t

    Sea rch methods ar e common mechanisms in problem solving. In ma ny AI applica tions,

    they a re used with heuristic functions to prune the search space and improve performa nce. In

    last thr ee decades, much effort ha s been directed towa rd resear ch on such heuristic functions

    a nd sear ch methods by AI community . As it is very ha rd t o build theoretical models for heuristic

    functions to predict their behavior, we can often only check their performance experimentally.

    In pra ctica l applica tions, it is import an t t o understa nd th e sea rch space an d behavior of

    heuristic functions, otherw ise, we cannot figure out w ha t's going on in actua l a pplica tions an d

    cann ot cont rol them. These issues ar e crit ical, especia lly in th e field of rea l-tim e problem

    solving, in which applicat ions ha ve time constra ints a nd a re required to finish processing within

    the given time interva l.

    In t his report, visua lizat ion methods ar e intr oduced a s tools to underst a nd the sear ch

    spa ces a nd beha vior of heuristic functions. As exam ples of th e usefulness of visualiza tion

    methods, A* an d ID A* algorithms a re represented in va rious forms. They can be used to debug

    practical a pplica tions tha t use heuristic functions.

    1 NTT Da ta Communicat ions Systems, D evelopment Section

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    2/45

    1. Why Visualizations are Important in AI

    Looking ba ck on t he hist ory of science, observa tion t ools often play ed a very

    import a nt role in scient ific discovery. In t he a ges before th e invention of th e telescope,

    for exam ple, w e could not observe pla nets in d eta il. We didn't even know of the

    existence of pla nets. Telescopes ma de it possible to mea sure a ccura te positions of th e

    planets, a nd t ha t ma de it possible to find Kepler's law , New ton's law s a nd so forth . The

    sa me story is t old in other a rea s of science. The microscope, X-ra y, spectr um a na lyzer

    a nd other observa tion tools all cont ribut ed to th e progress of science. In oth er words,

    th e history of science is a lso the hist ory of the engineering of observa tion t ools.

    The story is t he sa me in comput er science. Today , computers a re used to

    simula te a va riety of problems in comput er science; for example, computer simula tions

    of th e execut ion queue of an operat ing syst em. Queuing th eory provides some guida nce

    but t he optima l queue length is often determined experimenta lly with computer

    simula tions. In t his exa mple, comput ers ar e used as t ools to stu dy th eories in comput er

    science a nd t hey a re also the ta rget of st udy in comput er science. When w e develop

    th eories of comput er science, we a lso need t o develop observa tion t ools for t hem. Aga in,

    w e ca nnot develop theories w ith out observing phenomena .

    In comput er science, especially in a rt ificia l int elligence, th e development of

    observa tion t ools seems not t o ha ve been very focused. This pa per describes a collection

    of visualization tools for search algorithms, because search algorithms are very common.

    To apply sea rch mecha nisms for problem solving, the problem spa ce must be defined a s

    a set of sta tes, including an initial sta te a nd goal sta tes, and a set of operators to move

    from one sta te to th e oth er sta tes. A solution corresponds t o a s eries of opera tions

    moving from the initial sta te to a goal sta te.

    We can a na lyze sear ch a lgorith ms theoretically or empirically. Theoretica l

    a na lyses ar e sometimes bett er tha n experiment a l ones, because w e don't need to collect

    da ta , and beca use the results a re often more genera l . However, we usua lly need to rely

    on heuristic functions t o solve big an d complex problems in realist ic time. H euristic

    functions ma ke a na lysis ha rder as th ey often don't ha ve theoretical underpinning. In

    th e ca se of chess, for exam ple, th ousan ds of suggestions exist in t he books, but t hey

    don't ha ve theoretica l explana tions. Inst ead, th ey ca me from huma ns' experiences and

    inspira tions. In such cases, we need to rely on experimenta l an a lysis of the heuristics.

    B y a pplying visualizat ion t ools to search a lgorithms, w e can observe phenomena

    caused by heurist ic functions. These tools ar e also useful for debugging, verifica tion a ndvalidation.

    Sea rch spaces a re described in section 2 of th is paper. Convent iona l techniq ues

    such as search t ree representa tions an d depth-number of node representa tions, and

    their adva nta ges a nd disadva nta ges a s visualizat ions are discussed in section 3. In

    section 4, visua lizat ions of heuristic function are described w ith exa mples from th e

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    3/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    2

    Eight P uzzle. Time series and frequency an a lysis of search a lgorithms a re discussed

    w ith exa mples in section 5.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    4/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    3

    2. Objects to Visualize in Search

    2.1 Search Space

    The most importa nt thing in problem solving by sear ch is to understa nd sea rch

    spa ces th emselves. They va ry from problem to problem. For example, backgam mon ha s10

    20sta tes in its search space a nd chess has a much bigger stat e spa ce. The structure

    of sear ch spaces is a lso completely different in va rious problems. In chess, lar ge

    numbers of actions a re possible in th e f irst sta ge of th e gam e but a ctions a re l imited in

    the endga me. On the other ha nd, in shogi, which is a t wo-player gam e similar t o chess

    tha t a llows reuse of dead pieces, the movements in th e last sta ge aren't l imited a s in

    chess.2 Therefore, the sea rch spa ces for the tw o games w ould be different, even though

    th ese ga mes look simila r.

    The simplest w a y t o represent a search space is to count t he number of sta tes in

    it . For exa mple, we can compar e tw o problems A a nd B , which ha ve ten million st a tes

    a nd one million st a tes, respectively. We expect to t a ke 10 times longer to solve problemA th a n to solve problem B. This is because w e assum ed problem A a nd B a re equa lly

    difficult; i .e., they ha ve the sam e sea rch space structu re. B ut it is possible to define a

    problem wh ich has a bigger search spa ce but is simpler to solve. Thus simple search

    sta te count a lone is not sufficient t o cha ra cterize a search problem.

    Which problem is bigger ?

    Go a l

    Go a lA B

    Figure 2.1.1 Two Problems The num ber of possible stat es in problem A is much sma ller

    tha n in problem B . It t akes more tha n 100 steps to reach the goal in problem A, but only 3

    steps in problem B on a verage.

    2.2 Shape of search space (Branching Factor and Depth)Assuming w e ca n represent problem spa ces a s sear ch trees, the a verage

    bran ching factor an d depth of sea rch tree a re useful cha ra cteriza tions. The avera ge

    bran ching fa ctor is the a verage number of successor sta tes following ea ch sta te. For

    2 Although possible actions in the endgam e are fewer th an in the first sta ge, shogi ha s more possible

    endgame a ct ions tha n chess.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    5/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    4

    example, in the E ight P uzzle, the number of successor nodes3 is either one, tw o, th ree or

    four. When w e solve the puzzle allowing cyclic a ctions4, the a verage bran ching factor is

    a bout 2.6. On the other ha nd, it is 2.3 w ith out cyclic a ctions. These num bers were

    ta ken from a ctual execution tr a ces of searches tha t ha ve different successor functions.

    It is often very difficult to ca lcula te the theoretical bra nching factor. Thus experiment a l

    values for bran ching fa ctor5

    a re often used. In general , the bran ching factor dependsupon th e successor functions 6 in the search method.

    The depth of a sea rch tr ee represents t he length of a sequence of opera tions

    required to reach the termin a l nodes. When w e a ssume a sea rch tree is completely

    balanced a nd ha s branching factor band depth d, th e number of nodes at level i is given

    by bi , therefore th e tota l number of nodes in the tree n is given by th e follow ingequation:

    n= 1+ b+ b2 + b3 + L + bd

    = bii=0

    d

    (2.2.1)

    If we a ssume a t ree ha s different bra nching fa ctor bi a t level i, equa t ion (2.2.1)7

    w ould be the follow ing:

    n= 1+ b1+ b1b2 + b1b2 b3 + L + b1b2 b3Lbd

    = 1+ bjj=1

    i

    i=1

    d

    (2.2.2)

    E qua tions (2.2.1) a nd (2.2.2) can be applied to a fully ba lan ced t ree only w hen

    theoretical bra nching factors a nd sear ch depth a re known . However, i t is possible todetermine th e effecti ve br anching factora t level i( bi) experimentally by actuallysear ching. When we count t he number of nodes at level i a s ni and at level i +1a s ni + 1,the a verage effective branching fa ctor a t level iis defined by th e follow ing equa tion:

    bi =ni + 1

    ni(2.2.3)

    The chan ge in effective bra nching fa ctor shows th e cha nge of th e eff ecti ve sear ch

    spacewh ich is defined as a result of the search spa ce a nd of the h euristic function used

    to prune nodes. For exa mple, w e w ould observe lar ge ba t sha llow levels but small bin

    3 Successor nodes in a search t ree represent possible successive stat es.4 Cyclic actions are defined to generat e the same stat es that a ppeared previously. For exam ple, moving one

    piece back an d forth ma ny t imes corresponds to a cyclic action. We know such actions would not help in

    solving t he puzzle.5 We refer to experimenta l bran ching factor as th e "effective bran ching factor" in t he rest of this paper.6 Successor functions a re functions tha t r eturn successor nodes.7 This equat ion still assum es the tree is bala nced but has different bra nching factor at ea ch level.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    6/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    5

    deep levels in th e sea rch of gam es like chess an d shogi. In such ga mes, there are a huge

    number of possible actions in the beginning st a ges but fewer a t t he end. Thus t he

    expected branching fa ctor in search a t each level will vary.

    Note also tha t equat ion (2.2.3) gives only the a verage bra nching factor a t a

    cert a in level a nd does not tell us w heth er the search tree is ba lan ced. The height ofsearch trees is not n ecessarily the sa me at each bran ch in actua l sea rch, as one bran ch

    can reach a dead end before a nother. In such ca ses, the number of terminal nodes a t

    level i will a f fect the ca lculat ion of bra nching fa ctor a t t ha t level. B eca use terminal

    nodes ha ve no successor nodes, their bran ching factor is 0, w hich decrea ses the avera ge

    bran ching factor. When we ar e interested only in the nodes tha t ha ve a t least one

    successor node, we should exclude termin a l nodes from our calcula tions. One exa mple

    of th e effect of termina l nodes on the a vera ge bran ching factor is shown a s figure 2.1.2.

    depth1

    depth2

    depth3

    Figure 2.1.2 An example of an Unbalanced Tree In t his tree, there is one node ateach depth w hich has 8 successor nodes while all others ar e termina l nodes (bra nching

    factor = 0). The avera ge branching factor at depth 2 and depth 3 is 1. Nodes wh ich ha ve 8

    successor nodes contr ibute to increase the a verage bra nching factor.

    This effect is a lso observed w hen w e use a h euristic function to prune bra nches

    from a search tr ee. The pruned nodes can be regard ed as a termina l node, therefore, the

    effective branching fa ctors a t each depth becomes sma ller t ha n t he values given by t he

    successor function. This effect is a lso observed w hen w e ar e forced to stop sea rch a t a

    cert a in level. In t his ca se, th e observed bran ching factor at th e low est level would be

    zero.

    2.3 Pruning and Heuristics

    When it is known tha t some pa rts of the search space are not worth searching,

    th e cost of sea rch ca n be sa ved by excluding t hose a rea s from th e solution space. For

    exa mple, in th e search a lgorithms used to solve the Eight P uzzle, we don't need t o

    consider th e previous st a te a s a successor st a te, beca use it w ould cause mea ningless

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    7/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    6

    itera tive a ctions. We know su ch actions w ould not help us solve the puzzle, th erefore,

    we can prune them.

    It is common a lso to use heurist ics to choose th e best su ccessor st a te ea rlier tha n

    less worth y successors. If th e problem is to find one accepta ble solut ion, a nd not t o

    sear ch all of th e sta te spa ce, choosing th e best a ction first w ill help us find t he solutionfa ster. H euristics a re used for tw o purposes:

    1. to choose th e best successor sta te

    2. to omit subt rees where t here is no need t o sea rch (prunin g)

    Visua lizat ions must be capa ble of representing both of th ese purposes. For

    example, we ca n use bra nching fact or a na lysis directly t o know th e effect of prun ing. As

    the result of pruning, the a verage bran ching fa ctor becomes sma ller t ha n t he expected

    value. On the other ha nd, we can indirectly observe th e quality of the pa th t he heuristic

    function chooses from th e sequence of heuristic values the function return s. In t he ca se

    of h functions in A* sea rch, for exam ple, if the fun ction is chooses a good pa th to th e

    goa l, th e h va lue is expected to decrease.

    A good visualization would represent these two purposes directly and separately.

    2.4 Characteristics of search algorithms

    As th e goa l of visualizat ions for sea rch algorithms is to understa nd t he

    a lgorithms a nd t o predict their behaviors, visualization tools must h a ve the abili ty to

    represent how sea rch algorithm s a re working.

    For example, depth-first search8 a nd breadth-first search9 behave

    differently. The former sea rches dow n to the deepest pla ce first w hile th e la tt er fully

    explores th e sha llow est level of th e search t ree first . We ca n decompose th e

    char a cteristics of oth er search a lgorith ms int o depth-first component s (deeper first) and

    bread th -first components (broa der first ). Best-first search10 is a general s tra tegy to

    sear ch the best possible successor node first . If th e eva lua tion function of a best-first

    sear ch relies heavily on the cost of the pa th t o rea ch the node, the search w ill be simila r

    to brea dth -first search. B y contr a st, i f the evalua tion function emphasizes the

    rea cha bility of goa ls, the sea rch would be similar t o depth-first sea rch. The

    char a cteristics of best-first sea rch depend on the evalua tion function. In genera l, in

    best-first search, we need to balance various cost factors in the evaluation function in a

    ta sk-specific ma nner.

    Eva luat ion functions typica lly must be ca refully tun ed by experiment.

    Decomposing search beha vior int o depth-first a nd brea dt h-first component s is one wa y

    8 P seudo-code of depth -first sea rch is show n in Appendix A.1.9 Pseudo-code of breadth-first search is shown in Appendix A.1.10 P seudo-code of best-first sea rch is show n in Appendix A.1.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    8/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    7

    to chara cterize a nd understa nd sea rch a lgorithms. In this paper, var ious visua liza tion

    techniqu es ar e shown t o accomplish t his decomposition.

    There a re intera ctions betw een search algorithm s and sea rch spa ces. Eva luat ion

    functions t ha t a re ca refully tuned to one part icular problem w ill not a lwa ys work well

    for slightly different problems. For exa mple, th e right -ha nd meth od11

    , or left ha ndmeth od, a re ea sy w a ys to solve simple ma ze problems. They a re basica lly a depth-first

    sear ch. Figur e 2.1.3 is a simple example of tw o ma ze problems, wh ich illustra tes a n

    intera ction effect betw een sear ch algorithm s an d search spa ces. In cas e (A), the left -

    ha nd meth od w orks better tha n th e right-ha nd method; in ca se (B ) the right -ha nd

    method works better.

    start

    goal

    start

    goal

    (A) (B)

    Figure 2.1.3 Two Maze Problems One simple example of the int eraction of algorithman d search space. (A) is easily solved by left-ha nd meth od. On the other ha nd, in ma ze

    (B ), w hich is th e mirror ima ge of (A), left-ha nd m ethod is not a good solution.

    Actual observa tions depend both on the char a cteristics of search a nd t he search

    spa ces. A good visualiza tion would represent th em independent ly and help determ inethe int eraction effect betw een t hem.

    11 One can solve simple mazes, which ha ve no islands, by keeping one hand to the wa ll and w alking a round

    the maze. "R ight-ha nd" m ethod refers to solving the problem by using the right-ha nd and t urning ar ound

    the ma ze clockwise, and vice versa for "left-ha nd" method.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    9/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    8

    3. Conventional Visualization tools

    3.1 Search Trees, Graphs

    It is very common to represent sea rch spaces as t rees 12. In this representa tion,

    nodes in th e tree correspond to sta tes in th e sea rch. Sea rch goes from the root node ofth e tree down to t he leaf nodes nodes w hich ha ve no furt her successor n odes or w hich

    a re desired sta tes. The pat h from the root t o the leaf nodes traces the steps from the

    sta rt st a te to a goal sta te in the solution space. The following f igure shows a tree

    representa tion of a search space.

    Figure 3.1.1 Example of Graph Representation of Search Tree Fully balanced treewit h bra nching factor b= 2 and height of tree = 4. There are 31 tota l nodes in this tree,

    including root node a nd lea f nodes.

    In t his representa t ion, when w e draw arcs as the same length an d descendantnodes as t he same dista nce, we ca n easily see the search depth an d search widt h a s the

    height a nd t he widt h of the sear ch tree, respectively.

    I t is a lso easy t o show chara cteristics of search a lgorithms such a s dif ferences in

    sear ch order. For exa mple, depth-first sea rch will pick up one pat h a nd cont inue

    searching down to the lea f node, which is a sta te the sear ch algorithm wa s looking for,

    or w hich ha s no successors. In t he former case, the sea rch algorithm ha s the option t o

    keep searching un til it finds bett er solutions. To sear ch furth er in the tr ee a fter

    reaching th e lea f node, the sea rch a lgorithm needs to look up other bra nches in the

    pat h. The simplest meth od is to sear ch lowest a ltern a tive bran ches. This operat ion is

    known a s backtracking. Depth -first sear ch w ould cont inue ba cktra cking unt il it finds asolut ion or searches a ll of the tr ee. The follow ing figure shows t he cha ra cteristics of

    depth-first search using tree representations.

    12 In genera l, a stat e space would be represented by genera l directed gra phs. However, we can expan d

    these graph representa tions by duplicat e subtrees in a t ree representa tion.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    10/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    9

    1

    2

    3

    4 5

    6

    7

    8 9

    10

    Figure 3.1.2 Depth-first Search in a Search Tree The order of sea rch is la beled oneach of the bra nches. In th is exam ple, the search a lgorithm checks the leftmost bra nches

    first , then goes to the right bra nches.

    On th e other ha nd, a breadt h-first search a lgorithm searches the sha llow level of

    th e tree first , then increa ses the level of search one by one. Figur e 3.1.3 show s th e

    beha vior of breadt h-first sea rch using t he sa me representa tion a s depth-first sear ch.

    1

    2 3

    4 5 6

    7 8 9 10

    Figure 3.1.3 Breadth-first Search in a Search Tree The order of sea rch is la beled oneach of the bra nches. B read th-first search checks nodes in the sha llowest level first , then

    searches progressively deeper levels.

    These representa tions are very intuitive and ea sy to understa nd, but t hey a re

    useful main ly for sma ll sea rch spaces. When th e tree becomes lar ge, w e ca nnot

    represent a ll search sta tes as n odes in th e sea rch tree. P a rt of this diff iculty depends on

    huma n perceptua l ca pabili t ies. I t is sa id to be ha rd for huma ns to hand le more tha n 10

    to 20 objects a t once. The tr ee representa tion of th e search spa ce for a pra ctical problem

    could be more th a n ten million sta tes. Even if we could recognize pat tern s in such a

    large tree representa tion, we could not understa nd t hem in deta il . To determine the

    deta ils of th ese pa tt erns, we need to look closely a t individua l nodes a nd pa ths inside

    the t ree.

    In t he lar ge tree in figure 3.1.4 (showing a bout tw o hun dred nodes) w e ca n

    recognize tha t t he top leftmost bra nch ha s ma ny more nodes tha n other tw o bra nches.

    However, we ca nnot determine the a verage bran ching fa ctor of ea ch branch from this

    representation.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    11/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    10

    Figure 3.1.4 Large Tree This figure is made by ra ndomly pruning subtr ees from a fullybala nced tree with b= 6 an d h= 7. The resulting tree includes about 200 nodes.

    This discussion is a lso va lid for va ria tions of tree representa tions such a s 'AND -

    OR trees' a nd ' la beled trees. ' They a re very int uitive and ea sy to understa nd for sma ll

    search spaces. Thus th ey help us understa nd th e ba sis of sea rch spa ces an d a lgorithms,

    but a re less useful for a na lyzing large sca le sea rch spaces in deta il .

    3.2 Depth-number of node counts

    The size of a sea rch spa ce is commonly represented a s t he num ber of nodes a t

    each level.

    Theoretical Depth-Node CountsFigur e 3.2.1 plots n ode count s for a sear ch tree. The number of nodes at each

    level is given by bi , where iis the depth of the search tr ee a nd bis the a veragebra nching fact or. Depth -node count s for th ree va lues of ba re shown in this f igure.

    4 5 6 7 8 9 10

    2000

    4000

    6000

    8000

    b=2.3

    b=2.5b=2.8

    Depth

    #Node

    Figure 3.2.1 Node Count Representation of Search Trees This figu re is ba sed onequa tion (2.2.1). The number of nodes at successive depths increas es exponentia lly.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    12/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    11

    Empirical Depth-node countsI t is also useful to apply the node count visualizat ion t o empirica l dat a . The

    following f igure shows a ctua l dat a from E ight P uzzle search using three different search

    meth ods. One is pure depth-first sea rch wit h a d epth-bound, which corresponds to one

    iterat ion of IDA* search with a consta nt h function. The oth er tw o a re IDA* sear ch13:

    one uses a Ma nha tt a n dista nce function forh a nd t he other uses a f inal position count

    function for h .14

    0

    5000

    10000

    15000

    20000

    25000

    30000

    35000

    40000

    0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0

    Dept

    n

    umberofnodes

    pure depth-first search

    IDA* withfinal position count

    IDA* withManhattan-distance

    Figure 3.2.2 Empirical node counts from Eight Puzzle This figure shows t he number

    of nodes expanded a t ea ch level of the search tree for three a lgorithms. As pure depth-firstsearch doesn't prune nodes at all, th e curve from pure depth-first sear ch shows the t otal

    number of nodes at ea ch level. B y compar ing with t ha t curve, we can see how ma ny nodes

    ar e pruned by the other tw o algorithms. If the number of nodes at one level is the sam e as

    pure depth-first sear ch, then there is no pruning a t th at level.

    The curve from pure depth -first sear ch uses no prun ing, t herefore it represents

    a ll of the nodes a t ea ch depth. This curve grows exponentia lly as w e have shown in t he

    theoretical depth-node counts graph (figure 3.2.1).

    Now w e ca n check the effect of pruning by comparing pruned dat a w ith t he pure

    depth-first sea rch curve. The oth er tw o curves a re almost ident ical to the no-pruning

    curve until depth = 9. This mea ns the tw o a lgorithms expanded almost the sam enum ber of nodes unt il depth = 9. The curve from IDA* with th e final position count

    function is different from no-prunin g curve only from depth = 14, but I DA* with

    Man ha tt a n dista nce ha s a lower growth ra tio tha n the no-pruning curve. This shows

    tha t t he former can prune nodes only a t t he deepest levels, but t he lat ter can prune

    13 P seudo-code of ID A* sea rch is sh own in Appendix A.3.14 These heuristic functions are described in Appendix A4 in detail.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    13/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    12

    nodes a t sha llow levels a lso. We cann ot know why t hese functi ons are dif fer ent , given

    th i s r epr esent ati on, but we can k now how they are di ffer ent . We need to introduce

    visualization of heuristics to know why these heuristic functions behave differently.

    From equa tion (2.2.3) the a verage bra nching factor a t each level for t his da ta can

    be ca lcula ted. The result is show n in figure 3.2.3.

    0.5

    1.0

    1.5

    2.0

    2.5

    0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0

    Dept

    pure depth-first search

    IDA* with final position count

    IDA* with Manhattan-distance

    averag

    ebranchingfactor

    Figure 3.2.3 Empirical branching factor at each level of the Eight Puzzle Thisfigure shows the empirically derived avera ge branching fa ctor for each algorithm.

    I f th e tree is fully bala nced a nd t here is no pruning during sear ch, the average

    bra nching fa ctor is expected to be consta nt a t every level a nd t he plot is expected t o be a

    flat l ine. In sear ch without pruning, which is shown a s pure depth-first search in the

    figure, the average branching factor has some structure: sma ll bran ching factors are

    followed by lar ge branching factors and vice versa . In t he Eight P uzzle, the full search

    tr ee is likely to ha ve a sm a ll number of moves follow ed by a la rge number of moves, a nd

    vice versa . For exa mple, th e cent er position ha s thr ee possible moves th a t lead t o sta tes

    wh ich ha ve only tw o legal m oves.

    Time Trace of Node Count

    It is also useful to observe the behavior of va rious search meth ods in a nodecount gra ph by plotting t he history of sea rched nodes. Figur e 3.2.4 represents t he

    expected hist ory of node count s in depth -first sea rch. In t his gra ph, the number of

    nodes at ea ch level increases a s time passes. Thus la ter curves are a bove ea rlier curves,

    a s more nodes ar e sear ched a t ea ch depth . The curve grows vertically from bottom t o

    top.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    14/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    13

    Numbero

    fNodes

    time

    Depth

    Figure 3.2.4 Time Trace Representation in Node Count (general depth-first search)

    This is th e expected gra ph on time t ra ce of node count in depth-first sea rch. As time pa sses,the num ber of nodes visited by depth-first sear ch increases at each level.

    An a ctua l depth -first sea rch for th e Eight P uzzle, show n in figure 3.2.5, is pretty

    much as expected. The number of nodes at ea ch depth increases as tim e pa sses. If the

    search tr ee is not ba lanced a t a ll , the number of nodes shown in this f igure wouldn't

    increase proportional t o time spent for sea rch. We ca n conclude, th en, tha t t he search

    tree in Eight P uzzle is balan ced.

    2 4 6 8 10

    Depth

    0

    50

    100

    150

    200

    250

    300

    350

    NumberofNode

    s

    Figure 3.2.5 Time Trace Representation in Node Count (Depth-first Search on theEight Puzzle) This gra ph wa s ma de from one insta nce of a t ime tra ce of depth-first sear ch onthe Eigh t P uzzle. Ea ch curve represents th e number of nodes at each depth in every 80 nodes

    expanded; i.e. , the lowest curve is t he plot of the first 80 nodes searched, t he second lowest

    curve is from the first 160 nodes, a nd so on. The envelopes of these curves grow exponentia lly

    as the depth increases.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    15/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    14

    On the other hand, the graph of breadth-first search will be completely different

    from depth -first sea rch in a n ode count r epresent a tion wit h history. The follow ing

    figure is an expected execution history of depth -first sea rch. In t his represent a tion, the

    breadth-first search progresses horizontally from left to right. This is because th e

    sear ch moves from sha llow levels to deeper levels progressively. If t he sear ch space is

    th e sam e as for depth -first sea rch, the envelope of th e curve is also the sa meexponentia l curve as t ha t of depth-first sear ch.

    Num

    berofNodes

    time

    Depth

    Figure 3.2.6 Time Trace Representation in Node Count (general breadth-first search)As time passes, th e frontier of the sea rch progresses from left to right horizonta lly. The

    envelope of the curve reflects the sear ch space and is the sa me w ith d epth-first curve.

    The result of a n a ctual brea dth -first search on the E ight P uzzle is shown in

    figur e 3.2.7.

    2 4 6 8 10

    Depth

    0

    50

    100

    150

    200

    250

    300

    350

    NumberofNodes

    Figure 3.2.7 Time Trace Representation in Node Count (Breadth-first Searchon Eight Puzzle) This graph w as ma de from a t ime tra ce of breadt h-first search onthe Eight P uzzle. Ea ch curve represents the number of nodes at ea ch depth.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    16/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    15

    Other search a lgorithms m ix breadt h-first search a nd depth-first search. The

    follow ing figure shows best -first sea rch a pplied t o the sa me sear ch tree a s figures 3.2.4

    a nd 3.2.5. If th e eva lua tion function used in best-first sea rch relies on depth, th e sea rch

    is like depth -first sea rch a nd t he envelope grow s vertically. If th e function relies on

    breadth , the search becomes like breadt h-first search a nd curve grows horizonta lly . In

    other w ords, th e ver ti cal growt h of th e cur ve r epr esent s depth -fi r st component s in t hesear ch and th e hori zont al growt h of t he cur ve r epr esent s breadt h-fi r st component s.

    Depth

    Nu

    mberofNodes

    time

    Figure 3.2.8 Time Trace Representation in Node Count (general best-first search)G eneral best-first search ha s a depth-first component (vertical growth ) an d a br eadt h-first

    component (horizonta l gr owth).

    The result from ID A* sea rch with Ma nha tt a n dista nce is shown in f igure 3.2.9.

    Ea ch curve corresponds to a n itera tion of ID A* search; i.e., the leftmost curve, wh ich

    sta rts a t depth 0 and reaches depth 3, is from the f irst i t erat ion. The second leftmostcurve is from th e second itera tion, wh ich expan ded nodes to level 4, an d so fort h. The

    eighth (last ) i terat ion is shown a s the t op curve. In t his case, a solution is found a t t he

    eighth it era tion a t level 21. The search horizon progresses horizonta lly in the lat er

    iterat ion of IDA* sea rch. This fact shows t ha t t he heuristic function prunes ma ny

    bran ches in deeper pa rts of the search tr ee.

    For comparison, a non-pruning a lgorithm is a lso shown in this f igure a s a n

    exponentia l curve. The sear ch is very mu ch like depth-first sea rch (i.e., it grows r a pidly

    in the horizontal direction) but expands fewer nodes than pure depth-first search.

    Especially in the last tw o itera tions, the sea rch progresses a t more tha n ten levels at

    once. This means tha t t he heuristic function can help choose the right bra nch an d a voidsearching bad pat hs .

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    17/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    16

    0 5 10 15 20

    Depth

    0

    10

    20

    30

    40

    50

    60

    7

    Number

    ofNodes

    No pruning

    8th iteration

    1st iteration

    Figure 3.2.9 Time Trace Representation in Node Count (IDA* Search with Manhattandistance) One insta nce of a t ime tra ce of node count using ID A* sear ch on the E ight P uzzle.

    Figur e 3.2.10 is an other exam ple from the puzzle wit h a different h function. In

    th is ca se, the left-ha nd side of the envelope of the t ime tra ce follow s exactly t he

    exponentia l no-pruning curve, w hich m eans the a lgorithm expa nded a ll nodes a t each

    level wit hout pruning. From compar ison w ith t he previous f igures, this gra ph a lso

    shows this search includes more breadth-first components than the previous search

    a lgorithm, a s t he envelope of the curve grows fast er vertica lly tha n h orizont a lly

    (compa re with figur e 3.2.9). This mean s tha t t he h function is not helping very much by

    pruning nodes, an d a s a result , sea rch ca nnot go deeper int o the search tree until i t

    expands ma ny more nodes at sha llower depths.

    5 10 15 20

    Depth

    0

    250

    500

    750

    1000

    1250

    1500

    75

    NumberofNodes

    No pruning13rd iteration

    1st iteration

    Figure 3.2.10 Time Trace Representation in Node Count (IDA* Search with final

    position count) Another insta nce of a t ime tra ce in node count usin g ID A* search on theEight P uzzle. Note tha t the scale of the Y-axis is much bigger than in th e previous tw o figures.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    18/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    17

    4. Visualization of Heuristics

    4.1 Depth-Heuristic Function Representations

    When heurist ic functions a re used for sea rch, visualiza tions of th e sea rch give us

    ma ny useful ideas a bout how to evalua te them. In ma ny cases, we don't ha veth eoretica l expecta tions for heuristic functions. We need to determine how w ell th ey

    perform empirically, for w hich we can r ely on visua lizat ions of them.

    The depth -heur i sti c fun cti on repr esent ati onis shown in th e rest of this

    subsection. Figure 4.1.1 wa s ma de from a history of search in solving the E ight P uzzle

    problem. This figure is from one par ticula r sea rch. The X-a xis represents h-value

    (estima ted h-va lue) given the current s ta te, th e Y-a xis shows th e depth of th e curr ent

    sta te from th e initia l sta te, and t he gray level at each point represents t he number of

    sta tes a t t ha t level. The positions colored in black signify tha t no such st a te exists in

    the search space. White sta nds for ma ny nodes15. In this f igure, th e h function was

    used only t o evalua te each st a te; i t w a sn't used during sear ch to prune successor nodes.Thus t his figure represent s th e structu re of the ent ire sea rch spa ce from the view of th e

    h function. For example, the h-va lue of the initia l condition wa s 16. Then tw o nodes at

    h-va lues 15 an d 17 a nd level 2 a re expand ed, next h-va lues 14, 16, an d 18 at level 3,

    a nd so forth 16. From th is figure, we can observe th a t t he number of successor nodes

    increases as t he sea rch progresses. In pa rticular, a h uge number of nodes ha ve h-

    values a round 17 (wh ite place at h= 17, level= 12). The nodes distribut e almost

    symmetrically with th e center at h = 16.

    In t he actual IDA* search tha t uses this h function, nodes are sea rched in order

    of sma ller (h+ g)-value17. Figure 4.1.2 is a visua lizat ion of sear ch order using th e sa me

    h function as in 4.1.1. Whit e diagona l arr ows from the bott om right to top left show

    groups of nodes w hich ha ve the sa me ( h+ g)-va lue. In th e first itera tion of ID A*search, the nodes on t he leftmost a rrow a re sea rched, because they ha ve the same

    ( h+ g)-va lue as th e init ia l threshold (16). In t he second itera tion, the th reshold valueis set t o 18 and nodes on the second leftmost a rrow a re also sea rched, a long w ith t he

    nodes on the leftmost a rrow. In ea ch iterat ion of IDA* search, the search horizon

    progresses one arrow toward the left, as more nodes are searched at deeper levels.

    15 It is possible to use a 3D gr aph t ha t shows t he number of nodes on the Z-axis (instead of a 2D gra y scale

    gra ph). The gray sca le representa tion is chosen for its intuitiveness of representat ion. In th is figure, gra y

    level is determined by th e number of nodes at ea ch stat e and plotted on a logarit hmic scale. (While the

    most frequent st at e has more tha n 20,000 nodes, it is pra ctically impossible for human s to distinguish more

    tha n 10 gra y levels simulta neously.)16 In t his h-ha t-function, the h-ha t-value of the next sta te is one plus or one minus t he current h -ha t-value.

    As the result of this property, the depth h -ha t-function representa tion ha s a checkerboard a ppear an ce.17 In t his example, the depth from th e root node wa s used as t he g-value for ID A* search.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    19/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    18

    0 5 10 15 20

    0

    2

    4

    6

    8

    10

    12

    H-hat-value

    Depth

    Figure 4.1.1 Example of Depth-Heuristic Function Visualization This figure is ma defrom one instan ce of search on the E ight P uzzle by using the Manha t ta n dis tance with t he

    blank space as h funct ion. The X- a nd Y-a xes represent h -value and depth respectively. Ea chsqua re in this plane represents the sta te corresponding to the values on the X-axis a nd th e Y-

    axis . For example, the square next to the top r ight corner shows t he s ta te t hat has h = 22 a t

    depth= 12. The gray t one in each area r epresents the number of nodes a t t hat s ta t e

    (black=none, white= man y).

    0 5 10 15 20

    0

    2

    4

    6

    8

    10

    12

    H-hat-value

    Depth

    Figure 4.1.2 Search order of Figure 4.1.1White ar rows in this figure show sta tes which

    have same (h + g )-value. In th e IDA* search algorith m, thresholds are set in each iterat ion,

    then sea rch is done up to the threshold value. The search progresses from the leftmost arr ow

    to right a rrows in successive itera tions.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    20/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    19

    Figur e 4.1.3 is th e sam e search a s in figures 4.1.1 a nd 4.1.2 but t he plot sh ows

    only a ctua lly sea rched nodes by using t he h function for prun ing 18. The pat h tha t

    reached the f irst solution is shown by a ja gged white a rrow run ning from bott om right

    to top left . In th is example, tw o a ctions tha t increa sed the h -va lue were needed to

    reach the solution. These two actions are represented by the ja gged pa rts of the a rrow,

    a nd correspond to thr ee itera tions in ID A* sea rch wit h t hreshold va lues 16, 18, an d 20.In I DA* search, the t hreshold value w a s set t o 16 first beca use the h-va lue of th e initia l

    condit ion is 16. The successors th a t ha d bigger ( h+ g)-va lues were not expan ded in th e

    first search iterat ion. Only nodes on t he diagonal l ine from h = 16 (nodes h = 15/d= 1 a nd

    h= 14/d= 2) w ere sear ched in the first itera tion. In t he second itera tion, the thr eshold

    wa s set to 18 a nd ID A* sea rched to the nodes on th e next dia gona l l ine. In t he third

    iterat ion, the goa l node wa s found a t d= 20 a nd h = 0.

    H-hat-value

    Dep

    th

    0 5 10 15 20

    0

    5

    10

    15

    20

    Figure 4.1.3 Example of Depth-Heuristic Function Visualization (from the Eight P uzzle,Man ha tt an dist an ce wit h blank space) The same insta nce of depth-heuristic function shown in

    figures 4.1.1 and 4.1.2, but nodes actua lly searched are shown in th is figure. Note tha t th e

    nodes in the upper right of figure 4.1.1 ar e pruned an d not sear ched. The wh ite ar row shows a

    pat h to one solution found in this sear ch.

    Note tha t t he nodes a bove the diagonal l ine have higher ( h+ g)-values th a n t heth reshold va lue of th e la st itera tion. The nodes shown a bove th e line w ere expand ed in

    th e la st it era tion of ID A* sea rch, wh ich recognized th a t t hese successors need not to be

    searched. In th is representa tion, we regard th ese nodes as searched, a nd they a re

    plott ed in the sa me figure beca use they w ere actua lly expanded.

    It is intuit ive to observe the progress of th e sea rch a s a seq uence of depth -

    heurist ic function representa tions. Figure 4.1.4 is genera ted from the sam e inst a nce of

    18 Note tha t t he scale of the Y-axis is different fr om figure 4.1.1 and 4.1.2, which ma kes the slope of the

    search horizon line different. The slopes would be the sa me if we plotted them on t he sam e scale.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    21/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    20

    th e IDA* sear ch show n in th e previous figures. Ea ch picture corresponds to one

    iterat ion of IDA* sea rch. In t he f irst i tera tion, in th e leftmost picture, only a sma ll

    port ion of th e spa ce is sea rched. In t he second itera tion, the algorith m is allow ed to

    sear ch the next dia gonal line shown in figure 4.1.2 but does not rea ch the goa l. The goa l

    is reached in th e third i tera tion, shown in the rightm ost picture.

    Figure 4.1.4 Time Trace of Depth-Heuristic Function Visualization Ea ch figure is asna pshot of an it erat ion of IDA* search in th e depth-heuristic function representa tion. The

    leftmost figure is from the first itera tion, the center from the second, the right from the third.

    We ca n rega rd figure 4.1.1 a s a s ear ch space representa tion from the view of th e

    heurist ic function used for th is problem solving, a nd figur e 4.1.3 as t he result of

    pruning . The checkerboard pa tt ern shown in these pictu res results from the heuristic

    function used t o map th e sta te in t he problem space into heuristic values. Other

    heuristic functions ma y ma p sta tes in the search space into different va lues, an d th us

    into different pat terns in depth-heuristic function representa tion. In other w ords, this

    representa tion reflects both the st ructure of the sear ch space an d t he heuristic function.Figure 4.1.5 is another example from E ight P uzzle search, using th e sam e initial

    condit ion but a slightly different h euristic function19 to estima te the dista nce to the goa l

    sta te. The sea rch spa ce ha s basica lly the sam e shape as wit h the previous h function,

    but because t he values of successor sta tes can be minus tw o, zero or plus t w o from the

    values of the current sta te, h can h a ve only even va lues a nd t he sta te space becomes

    evenly spa ced vert ica l lines.

    19 In t his example, the h-hat funct ion used ma nhat ta n dis ta nce but didn't include the blank space in the

    count.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    22/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    21

    H-hat-value

    Depth

    0 5 10 15 20 25

    0

    2

    4

    6

    8

    10

    12

    Figure 4.1.5 Example of Depth-Heuristic Function Visualization (from the Eight P uzzle,Man ha tt an d ista nce without the blan k space) All of the nodes up to depth= 12 in the search

    tree are shown. The shape of the distribut ion of nodes is an inverted tria ngle similar theprevious search. The striping is a product of the h function used.

    Figure 4.1.6 shows nodes a ctually sea rched w ith the h euristic function sh own in

    figur e 4.1.5. This figur e corr esponds to figur e 4.1.3. The pat h to rea ch the first solut ion

    is shown by the white diagonal arrow.

    H-hat-value

    Depth

    0 5 10 15 20

    0

    5

    10

    15

    20

    Figure 4.1.6 Example of Depth-Heuristic Function Visualization (from the Eight P uzzle,Man ha tt an dista nce wit hout the blank space) This figure shows the nodes actually expanded

    in the search, which uses the h function shown in figure 4.1.5 for pruning.

    B y compa ring figure 4.1.3 a nd 4.1.6, we can observe th a t t he searched pa th in

    figure 4.1.6 is much wider th a n in figure 4.1.3. In t he ideal ca se, a n h function should

    return t he exact estima tion of the dista nce to the goa l. Thus th e pa th t o the goal should

    be a st ra ight l ine from t he bott om right to the t op left corner, meaning t he a rea

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    23/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    22

    searched is minimal. The bett er th eh fun cti on, th e nar r ower th e ar ea shown i n t hese

    fi gur es, in gener al . In f igure 4.1.6, ten a ctions t ha t increase h values ar e needed to

    reach th e goa l sta te. These actions a re represented byvertical a nd right -lea ning line

    segments in t he whit e arr ow. The goa l wa s found in t he eighth iterat ion of IDA* sea rch

    with this h function. Also th e number of nodes searched w ith t his function is a bout

    tw ice as ma ny a s with t he previous h function (figure 4.1.3).

    An a nima ted represent a tion of this sear ch, corresponding t o figure 4.1.4, is

    shown in figure 4.1.7. As it took eight itera tions to rea ch the goa l with t his h function,

    th ere a re eight pictur es in th is figure. The first itera tion is show n in the top left corner,

    th e second in t he top second left, a nd so on.

    Figure 4.1.7 Time Trace of Depth-Heuristic Function Visualization (from the Eight P uz-zle, Man ha tt an dist an ce wit hout the blank space) The same representat ion as figure 4.1.4 but

    wit h a different sear ch algorithm. These figures are ordered from left to right an d top to bottom.

    As th e sea rch progresses, the frontier of th e sea rch moves towa rd t he top left

    corner, while at the sa me time, the tra ce becomes wider. P rogress is significa nt in t he

    last t wo i terat ions , suggest ing tha t t he h function w orks better a t deeper levels tha n in

    sha llow levels.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    24/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    23

    5. Time Series Representations

    5.1 Time Domain Representations

    When w e record search depth a s th e history of sear ch, we ca n observe the beha v-

    ior of search in the t ime doma in, and w e ca n a pply time domain a na lysis techniques.

    Figur e 5.1.1 is an exa mple from a time t ra ce of genera l depth-first sea rch. The

    X-a xis is th e order of sea rch, wh ich corresponds t o time if we a ssume const a nt t ime to

    expa nd ea ch node. The Y-a xis is the depth of the sea rched node. In t his exa mple, th e

    a lgorithm searched down to depth = 7 and continued visiting nodes at depth 6 and 7

    several hundred times. B ig spikes in this representa tion mea n big backtra cks. For

    example, a ba cktra ck from depth 7 to depth 3 ha ppened at t ime 130. Time 0 th rough

    time 130 corresponds t o a sear ch of one bra nch from level 3 if th e sear ch is done in

    depth-first order.

    In the t ime tra ce of pure depth-first search, th e dista nce between points in the

    series at one level represent s time t o determ ine one subtr ee below th a t level.

    Depth

    Time

    Figure 5.1.1 Time Trace of Depth-first Search The X- an d Y- axes represent t ime a nd t he

    depth visited at tha t t ime. In depth-first search, algorithm picks up one branch an d tries to

    visit the deepest level of the bra nch first , then goes back and forth a t th e deeper levels. The

    big spikes in this representa tion signifies the termina tion of searching a subtr ee, wit h a la rge

    backtra ck to the next subtree.

    I t is ea sy to see a t w hich levels the a lgorithms spent t ime. For example, figure

    5.1.2 represents t he time tr a ce of brea dt h-first sea rch on t he sa me search spa ce a s in

    figure 5.1.1. B rea dt h-first sear ch visits all nodes a t sha llow er levels first . The time

    spent a t a level is proportiona l to th e number of nodes a t tha t level, so the sha pe of th e

    time trace is completely different between depth-first search and breadth-first search.

    Depth-first a lgorithms h a ve spiky time tra ces a nd breadt h-first a lgorithms m a ke stairs.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    25/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    24

    Time

    D

    epth

    Figure 5.1.2 Time Trace of Breadth-first Search

    However, it is n ot so easy t o f ind pa tt erns in time tr a ces for a lgorithms other

    th a n pure brea dt h-first sea rch and depth -first sear ch. For exa mple, figure 5.1.3 is th e

    time tr a ce of ID A* sea rch for th e problem discussed in the previous sections. It is very

    ha rd t o tell much from th is f igure.

    0 50 100 150 200 250 300

    5

    10

    15

    20

    5

    Figure 5.1.3 Time Trace of IDA* Search on Eight Puzzle

    From the time tra ce of search a lgorithms w e ca n get: 1) a rough idea of the

    beha vior of the sear ch a lgorith ms; it is especially useful for pure depth -first sea rch or

    bread th -first sea rch, a nd 2) some idea of th e frequency component s of time t ra ce; this is

    needed for th e design of a smooth ing filter (described t he following section).

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    26/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    25

    5.2 Frequency Domain

    Time domain a na lysis is stra ightforwa rd a nd very intu itive. Although it cann ot

    distinguish tw o similar a lgorithms in deta il , i t is useful to see the search depth h istory.

    As t he next step, we can a pply fourier t ra nsforms t o view t he time tr a ce of sea rch

    a lgorithms in t he frequency doma in. B y converting a sequence from th e time doma in

    into the frequency doma in, we can observe itera tive actions in th e search a lgorithms

    more clea rly. For exa mple, visiting a n ode a t depth 5, expa nding t hree child nodes a t

    depth 6 and then r eturning t o a node at depth 5 corresponds a n itera tion of interval 4.

    If t his ha ppens often, it ca n produce a st rong frequency component a t fr equency 1/4 Hz.

    Frequ ency components represent ba cktra cking in sear ch. In genera l, low frequency

    components represent large backtracks, which are likely to occur when returning to a

    sha llow level of th e sear ch tree, a nd h igh frequ ency component s come from minor

    backtracking at deeper levels.

    It era tive components observed in th e frequency doma in can be ca used by

    intera ctions between the structure of the search space a nd search a lgorithms. For

    exa mple, th e time tr a ce of depth-first sea rch a nd brea dth -first sea rch can include

    completely different frequency components even w hen a pplied to exactly t he sa me

    search space. Thus, frequency a na lysis ca nnot separa te th e structure of the search

    space from chara cteristics of sear ch a lgorithms.

    In t his subsection, the bas is of the fourier tr a nsform is explained first. Then a

    smooth ing technique for pra ctical ana lysis is reviewed. To illustra te frequency a na lysis

    of search algorithms, we show frequency gra phs for th e Eight P uzzle a nd t he tra veling

    salesperson problem, w ith their int erpreta tions.

    5.2.1 Fourier TransformTh e four ier t r ansformis a common technique to tra nsform a function in t he time

    domain into the frequency doma in. The basic idea is to regard a n a rbitra ry w a ve form

    a s the ad dition of simple sine wa ves. The tra nsform decomposes the wa ve into sine

    wa ves, yielding the strength a nd pha se of ea ch decomposed sine wa ve. B y a dding all of

    th e decomposed sine wa ves, w e ca n reconst ruct t he origina l wa ve form. This is ca lled

    t he in ver se fouri er tr ansform.

    In the ca se wh ere the origina l function is continuous, th e following formula s a re

    a pplied t o ca lculat e the fourier t ra nsform a nd inverse fourier tra nsform.

    F ( ) = f t( ) e2it

    dt FourierTransfor

    f t( ) = F ( ) e2it

    d InverseFourierTransfor

    (5.2.1)

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    27/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    26

    If t he original fun ction is in d iscrete form, equa tions (5.2.2) a re used t o ca lculat e

    the fourier tra nsform a nd inverse fourier tra nsform. They ar e basica lly equivalent t o

    th e equa tions in (5.2.1) but a ssume a discrete number of wa ve forms.

    F j( ) =1

    N

    f t( ) e2ikj/T

    k=0

    N1

    FourierTransfor

    f k( ) = F j( ) e2ikj/Tj=0

    N1

    InverseFourierTransfor

    (5.2.2)

    Note tha t in t he case of th e discrete fourier tra nsform, th e highest frequency

    depends upon t he sam ple ra te of the original function. I f th e sampling ra te is 1 point

    per second, th e highest fr equency is 1/2Hz. For a sa mpling ra te of 10 point s per second,

    we can get a highest frequency of 5Hz 20.

    As we a re going to a pply the fourier tr a nsform to time tr a ces of search

    a lgorith ms, we need to use th e discrete fourier tr a nsform. Figur e 5.2.1 shows a

    frequency domain spectrum from the node-depth h istory of a depth-first sea rch.

    Index

    Strength

    Figure 5.2.1 Frequency Distribution of depth-first search in figure 5.1.1

    In t his frequency distr ibution gra ph, th e X-a xis represents frequ ency (or

    interval) a nd th e Y-a xis represents relat ive strength . B y simply a pplying equat ion

    (5.2.2) to t he discrete t ime series of sea rch, th e frequency components a re calcula ted a s

    complex num bers. In t his gra ph, the absolute values of each frequency component a recalculat ed f irst , t hen they a re sta nda rdized by dividing by th e maximum component

    va lue. Note also tha t t he zero frequency, which is referred t o a s D.C. level in electr ica l

    engineering, is omitted because it represents simply the average node depth.

    20 Sa mpling theory s ta tes tha t t he theoret ica l highest frequency is ha lf of the sam pling ra t e.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    28/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    27

    In t his example, 320 da ta point s ar e used for th e ca lcula tion. Thus 160 in th e X-

    a xis corr esponds t o 160/320 = 0.5 Hz or int erva l 2. Sim ila rly 107 in t he midd le of th e X-

    a xis corr esponds t o itera tions a bout in t erva l 320/107 = 3, 80 is from int erva l 320/80 = 4,

    a nd so on. Int erva l 4 is ca used by the itera tive sea rch of 3 child nodes. For exa mple,

    depth-first sear ch from a level 4 node follow ed by th ree lea f nodes, which is t he

    sequence of 4,5,5,5,4,5,5,5,. . . in th e time t ra ce, can cause fr equency components a t th einterval 4. In general in depth-first search, frequency components a t int erval i

    correspond to search on the node wh ich ha s i -1child nodes.

    As th is exa mple ca me from discrete numbers, th e oth er interva l component s

    betw een th ese va lues cann ot technica lly exist, th ough they ma y exist in practice. They

    a re called harmonicsa nd a re ca used by decomposing non-sine wa ves int o sine wa ves in

    the fourier tra nsform.

    The frequency distribut ion show n in figure 5.2.3 w a s genera ted from th e time

    tra ce of depth-first search on a fully ba lan ced t ree with b= 3. There is a big clear peak a t

    a bout 75, wh ich corr esponds t o inter va l 310/75 4 in this distribution. I f the searchtrees are ba lanced an d ha ve exactly th e same bra nching factors in each level, frequencydistributions t end to ha ve clea r peaks, though th ey sti l l have ha rmonics.

    Index

    Strength

    Figure 5.2.3 Frequency Distribution of Depth-first Search on a Fully Balanced Tree

    5.2.2 Smoothing Filter

    In t he fourier a na lysis of real sea rch histories, noise in th e origina l functionma kes a na lysis difficult. We can a pply a smoothing filter to th e frequency distribut ion

    to reduce noise and to make the distribution clear.

    Although w e ca n design a ny f i l ter in pra ctice, the most common is the mea n

    filter wit h a fixed wind ow size. It w orks as a low-pa ss (high-cut) filter beca use the noise

    is often in th e high ran ge of frequency distribut ions. E qua tion (5.2.3) is used as th e

    simple mean filter of window size 2.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    29/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    28

    MeanSmoothed a i( )[ ] =a i( ) + a i+1( )

    2(5.2.3)

    In general , th e mean smoothing f i l ter with window size wis described by t he

    follow ing formula :

    MeanSmoothed a i( ),w[ ] =1

    wa i( )

    k=iw/2

    i+w/2

    (5.2.4)

    Note here tha t a pplying a mean fi lter w ith w indow size 2 twice to a function f is

    equivalent t o applying a qua rter-ha lf-qua rter f i l ter to th e function fonce.

    We ca n a lso design a high-pa ss filter or other filters, but for smooth ing purposes,

    only low -pas s filters ma ke sense.21 We should look for the filter t ha t m ost clea rly

    reveals t he frequency components.

    I t is importa nt tha t smoothing f i lters not be applied to time domain da ta (beforefourier tra nsform), but ra ther t o the frequency doma in (a fter fourier tra nsform). I f

    a pplied to the time doma in, a filter reduces high frequency components of the origina l

    w a ve form. As a result , the frequency distr ibution would be different from th e original

    form. Applying a low pa ss filter to the time domain is equivalent t o ignoring the high

    frequencies in th e frequency domain. B eca use we are interested in tr end in the

    frequency domain, we should apply the smoothing filter to the frequency distribution.

    The following gra ph w a s generat ed by a pplying a mean smoothing f i lter four

    times to the frequency dist ribution shown in figure 5.2.1. Note tha t spikes in the

    unsmooth ed distribution ha ve been reduced by smoothing so tha t pa tt erns in th e

    frequency spectr um become clear er. To get a n idea w hich frequency component s rea llydo exist a nd w hich do not, w e need to check the figures from the time doma in.

    B y smoothing, frequency components a t intervals 3 a nd 4, located a t index 107

    a nd 80 respectively, ha ve been enha nced. How ever, it is still difficult t o distin guish

    other components betw een these levels th a t a re ca used by ha rmonics of low fr equency

    components.

    Note here tha t the smoothing f i lter must be designed so tha t i t doesn't f i lter out

    components w hich interest us. Thus designing t hese filters requires knowledge of the

    frequency components t ha t sh ould exist in t he observa tions. We need to check the time

    tra ce of the search f irst in order to get some idea wh ich pa rt of th e frequency

    components a re importa nt.

    21 We can use t he sam e fourier t echniqu e to check the freq uency response of any filter. This is th e most

    common usa ge of the fourier tra nsform in electrical eng ineering.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    30/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    29

    Index

    Strength

    Figure 5.2.3 Smoothed frequency distribution of depth-first search with mean filterA smoothing filter is a pplied to t he frequency dist ribution shown in figure 5.2.1. The smoothing

    filter can r educe spikes, revealing the m ain components of the distr ibution.

    5.2.3 Examples from Fourier Analysis of Search Algorithms

    A Simple Example of Fourier Transform on Search

    The following figure was generated from the history of a breadth-first search.

    We should see no ba cktra cking in t his tr a ce beca use th e algorithm s can s a ll nodes from

    sha llow er to deeper levels once a nd never visits t he sa me level a ga in. Therefore, there

    should be no frequency component s in the frequency doma in. In pra ctical applica tions

    of the fourier tra nsform, i t is assum ed tha t t he wa ve form is sampled from an infinite

    sequence, and furt hermore, tha t t he rest of the w a ve is exa ctly the sam e as t he observedpar t. This ass umpt ion causes us to find low frequency components even th ough the

    original function ha s no itera tive component s. As a result, the frequency distr ibution

    ha s only low fr equency component s, wh ich a re basica lly noise.

    This result should be contra sted t o the depth -first s ear ch shown in figure 5.2.5.

    Here, lots of backtr a cking cau ses high-frequency components in t he frequency doma in.

    Therefore, th e frequency dist ribut ion of depth-first sear ch includes more high frequen cy

    components than breadth-first search. In general, high frequency components

    correspond to ba cktra cking w ith a short period, which can only occur in t he low est levels

    of a s ear ch tree. Low frequency components correspond to long period ba cktra cking,

    w hich can occur betw een high levels of sear ch trees.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    31/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    30

    Index

    Strength

    Figure 5.2.4 Frequency Distribution of Breadth-first Search22 Only low frequencycomponents exit in this d istribution, w hich is called itera tive noise. (This phenomenon results

    from using a finite number of sam ple points.)

    Frequency Distribution of Combined SearchTo demonstr a te t he utility of the fourier tra nsform, th e figures in 5.2.5 a re

    creat ed from combined-sear ch algorithm s. The Br eat h-Depth a lgorith m, shown a s (A),

    uses brea dth -first search unt il it r eaches depth 4, then uses depth-first search. On th e

    contr a ry, t he Depth-B readt h a lgorithm in (B ) uses depth-first sea rch unt il level 4, a nd

    then u ses brea dth-first sear ch.

    50 100 150 200 250 300

    2

    3

    4

    5

    6

    7

    50 100 150 200 250 300

    2

    3

    4

    5

    6

    7

    Dept h Dept h

    Time Time

    (A) B rea dt h-Dept h S ea rch (B ) D ept h-B rea dt h S ea rch

    Figure 5.2.5 Time Trace of Breadth-Depth Search and Depth-Breadth Search Timetra ce of two combined search algorithm s. The Br eat h-Depth a lgorithm, shown a s (A), uses

    breadt h-first search until it reaches depth 4, then uses depth-first search. In contr ast , the

    Depth-Brea dth a lgorithm in (B) uses depth-first search unt il level 4, then bread th-first sear ch.

    22 A mean sm ooth filter wa s applied four times to generat e this graph.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    32/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    31

    In the t ime doma in, i t is dif f icult to compare t wo t ime tra ces of sea rch depth

    directly . Even th ough we ca n calcula te th e correlat ion of two time tra ces by cha nging

    th e offset of one curve, we n eed to compa re t his correla tion for each possibl e offsetin

    order to find th e best va lue. For exa mple, ima gine the case shown in figure 5.2.6. The

    sam e algorithm is used in tw o almost identical sear ch trees; one search tr ee has depth =

    4 (shown in A) a nd t he other a lso ha s depth = 4 but one extra bra nch at depth 2 (shownin B). B eca use of the extra bran ch, the time tra ce of the second search tree ha s a delay,

    thus w e will f ind the best correlation with a n unknown offset. As we don't ha ve any

    idea a bout t his offset va lue in general , we need to itera te this calculation man y times.

    This sit ua tion w ill become even more complicat ed w hen w e compare t ime tra ces from

    dissimilar trees.

    (A) (B)

    ?

    1,2,3,4,5,5,4,5,5,... 1,?,?,?,?,...,2,3,4,5,5,4,5,5,...

    offset identical with (A)

    SEARCHT

    REE

    TIME

    TRACE

    1

    3

    1

    2

    3

    4 4

    5 5

    Figure 5.2.6 Problem of the correlation of time traces (B ) ha s almost identical search

    tree with (A) but ha s an extra bra nch at level 2. As a result of this extra bra nch, the timetra ces must be offset to find the best correlation.

    Once time traces are converted into frequency distributions they are directly

    compa ra ble a ma jor benefit for t he use of frequency a na lysis.

    B y using th e frequency distribution representa tion we can easily discuss

    bread th -first a nd depth-first components of th ese tw o sear ch a lgorith ms. The

    distr ibutions a re shown in figure 5.2.7.

    The frequency dist ribut ion of Depth-B rea dt h sea rch show n in figur e 5.2.7(A) ha s

    strong spikes at the sa me pla ces a s th e pure depth-first search a lgorithms shown in

    figure 5.2.2. Thus w e ca n predict a simila rity betw een D epth-B readt h sea rch a nd puredepth-first sear ch. The frequency distribut ion of B rea dt h-Depth sea rch, shown a s figure

    5.2.7(B ), ha s only low frequency components a nd is simila r t o pure brea dt h-first sea rch

    shown in figur e 5.2.3.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    33/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    32

    0 25 50 75 100 125 150

    0.2

    0.4

    0.6

    0.8

    0 25 50 75 100 125 150

    0.2

    0.4

    0.6

    0.8

    1St rength St rength

    Index Index

    (A) B rea dt h-D ept h Sea rch (B ) D ept h-B rea dt h Sea rch

    Figure 5.2.7 Frequency Distributions of Breadth-Depth Search and Depth-BreadthSearch Frequencies included in th e Br eadt h-Depth sea rch in (A) include many more highfrequency components, which w ere generat ed by depth-first components. The distribut ion

    from the Depth-Brea dth sea rch in (B ) ha s only low components. These are basically n oisecaused by errors of tra nsformat ion and ha rmonics. This distribution is very similar to those

    produced by pure breadth -first search a lgorithms.

    Frequency Distribution of IDA* Search on Eight PuzzleAs a nother exa mple, the follow ing figures represent fourier tra nsforms of IDA*

    search on th e Eight P uzzle. A mean smoothing f il ter wa s applied four times in the

    frequency domain.

    0.00

    0.10

    0.20

    0.30

    0.40

    0.00 0.10 0.20 0.30 0.40 0.50

    Frequency

    Strength

    0.00

    0.10

    0.20

    0.30

    0.40

    0.00 0.10 0.20 0.30 0.40 0.50

    Frequency

    Strength

    Figure 5.2.8 Frequency Distribution of IDA* Search on the Eight Puzzle (A) wit hManha t ta n dis ta nce (B) with count f ina l posit ion

    Looking at th ese two figures w e ca n compar e the behavior of th e tw o heuristic

    functions. The frequency distribution from IDA* search w ith Ma nha tt a n dista nce (A)

    only includes lower frequencies, especially w hen compa red w ith fina l position count (B ).

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    34/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    33

    This indicat es less ba cktra cking in lower levels of th e tree. The sear ch works by going

    down t o the deeper levels, th en does a lit tle backtr a cking followed by a r etur n to higher

    levels. The heurist ic function helps by prunin g bad br a nches in early st a ges of the

    search, and a s a r esult , ma ny big ba cktra cking jumps are observed. On the contr a ry, in

    th e ca se of th e count fina l position function, shown in (B), th e frequency distribut ion

    includes relat ively ma ny high frequency component s. This mean s more backtra ckingoccurs in both high levels a nd low levels, from w hich we can conclude tha t t he heuristic

    function didn't help much to prune bra nches.

    Figur e 5.2.9 is th e frequency distribut ion of pure depth -first sea rch on the E ight

    P uzzle. The num ber of successors is either 1, 2, or 3 an d depends on the current sta te,

    th us the bra nching factor of th e puzzle is not const a nt . Therefore, the distribut ion is

    more sca tt ered t ha n t he distributions in f igure 5.2.8.

    0.00

    0.10

    0.20

    0.30

    0.40

    0.00 0.10 0.20 0.30 0.40 0.50

    Strength

    Frequency

    Figure 5.2.9 Frequency Distribution of Pure Depth-first Search on the Eight PuzzleThere ar e strong peaks a t bra nches of 3, 4 an d 5.

    5.3 Interval Counting Methods

    The interval count ing representa tion is an a lterna tive wa y to view the interva ls

    of wa ve forms. B eca use the fourier ana lysis of t ime tra ces ha s the problem of

    ha rmonics, we can not get a clear picture from fourier an a lysis without some knowledge

    a bout w hich frequencies to use in a smoothing f i l ter . In contr a st, th e int erval count ing

    method ca n be used with out a ny knowledge of frequencies. U sing numbers, this methodcombines the representation of sub-tree and branching factors from frequency analysis

    (th ough it only w orks if the sea rch is done in depth-first order).

    Suppose we ha ve a t ime tra ce of search depth in some algorithm shown a s f igure

    5.3.1. We can mea sure the interva ls betw een occurrences of th e sa me search depth. For

    exa mple, depth 4 appea rs four times in this search a nd t hese interva ls are 2, 1 a nd 1.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    35/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    34

    We ca n count the int ervals between different search depths a nd f i l l out a ta ble, as

    shown in t a ble 5.3.1.

    1 2 3 4 5 4 4 4 3 2 1tttt ++++

    Figure 5.3.1 Interval Counting Method The numbers on th e arr ow a re depths of nodesvisited. To calculat e the int erval for each level, it is necessary t o find the n ext occurrence of a

    node at t ha t level in the sequence, and count the n umber of nodes from the initia l occurrence to

    the next. For example, 2 is found a t t= 2 and t= 10, thus the interva l of 2 is 8.

    Table 5.3.1 Example of Interval Counting Table

    In t erva l D ept h = 1 D ept h = 2 D ept h = 3 D ept h = 4 D ept h = 5 D ept h = 6

    2 2

    3 1

    4

    5

    6

    7 1

    8

    9 1

    10

    In t he fourier tra nsform, the interva ls are count ed betw een a ll pa irs of the sa me

    depth, w hich makes it difficult to interpret periodicity in th eir beha viors. For exa mple,

    for d epth 4 in figure 5.3.1, we w ill find frequ ency components of interva l 2 (tw ice), 3

    (tw ice), 4 (once), an d 5 (once) from t he fourier tr a nsform . The only int erest ing freq uency

    components in t his list a re neighboring levels beca use we a re interest ed in the sma llest

    intervals a nd interva l 5 isn't one of the sma llest int ervals of depth 4 here. Only interval2 (tw ice) a nd 3 (once) should be count ed, a nd th e other component s sh ould be ignored,

    a s show n in figur e 5.3.2.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    36/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    35

    1 2 3 4 5 4 4 4 3 2 1tttt ++++

    2

    3

    45

    frequencycomponents

    for depth=4

    Figure 5.3.2 Frequency Components for depth=4 An an alogy to the fourier tra nsform isfound in interva l counting. In a fourier tra nsform, all combinat ions of the interva l shown in this

    figure would be counted, which would obscure ra ther t ha n reveal th e frequency components.

    The follow ing t w o figures a re examples of int erva l count ing from depth -first

    search a nd breadt h-first search, graphed a s thr ee-dimensional bar -plots. In t hese

    figures, the X-a xis represent s th e interva l, the Y-a xis represent s th e level and th e Z-a xis

    represents frequency of a ppea ra nces in the histories of the sear ch. Note th a t aloga rith mic function wa s applied to frequencies to ma ke sma ll components visible on

    the sa me sca le with t he bigger values, wh ich a re of dif ferent ma gnitude.

    5

    10

    15

    20

    2

    4

    6

    0

    2

    4

    5

    10

    15

    2

    4

    6

    0

    2

    4

    5

    10

    15

    20

    2

    4

    6

    0

    2

    4

    5

    10

    15

    2

    4

    6

    0

    2

    4

    Level

    Interval

    Frequency

    Level

    Interval

    Frequency

    (a) Depth-first Search (b) Breadth-first Search

    Figure 5.3.3 Three Dimensional Bar Plot of (a) Depth-first Search, (b) Breadth-firstSearch in a randomly pruned tree In th ese gra phs, only the counts w hich are less than 20interva ls are shown . There are lots of long interval components in t he depth-first sear ch

    shown a s (a).23 On the contra ry, in the brea dth-first sea rch gra ph, only components which

    ha ve an int erval of 2 exist .

    23 Note tha t counts sma ller than d epth 3 in depth-first search ha ve very big interva l s and a re located in

    the fa r right positions of this plot.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    37/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    36

    In d epth-first search, the interva l a t a certa in level represents t he number of

    nodes below t ha t d epth. For exam ple, if we observe level 2 follow ed by 30 lower levels,

    a nd then level 2 a ga in, tha t mean s the bra nch has 30 nodes total . In th e interval

    count ing method, this is counted at level = 2 a nd interva l = 31. Similarly , the

    observation of level = dand interval = isuggest s th e exista nce of one subtree at level d

    which ha s i -1nodes in the subtree. I f the tree is bala nced, we ca n expect t ha t t he totalnu mber of nodes below level i is b

    hi , where h is the height of the tree and b is the

    bra nching fa ctor of the subtr ee. It is a lso expected tha t w e will observe level = da nd

    interval = i, bi

    t imes in a fully balan ced tree with th e same pa ra meters.

    In brea dth-first search, we see no depth other th a n interva l 2 using interval

    count ing because brea dt h-first s ear ch progresses level by level, yielding only int erva ls of

    2. In t his gra ph, the heights of bars of interva l 2 represent exactly the sa me number of

    nodes at each level.

    The follow ing figures show int erva l counting of th e time tra ces for the sear ch

    a lgorith ms d escribed in section 5.1.

    B rea dt h-Depth -first sea rch in figure 5.3.4(a ) uses bread th -first sea rch down t o

    level 3, and t hen sw itches to depth-first sea rch. Thus t he interva l counting gra ph

    becomes exa ctly th e sa me gra ph a s depth -first sea rch below level 3. Above level 2 it is

    the sa me as breadt h-first search an d ha s one bar a t level 2 a nd interva l 2.

    5

    10

    15

    20

    2

    4

    6

    0

    2

    4

    5

    10

    15

    2

    4

    6

    0

    2

    4

    5

    10

    15

    20

    2

    4

    6

    0

    2

    4

    5

    10

    15

    2

    4

    6

    0

    2

    4

    Level

    Interval

    Frequency

    Level

    Interval

    Frequency

    (a) Breadth-Depth-first Search (b) Depth-Breadth-first Search

    Figure 5.3.4 Three Dimensional Bar Plot of (a) Breadth-depth-first search, (b) Depth-breadth-first search in a randomly pruned tree

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    38/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    37

    On t he other ha nd, D epth-B rea dt h-first sea rch in figure 5.3.4(b) la cks the bar of

    breadth -first sea rch at int erval 2. I t ha s bars a t interva l 2 a bove level 3 instead , which

    represents bread th -first sear ch components. This mean s the search uses brea dt h-first

    search methods below level 3. Two sma ll ba rs in a bigger interval a rea w ere generat ed

    by counting t he sam e level of a different bra nch. These sma ll components a re regar ded

    a s ghost images a nd can be avoided by not count ing an interval in t he same level butdifferent bra nches.

    6. Summary of Representations of Search

    This section is represented by a summ a ry t a ble w hich is too la rge to include in

    th is post script file. It is, however, included in the ha rdcopy version of th is technical

    report which can be obtained via e-mail request, [email protected], or

    Ba rbara Suther land

    Computer Science Dept., Box 34610

    U niversity of Massa chusett s

    Amherst, MA 01003-4610

    (413) 545-3286

    7. Conclusions

    Theoretica l an a lysis techniques a re bett er tha n experimenta l ana lysis.

    Sometimes, i t is very diff icult to build t heoretica l models a nd a na lyze them w hen

    problems become complex, or heur istic functions a re used t o solve the problems. In th e

    a na lysis of search a lgorithms w ith h euristic functions, i t is very ha rd t o formalize the

    problem a nd t o solve it by theoretically even in a sma ll problem like th e Eight P uzzle.

    Visualizat ion t ools for t he search a lgorithms a re importa nt in these ca ses. They can

    also be applied to debugging search algorithms in practice.

    Time doma in a na lysis of search a lgorithms a re shown in thr ee forms:

    (a ) time tra ce to see at a glance the behavior of search

    (b) frequency domain to a na lyze iterative a ction of search a lgorithms

    (c) interva l counting t o decompose sea rch a lgorith ms int o depth a nd brea dt h

    components.

    Alth ough th ese tools cann ot be directly a pplied to ar bitra ry ca ses, the effort to collect

    such tools an d to generalize th em is very importa nt . We need to continue developing

    such tools as part of the st udy of algorith ms.

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    39/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    38

    A. Search Algorithms used in Examples

    A.1 Pseudo code of Depth-first, Breadth-first and Best-first Search

    / * Gener al Search Funct i onsear ches a t r ee def i ned by node_l i st and f unct i on successor( ) i n t heor der of st r at egy( ) f uncti on */gener al _sear ch( node_l i st , st r at egy){

    / * Check i f t here i s a node */i f ( empt y( node_l i st ) )

    r et urn ( NOT_FOUND) ;

    cur r ent _node = f i r st ( node_l i st ) ;al t er nat i ve_nodes = r est ( node_l i st ) ;

    / * Check whether t he cur r ent node i s a goal */i f ( goal p( cur r ent _node) )

    r et ur n( cur r ent _node) ;

    / * Expand successor nodes */successor _node = successor s( cur r ent _node) ;

    / * Re- cal cul at e sear ch orderst r ategy( ) f unct i on r eturns t he order of successor nodes */node_or der = st r ategy(al t ernat i ve_nodes, successor_node);

    / * Cal l sel f r ecur si vel y */r et ur n ( gener al _sear ch( node_or der , st r at egy)) ;

    }

    / * Depth- f i r st Search

    f unct i on dept h_f i r st per f or ms dept h- f i r st sear ch over t he t r ee def i nedby node_l i st and successor ( ) f unct i on*/

    ddddeeeepppptttt hhhh____ffffiiii rrrr sssstttt ( node_l i st){

    general _sear ch( node_l i st , *dept h_f i r st _or der( ) ) ;}dept h_f i rst _order( node_l i st, successor_l i st){

    r et urn(append( successor _l i st , node_l i st ) ) ;}

    / * Br eadth- f i r st Sear chf unct i on br eadt h_f i r st per f or ms br eadt h- f i r st sear ch over t he t r ee

    def i ned by node_l i st and successor( ) f unct i on*/bbbbrrrr eeeeaaaaddddtttt hhhh____ffffiiii rrrr sssstttt ( node_l i st){

    general _sear ch( node_l i st , *breadt h_f i r st _or der ( ) ) ;}breadt h_f i rst _order( node_l i st, successor_l i st){

    r et urn(append( node_l i st , successor_l i st ) ) ;}

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    40/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    39

    / * Best- f i rst Searchf unct i on best _f i r st per f or ms best - f i r st sear ch over t he t r ee def i nedby node_l i st and successor ( ) f unct i on

    */bbbbeeeesssstttt____ffffiiii rrrr sssstttt ( node_l i st)

    {general _search( node_l i st, *best_f i rst _order( ) ) ;

    }best_f i rst _order( node_l i st, successor_l i st){

    return( sort _by_pri or i t y( append( node_l i st, successor_l i st) ) ) ;}

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    41/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    40

    A.2 Pseudo code of A* Search

    / *f unct i on A* per f orms A* search over t he t r ee def i ned by node_l i st andsuccessor ( ) f uncti on*/

    aaaa****(((( nnnnooooddddeeee____llll iiii sssstttt )))){

    / * Check i f t here i s a node */i f ( empt y( node_l i st ) )

    r et urn ( NOT_FOUND) ;

    cur r ent _node = f i r st ( node_l i st ) ;al t er nat i ve_nodes = r est ( node_l i st ) ;

    / * Check whether t he cur r ent node i s a goal */i f ( goal p( cur r ent _node) )

    r et ur n( cur r ent _node) ;

    / * Expand successor nodes */successor _node = successor s( cur r ent _node) ;al l _successor s = append( al t ernat i ve_nodes, successor_node);

    / * Re- cal cul at e sear ch order */node_or der = sor t ( al l _successor s, f ( $node) ) ;

    / * Cal l sel f r ecur si vel y */r et ur n (a*( node_order ) ) ;

    }

    ffff(((( nnnnooooddddeeee)))){

    r eturn (g( node) + h(node)) ;}

    gggg(((( nnnnooooddddeeee)))){

    / * use dept h f r om r oot as f val ue */r eturn dept h(node) ;

    }/ * Heuri st i c Funct i on */hhhh(((( nnnnooooddddeeee)))){

    r eturn manhat t an_di st ance(node) ;}

  • 7/30/2019 MM-Visualization Tools for Real-Time Search Algorithms

    42/45

    Visual i zat i on Tool s for Real -t ime Sear ch Algor i thms Kuwata & Cohen

    41

    A.3 Pseudo code of IDA* Search

    / *f unct i on i da* perf orms i da* sear ch unt i l MAX_TH over t he t r ee def i nedby r oot _node and successor ( ) f unct i on*/iiii ddddaaaa****(((( rrrr ooooooootttt____nnnnooooddddeeee))))

    {/ * i ni t i al t hreshol d */t h = f ( r oot _node);

    / * i d sear ch */l oop {

    smal l est _f = +I NFI NI TY;t h = df i da*( r oot _node, t h) ;

    } unt i l ( goal p( t h) | | t h > MAX_TH) ;

    i f (goal p( t h) )return (th);

    el ser et urn ( NOT_FOUND) ;

    }

    / * Thi s gl obal v