Skip to content

planner_study.ms_bench

ms_bench

Rigorous SINGLE-AGENT planner path benchmark: for each MAP TYPE, sweep many seeds (map instances), compute %Success / %Optimal PER instance, report mean +/- std across seeds. Upper bound = BFS teacher, lower bound = naive Manhattan. Plan & execute on the full map (clean path-optimality test).

eval_instance

eval_instance(Vfn, wall, goals, nstart, rs)

return (succ_frac, opt_frac, actacc) pooled over the goals of ONE map instance.

Source code in experiments/planner_study/ms_bench.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def eval_instance(Vfn, wall, goals, nstart, rs):
    """return (succ_frac, opt_frac, actacc) pooled over the goals of ONE map instance."""
    H,W=wall.shape; tot=succ=opt=acc=accn=0
    for g in goals:
        dstar=PV.bfs_dist(wall,g); V=Vfn(wall,g)
        reach=np.argwhere((dstar<(1<<30))&(~wall))
        reach=[tuple(x) for x in reach if tuple(x)!=g]
        if not reach: continue
        starts=[reach[i] for i in rs.choice(len(reach),size=min(nstart,len(reach)),replace=False)]
        cap=4*H*W
        for st in starts:
            tot+=1
            # action accuracy at this cell
            best=None;bv=-1e18
            for dr,dc in DIRS4:
                nr,nc=st[0]+dr,st[1]+dc
                if 0<=nr<H and 0<=nc<W and not wall[nr,nc] and V[nr,nc]>bv: bv=V[nr,nc];best=(nr,nc)
            accn+=1
            if best is not None and dstar[best]==dstar[st]-1: acc+=1
            reached,steps=PV.rollout(V,wall,st,g,cap)          # rollout returns (reached, steps)
            if reached:
                succ+=1
                if steps==int(dstar[st]): opt+=1
    t=max(tot,1)
    return succ/t, opt/t, acc/max(accn,1)