Sample Complexity of Learning Heuristic Functions for Greedy-Best-First and A* Search
Abstract
Greedy best-first search (GBFS) and A* search (A*) are popular algorithms for pathfinding on large graphs.
Both use so-called heuristic functions, which estimate how close a vertex is to the goal.
While heuristic functions have been handcrafted using domain knowledge, recent studies demonstrate that learning heuristic functions from data is effective in many applications.
Motivated by this emerging approach, we study the sample complexity of learning heuristic functions for GBFS and A*.
We build on a recent framework called data-driven algorithm design and evaluate the pseudo-dimension of a class of utility functions that measure the performance of parameterized algorithms.
Assuming that a vertex set of size n is fixed, we present
O( n lg n ) and O( n 2 lg n ) upper bounds on the pseudo-dimensions for GBFS and
A*, respectively, parameterized by heuristic function values.
The upper bound for
A* can be improved to O( n 2 lg d ) if every vertex has a degree of at most d and to O( n lg n ) if edge weights are integers bounded by poly( n ) .
We also give Ω( n ) lower bounds for GBFS and A*, which imply that our bounds for GBFS and A* under the integer-weight condition are tight up to a lg n factor.
Finally, we discuss a case where the performance of A* is measured by the suboptimality and show that we can sometimes obtain a better guarantee by combining a parameter-dependent worst-case bound with a sample complexity bound.
Introduction
Given a graph with a start vertex s , a goal vertex t , and non-negative edge weights, we consider finding an s – t path with a small total weight.
The Dijkstra algorithm [16] finds an optimal path by exploring all vertices that are as close to s as t .
It, however, is sometimes impractical for large graphs since exploring all such vertices is too costly.
Heuristic search algorithms are used to address such situations; among them, greedy best-first search (GBFS) [17] and A* search (A*) [24] are two popular algorithms.
Both GBFS and A* use so-called heuristic functions, which estimate how close an input vertex is to t .
GBFS/A* attempts to avoid redundant exploration by scoring vertices based on heuristic function values and iteratively expanding vertices with the smallest score.
If well-suited heuristic functions are available, GBFS/A* can run much faster than the Dijkstra algorithm.
Furthermore, if
A* uses an admissible heuristic function, i.e., it never overestimates the shortest-path distance to t , it always finds an optimal path [24].
Traditionally, heuristic functions have been made based on domain knowledge; e.g., if graphs are road networks, the Euclidean distance gives an admissible heuristic.
When applying GBFS/A* to various real-world problems, a laborious process is to handcraft heuristic functions.
Learning heuristic functions from data can be a promising approach to overcoming the obstacle due to the recent development of technologies for collecting graph data.
Researchers have demonstrated the effectiveness of this approach in robotics [11, 32, 28, 36], computational organic chemistry [13], and pedestrian trajectory prediction [36].
With learned heuristic functions, however, 36th Conference on Neural Information Processing Systems (NeurIPS 2022).
obtaining theoretical guarantees is difficult since we can hardly understand how the search can be guided by such heuristic functions.
(A recent paper [1] studies learning of admissible heuristics for
A*, but the optimality is confirmed only empirically.)
Moreover, learned heuristic functions may be overfitting to problem instances at hand.
That is, even if GBFS/A* with learned heuristic functions perform well over training instances, they may deliver poor future performance.
In summary, the emerging line of work on search algorithms with learned heuristic functions is awaiting a theoretical foundation for guaranteeing their performance in a data-driven manner.
Thus, a natural question is: how many sampled instances are needed to learn heuristic functions with generalization guarantees on the performance of resulting GBFS/A*?
1.1 Our contribution
We address the above question, assuming that path-finding instances defined on a fixed vertex set of size n are drawn i.i.d.
from an unknown distribution.
Our analysis is based on so-called data-driven algorithm design [22, 4], a PAC-learning framework for bounding the sample complexity of algorithm configuration.
In the analysis, the most crucial step is to evaluate the pseudo-dimension of a class of utility functions that measure the performance of parameterized algorithms.
We study the case where
GBFS/A* is parameterized by heuristic function values and make the following contributions:
Section 3 gives O( n lg n ) and O( n 2 lg n ) upper bounds on the pseudo-dimensions for GBFS and A*, respectively.
The bound for A* can be improved to O( n 2 lg d ) if every vertex has an at most d degree and to O( n lg n ) if edge weights are non-negative integers at most poly( n ) .
Section 4 presents Ω( n ) lower bounds on the pseudo-dimensions for GBFS and A*.
We prove this result by constructing Ω( n ) instances with unweighted graphs.
Thus, our bounds for GBFS and A* under the integer edge-weight condition are tight up to a lg n factor.
Section 5 studies a particular case of bounding the suboptimality of A*.
We show that we can sometimes improve the guarantee obtained in Section 3 by using an alternative O( n lg n ) bound on the pseudo-dimension of a class of parameter-dependent worst-case bounds [34].
An important consequence of the above results is the tightness up to a lg n factor for GBFS and A* under the integer-weight assumption.
Note that this assumption holds in various realistic situations.
For example, the Internet network and state-space graphs of games are unweighted (unit-weight) graphs, and A* is often applied to path-finding instances on such graphs.
1.2 Related work
Data-driven algorithm design.
Gupta and Roughgarden [22] proposed a PAC approach for bounding the sample complexity of algorithm configuration, which is called data-driven algorithm design and has been applied to a broad family of algorithms, including greedy, clustering, and sequence alignment algorithms.
We refer the reader to a nice survey [4].
A recent line of work [5, 9, 10] has extensively studied the sample complexity of configuring integer-programming methods, e.g., branch-and-bound and branch-and-cut.
In [9, 10], upper bounds on the pseudo-dimension for general tree search are presented, which are most closely related to our results.
Our upper bounds, which are obtained by using specific properties of GBFS/A*, are better than the previous bounds for general tree search, as detailed in Appendix A. Balcan et al.
[8] presented a general framework for evaluating the pseudo-dimension.
Their idea is to suppose that performance measures form a class of functions of algorithm parameters, called dual functions, and characterize its complexity based on how they are piecewise structured.
This idea plays a key role in the analysis of [9, 10], and our analysis of the upper bounds are also inspired by their idea.
Its application to our setting, however, requires a close look at the behavior of GBFS/A*.
Balcan et al.
[7] showed that approximating dual functions with simpler ones is useful for improving sample complexity bounds, which is similar to our idea in
Section 5.
A difference is that while they construct simpler functions with a dynamic programming algorithm, we can use a known worst-case bound on the suboptimality of best-first search [34].
Lower bounds on the pseudo-dimension for graph-search algorithms have not been well studied.
Heuristic search with learning.
Eden et al.
[18] theoretically studied how the average-case running time of A* can be affected by the dimensions or bits of learned embeddings or labels of vertex features, based on which heuristic function values and computed.
The sample complexity of learning heuristic functions, however, has not been studied.
Preliminaries
We present the background on learning theory and our problem setting.
In what follows, we let I ( · ) be a boolean function that returns 1 if its argument is true and 0 otherwise.
We use H ⊆ R Y to denote a class of functions that map Y to R ⊆ R .
For any positive integer m , we let [ m ] = { 1 , . . .
, m } .
2.1 Background on learning theory
The following pseudo-dimension [29] is a fundamental notion for quantifying the complexity of a class of real-valued functions.
Definition 1.
Let H ⊆
R Y be a class of functions that map some domain Y to R .
We say a set { y 1 , . . .
, y N } ⊆
Y is shattered by H if there exist target values, t 1 , . . .
, t N ∈ R , such that
[Equation]
The pseudo-dimension of H , denoted by Pdim( H ) , is the size of a largest set shattered by H .
If H is a set of binary-valued functions that map Y to { 0 , 1 } , the pseudo-dimension of H coincides with the so-called VC-dimension [35], which is denoted by VCdim( H ) .
The following proposition enables us to obtain sample complexity bounds by evaluating the pseudodimension (see, e.g., [2, Theorem 19.2] and [27, Theorem 11.8]).
Proposition 1.
Let H > 0 , H ⊆
[0 , H ] Y , and D be a distribution over Y .
For any δ ∈ (0 , 1) , with a probability of at least 1 − δ over the i.i.d.
draw of { y 1 , . . .
, y N } ∼ D N , for all h ∈ H , it holds that (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)
N
N (cid:88) i = h
[Equation]
∼D
[Equation]
)] (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)
[Equation]
In other words, for any ϵ > 0 , N = Ω (cid:16) H 2 ϵ 2 (cid:0) Pdim( H ) lg Hϵ + lg 1 δ (cid:1)(cid:17) sampled instances are sufficient to ensure that with a probability of at least 1 − δ , for all h ∈ H , the difference between the empirical average and the expectation over an unknown distribution D is at most ϵ .
2.2 Problem formulation
We describe path-finding instances,
GBFS/A* algorithm, and performance measures considered in this paper.
Path-finding instances.
We consider solving randomly generated path-finding instances repetitively.
Let x = ( V, E, { w e } e ∈ E , s, t ) be a path-finding instance, where ( V, E ) is a simple directed graph with n vertices, { w e } e ∈ E is a set of non-negative edge weights (sometimes called costs), s ∈ V is a start vertex, and t ∈ V is a goal vertex.
We let Π be a class of possible instances.
Each instance x ∈ Π is drawn from an unknown distribution D over Π .
We impose the following assumption on Π .
Assumption 1.
For all x ∈ Π , the vertex set V and the goal node t are identical, and there always exists at least one directed path from s ̸ = t to t , i.e., every instance x ∈ Π is feasible.
Fixing V is necessary for evaluating the pseudo-dimension in terms of n = | V | .
Note that we can deal with the case where some instances in Π are defined on vertex subsets V ′ ⊆ V by removing edges adjacent to V \ V ′ .
The feasibility assumption is needed to ensure that GBFS/A* always returns a solution, and s
̸ = t simply rules out the trivial case where the empty set is optimal.
In Appendix B, we discuss how to extend our results to the case where t can change depending on instances.
Algorithm description.
We sketch algorithmic procedures that are common to both GBFS and
A* (see Algorithms 1 and 2 for details, respectively).
Let A ρ be a GBFS/A* algorithm, which is parameterized by heuristic function values ρ ∈ R n .
Given an instance x ∈ Π , A ρ starts from s and iteratively builds a set of candidate paths.
These paths are maintained by OPEN and CLOSED lists, together with pointers p ( · ) to parent vertices.
The OPEN list contains vertices to be explored, and the
CLOSED list consists of vertices that have been explored.
In each iteration, we select a vertex v from
OPEN , expand v , and move v from OPEN to CLOSED .
Heuristic function values ρ are used when selecting vertices.
For each v ∈ V , the corresponding entry in ρ , denoted by ρ v , represents an estimated shortest-path distance from v to t .
(Although heuristic function values are usually denoted by h ( v ) , we here use ρ v for convenience.)
In each iteration, we select a vertex with the smallest score , which is defined based on ρ as detailed later.
We impose the following assumption on the vertex selection step.
Assumption 2.
Define an arbitrary strict total order on V ; for example, we label elements in V by v 1 , . .
. , v n and define a total order v 1 < · · · < v n .
When selecting a vertex with the smallest score, we break ties, if any, in favor of the smallest vertex with respect to the total order.
If we allow A ρ to break ties arbitrarily, its behavior becomes too complex to obtain meaningful bounds on the pseudo-dimension.
Assumption 2 is a natural rule to exclude such troublesome cases.
Performance measure.
Let A ρ be GBFS/A* with parameters ρ ∈ R n .
We measure performance of A ρ on x ∈ Π with a utility function u .
We assume u to satisfy the following condition.
Assumption 3.
Let H > 0 .
A utility function u takes x and a series of all OPEN , CLOSED , and p ( · ) generated during the execution of A ρ on x ∈ Π as input, and returns a scalar value in [0 , H ] .
We sometimes use A ρ to represent the series of OPEN and CLOSED lists and pointers generated by A ρ .
Note that u meeting Assumption 3 can measure various kinds of performance.
For example, since the pointers indicate an s – t path returned by A ρ , u can represent its cost.
Moreover, since the series of
OPEN and CLOSED lists maintain all search states, u can represent the time and space complexity of
A ρ .
We let u ρ : Π → [0 , H ] denote the utility function that returns the performance of A ρ on any x ∈ Π , and define a class of such functions as U = { u ρ : Π → [0 , H ] | ρ ∈ R n } .
The upper bound,
H , is necessary to obtain sample complexity bounds with Proposition 1.
Setting such an upper bound is usual in practice.
For example, if u measures the running time, H represents a time-out deadline.
Generalization guarantees on performance.
Given the above setting, we want to learn ˆ ρ values that attain an optimal E x ∼D [ u ˆ ρ ( x )] value, where available information consists of sampled instances x 1 , . . .
, x N and u ρ ( x 1 ) , . . . , u ρ ( x N ) values for any ρ ∈ R n .
To obtain generalization guarantees on the performance of A ˆ ρ , we bound | 1 N (cid:80) Ni =1 u ρ ( x i ) − E x
∼D
[ u ρ ( x )] | uniformly for all ρ ∈ R n .
Note that the uniform bound offers performance guarantees that are independent of learning procedures, e.g., manual or automated (without being uniform, learned ˆ ρ may be overfitting sampled instances).
As in Proposition 1, to bound the sample complexity of learning ρ values, we need to evaluate the pseudo-dimension of U , denoted by Pdim( U ) , which is the main subject of this study.
Remarks on heuristic functions.
While we allow heuristic function values ρ to be any point in R n , the range of heuristic functions may be restricted to some subspace of R n .
Note that our upper bounds are applicable to such situations since restricting the space of possible ρ values does not increase Pdim( U ) .
Meanwhile, such restriction may be useful for improving the upper bounds on
Pdim( U ) ; exploring this direction is left for future work.
Also, our setting cannot deal with heuristic functions that take some instance-dependent features as input.
To study such cases, we need more analysis that is specific to heuristic function models, which goes beyond the scope of this paper.
Thus, we leave this for future work.
Note that our setting still includes important heuristic function models on fixed vertex sets.
For example, we can set ρ using learned distances to landmarks [21], or we can let ρ be distances measured on some metric space by learning metric embeddings of vertices [37].
Upper bounds on the pseudo-dimension
We present details of GBFS and A* and upper bounds on the pseudo-dimensions of U .
In this section, we suppose that vertices in V are labeled by v 1 , . .
, v n as in Assumption 2.
3.1 Greedy best-first search
Algorithm 1 shows the details of GBFS A ρ with heuristic function values ρ ∈ R n .
When selecting vertices in Step 3, the scores are determined only by ρ .
This implies an obvious but important fact.
Lemma 1.
Let ρ , ρ ′ ∈ R n be a pair of heuristic function values with an identical total order up to ties on their entries, i.e., I ( ρ v i ≤ ρ v j ) =
I ( ρ ′ v i ≤ ρ ′ v j ) for all i, j ∈ [ n ] such that i < j .
Then, we have u ρ ( x ) =
u
ρ ′ ( x ) for all x ∈ Π .
1: OPEN = { s } , CLOSED = ∅ , and p ( s ) =
None .
2: while OPEN is not empty : 3: v ← argmin { ρ v ′ | v ′ ∈ OPEN } .
4: for each child c of v : 5: if c = t : 6: return s – t path by tracing pointers p ( · ) , where p ( t ) = v .
7: if c / ∈ OPEN ∪ CLOSED : 8: p ( c ) ← v and OPEN ← OPEN ∪ { c } .
Move v from OPEN to CLOSED .
Algorithm 2 A* with heuristic function values ρ 1: OPEN = { s } , CLOSED = ∅ , p ( s ) =
None , and g s = 0 .
2: while OPEN is not empty : 3: v ← argmin { g v ′
+
ρ v v
∈
4: if v t : 5: return s t path by tracing pointers p (
6: for each child c of v : 7: g new ← g v + w ( v,c ) .
8: if c / ∈ OPEN ∪ CLOSED : 9: g c ← g new , p ( c ) ← v , and OPEN ← OPEN ∪ { c } .
10: else if c ∈ OPEN and g new <
g c : 11: g c ← g new and p ( c ) ← v .
12: else if c ∈ CLOSED and g new < g c : ▷ Steps 12–14 are for reopening.
13: g c ← g new and p ( c ) ← v .
Move c from CLOSED to OPEN .
Move v from OPEN to CLOSED .
Proof.
For any x ∈ Π , if ρ and ρ ′ have an identical strict total order on their entries, vertices selected in Step 3 are the same in each iteration of A ρ and A ρ ′ .
Since this is the only step ρ and ρ ′ can affect, we have A ρ =
A ρ ′ for all x ∈ Π , hence u ρ ( x ) =
u ρ ′ ( x ) .
Moreover, this holds even if ρ and/or ρ ′ have ties on their entries because of Assumption 2.
That is, the total order uniquely determines a vertex selected in Step 3 even in case of ties.
Therefore, the statement holds.
From Lemma 1, the behavior of GBFS is uniquely determined once a total order on { ρ v } v ∈ V is fixed.
Thus, for any x ∈ Π , the number of distinct u ρ ( x ) values is at most n ! , the number of permutations of { ρ v } v ∈ V .
This fact enables us to obtain an O( n lg n ) upper bound on the pseudo-dimension of U .
Theorem 1.
For GBFS A ρ with parameters ρ ∈ R n , it holds that Pdim( U ) =
O( n lg n ) .
Proof.
Lemma 1 implies that we can partition R n into n !
regions, P 1 , P 2 , . .
, so that for every P i , any pair of ρ , ρ ′ ∈ P i satisfies u ρ ( x ) =
u
ρ ′ ( x ) for all x ∈ Π .
Note that the construction of the regions, P 1 , P 2 , . .
. , does not depend on x .
Thus, given any N instances x 1 , . . .
, x N , even if ρ moves over whole R n , the number of distinct tuples of form ( u ρ ( x 1 ) , . . .
, u ρ ( x N )) is at most n ! .
To shatter
N instances, n ! ≥ 2 N must hold.
Solving this for the largest N yields Pdim( U )
=
O( n lg n ) .
3.2 A* search
Algorithm 2 is the details of A*.
As with GBFS, ρ only affects the vertex selection step (Step 3).
However, unlike GBFS, the scores, g v + ρ v , involve not only ρ but also { g v } v ∈ V .
Each g v is called a g -cost and maintains a cost of some path from s to v .
As in Algorithm 2, when v is expanded and a shorter path to c is found, whose cost is denoted by g new , we update the g c value.
Thus, each g v always gives an upper bound on the shortest-path distance from s to v .
For each v ∈ V , there are at most (cid:80) n −k =0 k ! ≤ ( n − 1)!
simple paths connecting s to v , and thus g v can take at most ( n − 1)!
distinct values.
We denote the set of those distinct values by G v , and define G V =
{ ( v, g v ) | v ∈ V, g v ∈ G v } as the set of all pairs of a vertex and its possible g -cost.
It holds that |G V | ≤ n × ( n − 1)!
= n ! .
Note that once x ∈ Π is fixed, G v for v ∈ V and G V are uniquely determined.
To emphasize this fact, we sometimes use notation with references to x : g v ( x ) , G v ( x ) , and G V ( x ) .
As with the case of
GBFS (Lemma 1), we can define a total order on the scores to determine the behavior of A* uniquely.
Lemma 2.
Fix any instance x ∈ Π .
Let ρ , ρ ′ ∈ R n be a pair of heuristic function values such that total orders on the sets of all possible scores, { g v ( x ) + ρ v | ( v, g v ( x ))
∈
G V ( x ) } and { g v ( x ) + ρ ′ v | ( v, g v ( x )) ∈
G V ( x ) } , are identical up to ties.
Then, it holds that u ρ ( x ) =
u ρ ′ ( x ) .
Proof.
If the two sets of scores have an identical strict total order, we select the same vertex in Stepin each iteration of A ρ and A ρ ′ .
Thus, we have A ρ =
A ρ ′ for any fixed x , implying u ρ ( x ) =
u ρ ′ ( x ) .
We show that this holds even in the presence of ties by using Assumption 2.
First, any two scores of the same vertices, g v ( x ) + ρ v and g ′ v ( x ) + ρ v , never have ties since G v consists of distinct g -costs.
Next, if g v i ( x ) + ρ
v
i
=
g
v j ( x ) + ρ v j holds for some i < j , we always prefer v i to v j in Step 3 due to Assumption 2.
Therefore, even in the presence of ties, we select a vertex in Step 3 as if the set of scores has a strict total order.
Thus, if ρ and ρ ′ induce the same total order up to ties on the sets of possible scores, it holds that u ρ ( x ) =
u ρ ′ ( x ) .
By using Lemma 2, we can obtain an O( n 2 lg n ) upper bound on the pseudo-dimension of U .
Theorem 2.
For A*
A ρ with parameters ρ ∈ R n , it holds that Pdim( U ) =
O( n 2 lg n ) .
Proof.
As with the proof of Theorem 1, we partition R n into some regions so that in each region, the behavior of A* is unique.
Unlike the case of GBFS, boundaries of such regions change over
N instances.
To deal with this situation, we use a geometric fact: for m ≥ n ≥ 1 , m hyperplanes partition R n into O((e m ) n ) regions.
Fix a tuple of any N instances ( x 1 , . . .
, x N ) .
We consider hyperplanes in R n of form g v i ( x k )
+ ρ
v i
= g v j ( x k )
+ ρ v j for all k ∈
[ N ] and all pairs of ( v i , g v i ( x k )) , ( v j , g v j ( x k ))
∈
G V such that i ̸
= j .
These hyperplanes partition R n into some regions, P 1 , P 2 , . .
, so that the following condition holds: for every P i , any ρ , ρ ′ ∈ P i have the same total order on { g v ( x k ) + ρ v
|
( v, g v ( x k ))
∈
G V ( x ) } and { g v ( x k ) + ρ ′ v | ( v, g v ( x k ))
∈
G V ( x k ) } up to ties for all k ∈ [ N ] , which implies u ρ ( x k )
=
u
ρ ′ ( x k ) for all k ∈ [ N ] due to Lemma 2.
That is, for every k ∈ [ N ] , if we see u ρ ( x k ) as a function of ρ , it is piecewise constant where pieces are given by P 1 , P 2 , . . . .
Therefore, when ρ moves over whole R n , the number of distinct tuples of form ( u ρ ( x 1 ) , . .
, u ρ ( x N )) is at most the number of the pieces.
Note that the pieces are generated by partitioning R n with (cid:80) k ∈ [ N ] (cid:0)
|G V ( x k ) |(cid:1) ≤ N (cid:0) n !2 (cid:1) hyperplanes, which means there are at most O (cid:16)(cid:16)
e N (cid:0) n !2 (cid:1)(cid:17) n (cid:17) pieces.
To shatter N instances, O (cid:16)(cid:16)
e N (cid:0) n !2 (cid:1)(cid:17) n (cid:17) ≥ 2 N is necessary.
Solving this for the largest N yields Pdim( U )
=
O( n 2 lg n ) .
Compared with GBFS, the additional n factor comes from the bound of ( n − 1)!
on |G v | .
This bound may seem too pessimistic, but it is almost tight in some cases, as implied by the following example.
Example 1.
Let ( V, E ) be a complete graph with edges labeled as (cid:8) e 1 , . .
, e | E | (cid:9) .
Set each edge weight w e i to 2 i − 1 for i ∈
[ | E | ] .
Considering the binary representation of the edge weights, the costs of all simple s – v paths are mutually different for v ∈ V , which implies |G v | = (cid:80) n − 2 k =0 k ! ≥ ( n − 2)! .
This example suggests that improving the O( n 2 lg n ) bound is not straightforward.
Under some realistic assumptions, however, we can improve it by deriving smaller upper bounds on |G v | .
First, if the maximum degree of vertices is always bounded, we can obtain the following bound.
Theorem 3.
Assume that the maximum out-degrees of directed graphs ( V, E ) of all instances in Π are upper bounded by d .
Then, it holds that Pdim( U ) =
O( n 2 lg d ) .
Proof.
Under the assumption on the maximum degree, there are at most (cid:80) n − 2 k
=
d k ≤ ( n − 1) d n −simple s – v paths, which implies |G v | ≤ ( n − 1)
d n − 2 for every v ∈ V .
Therefore, we have |G V | ≤ n × ( n − 1) d n − 2 .
Following the proof of Theorem 2, we can obtain an upper bound on Pdim( U ) by solving O (cid:16) N n (cid:0)
(cid:1)
≥ 2 N for the largest N , which yields Pdim
U )
=
O
n 2 lg d )
S x
s t    0 r x 2 x
s t    0 r
s t   3
r x
s t   0 r
Second, if edge weights are non-negative integers bounded by W , we can obtain the following bound.
Theorem 4.
Assume that edge weights { w e } e ∈ E of all instances in Π are non-negative integers bounded by a constant W from above.
Then, it holds that Pdim( U ) =
O( n lg( nW )) .
Proof.
Under the assumption, every g -cost g v takes a non-negative integer value at most nW .
Since G v consists of distinct g -cost values, |G v | ≤ nW holds, hence |G V | ≤ n 2 W .
Solving
O (cid:16) N n (cid:0) n 2 W 2 (cid:1) n (cid:17) ≥ 2 N for the largest N , we obtain Pdim( U ) =
O( n lg( nW )) .
Note that if W = O(poly( n )) holds, we have Pdim( U ) =
O( n lg n ) .
On reopening.
A* is usually allowed to reopen closed vertices as in Steps 12–14.
This, however, causes Ω(2 n ) iterations in general [26], albeit always finite [33].
A popular workaround is to simply remove Steps 12–14, and such A* without reopening has also been extensively studied [34, 31, 14, 15].
Note that our results are applicable to A* both with and without reopening.
Lower bounds on the pseudo-dimension
We present lower bounds on the pseudo-dimension for GBFS/A*.
We prove the result by constructing Ω( n ) shatterable instances with unweighted graphs.
Therefore, the O( n lg n ) upper bounds for GBFS (Theorem 1) and A* under the edge-weight assumption (Theorem 4) are tight up to a lg n factor.
Theorem 5.
For GBFS/A
* A ρ with parameters ρ ∈ R n , it holds that Pdim( U ) =
Ω( n ) .
Proof.
We construct a series of n − 4 instances, x 1 , . . .
, x n − 4 , that can be shattered by U , where each u ρ returns the length of an s – t path found by A ρ .
We label vertices in V by s , r , t , or i ∈
[ n − 3] .
See Figure 1 for an example with n = 8 .
We define M = V \ { s, r, t } .
For each x i ( i ∈ [ n − 4] ), we draw edges ( s, v ) for v ∈ M and ( v, t ) for v ∈ { v ′ ∈ M | v ′ > i } , which constitute optimal s – t paths of length 2 .
In addition, for each x i , we draw edges ( i, r ) and ( r, t ) , where s → i → r → t is the only suboptimal path of length 3 .
Letting t i = 2 . 5 for i ∈
[ n − 4] , we prove that U can shatter those n − 4 instances, i.e., A ρ can return suboptimal solutions to any subset of { x 1 . . .
, x n − 4 } by appropriately setting ρ .
Let S ⊆
[ n − 4] indicate a subset of instances, to which we will make A ρ return suboptimal solutions.
We show that for any S , we can set ρ so that A ρ returns s → i → r → t to x i if and only if i ∈ S .
We refer to the vertex labeled by n − 3 as m , which we use to ensure that every instance has an optimal path s → m → t .
We set ρ as follows:
ρ s = n (or an arbitrary value), ρ r = ρ t = 0 , ρ i
= i
+ 2 if i ∈ S ∪ { m } , and ρ i = n (or a sufficiently large value) if i ∈ [ n − 4] \ S .
If A ρ with this ρ is applied to x i , it iteratively selects vertices in S ∪ { m } in increasing order of their labels until a vertex that has a child is selected.
Once a vertex with a child is expanded, it ends up returning s
→ i → r → t if i ∈ S and s → v → t for some v > i if i / ∈ S .
We below confirm this more precisely, separately for
GBFS and A*.
GBFS.
We consider applying GBFS A ρ to x i .
A ρ first expands s and add vertices in M to OPEN .
Since vertices in v ∈ [ n − 4] \ S have sufficiently large scores of n , they are never selected before any vertex in S ∪ { m } .
Thus, A ρ selects a vertex from S ∪ { m } with the smallest score.
If the selected vertex, denoted by v , satisfies v < i , there is no child of v ; hence, nothing is added to OPEN , and we go back to Step 3.
In this way, A ρ iteratively moves v ∈ S ∪ { m } that has no child from OPEN to
CLOSED .
Consider the first time when the selected vertex v ∈ S ∪ { m } has a child c (this situation is guaranteed to occur since m always has a child).
If i / ∈ S , we have v ̸
= i since v is selected from
S ∪ { m } .
Then, since v ’s child is c
= t , A ρ returns s → v → t with v ̸
= i .
If i ∈ S , then i has the smallest score ( ρ i
= i + 2 ) among all vertices in S
∪ { m } that have a child.
Thus, A ρ selects i and opens r .
Now, r has the smallest score of ρ r = 0 .
Therefore, A ρ selects r and reaches t , returning s → i → r → t .
Consequently, A ρ returns the suboptimal path if and only if i ∈ S .
A*.
It first expands s and add M to OPEN .
Since g v = 1 for all v ∈ M , only ρ values matter when comparing the scores, as with the case of GBFS.
Therefore, A* iterates to move vertices in S ∪ { m } from OPEN to CLOSED until a vertex that has a child is selected.
Consider the first time a selected vertex v has a child c (so far, s is not reopened since g s = 0 ).
As with the case of GBFS, we have v ̸
=
i and c =
t if i / ∈ S , or v = i and c = r
if i ∈ S .
Now, every v ′ ∈ OPEN \ { c } has a score of at least 4 since g v ′
= 1 and ρ v ′ ≥ 3 for v ′ ∈ M .
Therefore, if i / ∈ S , t ∈ OPEN has the smallest score of g t + ρ t = 2 + 0 = 2 .
Thus, A ρ next selects t and returns s → v → t , where v ̸ = i .
If i ∈ S , since r ∈ OPEN has the smallest score of g r + ρ r = 2 +
= 2 , A ρ selects r and opens t .
Then, since t has the score of g t + ρ t = 3 + 0 = 3 , A ρ selects t and returns s → i → r → t .
To conclude, A ρ returns the suboptimal path if and only if i ∈ S .
Toward better guarantees on the suboptimality of A*
Given the results in Sections 3 and 4, a major open problem is to close the ˜O( n ) gap 2 between the
O( n 2 lg n ) upper bound and the Ω( n ) lower bound for A* in general cases.
This problem seems very complicated, as we will discuss in Section 6.
Instead, we here study a particular case where we want to bound the expected suboptimality of A*, which is an important performance measure since learned heuristic values are not always admissible.
We show that a general bound obtained from Theoremcan be sometimes improved by using a ρ -dependent worst-case bound [34].
For any x ∈ Π , let Opt( x ) and Cost ρ ( x ) be the costs of an optimal solution and an s – t path returned by A ρ , respectively, and let u ρ ( x ) =
Cost ρ ( x ) − Opt( x ) be the suboptimality.
From Theorem 2 and
Proposition 1, we can obtain the following high-probability bound on the expected suboptimality:
[Equation]
That is, the expected suboptimality can be bounded from above by the empirical suboptimality over the N training instances (an empirical term) plus an ˜O( H (cid:112) n 2 /N ) term (a complexity term).
While this bound is useful when N ≫ n 2 , we may not have enough training instances in practice.
In such cases, the complexity term becomes dominant and prevents us from obtaining meaningful guarantees.
In what follows, we present an alternative bound of the form “an empirical term + a complexity term” that can strike a better balance between the two terms when N is not large enough relative to n 2 .
To this end, we use the notion of consistency .
We say ρ is consistent if ρ v ≤ ρ c + w ( v,c ) holds for all ( v, c ) ∈ E .
If ρ is consistent, A* without reopening returns an optimal solution.
Valenzano et al.
Theorem 4.6] revealed that for any instance x ∈ Π , the suboptimality of A* can be bounded by the inconsistency accumulated along an optimal path (excluding the first edge containing s ) as follows:
[Equation]
where S ∗ ( x ) ⊆
E is an optimal solution to x (if there are multiple optimal solutions, we break ties by using the lexicographical order induced from the total order defined in Assumption 2).
We call ∆ ρ ( x ) the inconsistency (of ρ on S ∗ ( x ) ).
Given N instances x 1 , . . .
, x N , we can compute the empirical inconsistency, 1 N (cid:80) Ni =1 ∆ ρ ( x i ) , at the cost of solving the N instances, which we will use as an empirical term.
To define the corresponding complexity term, we regard ∆ ρ ( · ) :
Π → [0 , ˆ H ] as an inconsistency function parameterized by ρ , where we will discuss how large ˆ H > 0 can be later, and we let ˆ U = { ∆ ρ : Π → [0 , ˆ H ] | ρ ∈ R n } .
The following theorem says that the class ˆ U of inconsistency functions has a smaller pseudo-dimension than the class U of general utility functions.
Theorem 6.
For the class ˆ U of inconsistency functions, it holds that Pdim( ˆ U ) =
O( n lg n ) .
By using (2), Proposition 1, and Theorem 6, we can obtain the following high-probability bound on the expected suboptimality, whose complexity term has a better dependence on n than that of (1):
[Equation]
This bound is uniform for all ρ ∈ R n , as with other bounds discussed so far.
Thus, the bound holds even if we choose ρ to minimize the empirical inconsistency.
Note that the empirical inconsistency is convex in ρ since ∆ ρ ( x i ) consists of a maximum of a linear function of ρ and zero, hence easier to minimize than the raw empirical suboptimality in practice (and suitable for a recent online-convexoptimization framework [25]).
Before proving Theorem 6, we present a typical example to show that the inconsistency is not too large relative to the suboptimality.
Example 2.
Suppose that every edge weight w e is bounded to [0 , W ] , which ensures that the suboptimality u ρ is at most H =
W ( n − 1) for any ρ ∈ R n .
For simplicity, we consider the following natural way to compute ρ values: compute an estimate ˆ w e ∈ [0 , W ] of w e for each e ∈ E and let ρ v be the cost of a shortest v – t path with respect to { ˆ w e } e ∈ E .
Then, ρ enjoys the consistency with respect to { ˆ w e } e ∈ E , i.e., ρ v ≤ ρ c + ˆ w ( v,c ) for every ( v, c ) ∈ E .
Therefore, it holds that
[Equation]
Hence ∆ ρ is at most ˆ H =
W
( n − 2) , implying that ∆ ρ does not largely exceed the suboptimality.
If empirically accurate estimates ˆ w e for e ∈ S ∗ ( x ) are available, the inconsistency becomes small.
We prove Theorem 6 by using the general analysis framework by Balcan et al.
To begin with, we introduce Assouad’s dual class, which provides a formal definition of the class of functions of ρ .
Definition 2 (Assouad [3]) .
Given a class, H ⊆ R Y , of functions h : Y → R , the dual class of H is defined as H ∗ =
(cid:8) h ∗ y :
H → R (cid:12)(cid:12) y ∈ Y (cid:9)
such that h ∗ y
( h ) =
h ( y ) for each y ∈ Y .
In our case, we have Y = Π and H
= ˆ U , and each ∆ ∗ x ∈
ˆ U ∗ is associated with an instance x ∈ Π .
The following definition will be used to capture the piecewise structure of the dual class ˆ U ∗ .
Definition 3 (Balcan et al.
[8, Definition 3.2]) .
A class, H ⊆ R Y , of functions is ( F , B , K ) -piecewise decomposable for a class B ⊆ { 0 , 1 } Y of boundary functions and a class F ⊆ R Y of piece functions if the following condition holds: for every h ∈ H , there exist K boundary functions b (1) , . . .
, b ( K ) ∈ B and a piece function f b for each binary vector b ∈ { 0 , 1 } K such that for all y ∈ Y , it holds that h ( y ) =
f b y ( y ) where b y =
( b (1) ( y ) , . . .
, b ( K ) ( y ))
∈ { 0 , 1 } K .
The following result of [8] provides an upper bound on the pseudo-dimension of a class of functions via the piecewise structure of the dual class.
Proposition 2 (Balcan et al.
[8, Theorem 3.3]) .
Let U ⊆
R Π be a class of functions.
If U ∗ ⊆
R U is ( F , B , K ) -piecewise decomposable with a class B ⊆ { 0 , 1 } U of boundary functions and a class
F ⊆ R U of piece functions, the pseudo-dimension of U is bounded as follows:
[Equation]
Now, we are ready to prove Theorem 6.
Proof of Theorem 6.
Since there is a one-to-one correspondence between ∆ ρ ∈ ˆ U and ρ ∈ R n , we below identify ∆ ρ with ρ for simplicity.
Let B = (cid:8) I ( ⟨ z , ρ ⟩ + z 0 ) (cid:12)(cid:12) ( z 0 , z ) ∈ R n +1 (cid:9) ⊆ { 0 , 1 } ˆ U
and
F = (cid:8) ⟨ z , ρ ⟩ + z 0 (cid:12)(cid:12) ( z 0 , z ) ∈ R n +1 (cid:9) ⊆
R ˆ U be classes of boundary and piece functions, respectively.
We show that ˆ U ∗ is ( F , B , O( n 2 ))
-piecewise decomposable.
Fix any ∆ ∗ x ∈ ˆ U ∗ ; this also uniquely specifies an instance x ∈ Π and an optimal solution S ∗ ( x ) ⊆
E (due to the tie-breaking).
We consider K = | E | =
O( n 2 ) boundary functions of form b ( v,c ) ( ρ ) =
I (cid:0) ρ v − ρ c − w ( v,c ) > 0 (cid:1) for all edges ( v, c ) ∈ E .
We below confirm that these boundary functions partition R n ∋ ρ into some regions so that in each region, ∆ ∗ x ( ρ ) can be written as a linear function of ρ , which belongs to F .
For each binary vector b ρ = (cid:0) b ( v,c ) ( ρ ) (cid:1) ( v,c ) ∈ E ∈ { 0 , 1 } K , we define a subset S ρ ( x ) of S ∗ ( x ) as S ρ ( x ) = (cid:8) ( v, c )
∈ S ∗ ( x ) (cid:12)(cid:12) b ( v,c ) ( ρ ) = 1 , v ̸ = s (cid:9) ; that is, each ( v, c ) ∈ S ρ ( x ) satisfies v ̸
= s and ρ v − ρ c − w ( v,c ) > 0 .
From the definition of ∆ ρ ( x ) , we have ∆ ∗ x
( ρ )
=
∆ ρ ( x ) =
(cid:80) ( v,c ) ∈ S
ρ ( x ) ( ρ v − ρ c − w ( v,c ) ) .
This is a linear function of ρ , and thus we can choose a piece function f b ρ ∈ F such that ∆ ∗ x = f b ρ .
This relation holds for every b ρ ∈ { 0 , 1 } K , and thus we have ∆ ∗ x ( ρ ) =
f b ρ ( ρ ) for all ρ ∈ R n .
Hence ˆ U ∗ is ( F , B , O( n 2 ))
-piecewise decomposable.
Since F ∗ and B ∗ can be seen as classes of linear and halfspace functions of ( z 0 , z ) ∈ R n +1 , respectively, we have Pdim( F ∗ ) =
VCdim( B ∗ ) = n + 1 (see also [6, Lemma 3.10], a preprint version of [8]).
Therefore, from Proposition 2, we obtain Pdim( ˆ U ) =
O( n lg n ) .
Conclusion and discussion
We have studied the sample complexity of learning heuristic functions for GBFS and A* on graphs with a fixed vertex set of size n .
For GBFS and A*, we have proved that the pseudo-dimensions are upper bounded by O( n lg n ) and O( n 2 lg n ) , respectively.
As for A*, we have shown that the bound can be improved to O( n 2 lg d ) if every vertex has a degree of at most d and to O( n lg n ) if edge weights are bounded integers.
We have also presented the Ω( n ) lower bounds for GBFS and A*, implying that our bounds for GBFS and A* under the integer-weight condition are tight up to a lg n factor.
Finally, we have discussed bounds on the suboptimality of A* and obtained a guarantee with a better complexity term by evaluating the pseudo-dimension of the class of inconsistency functions.
An open problem is to close the gap between the upper and lower bounds regarding A* for general cases.
This, however, does not seem straightforward.
We here discuss the reasons for the difficulty.
As regards the upper bound, the bottleneck is the bound of ( n − 2)!
on |G v | , but this cannot be improved in general, as shown in Example 1.
Considering this, the direct use of Sauer’s lemma would not yield better upper bounds.
Thus, we need to use some special structures of the hyperplanes (e.g., each has only two variables), which would require more complicated analysis.
As for the lower bound, the construction of the Ω( n ) instances in Theorem 5 relies on the fact that ρ has an n degree of freedom.
In addition, Theorem 4 implies that we need to consider instances with non-integer edge weights (or exponentially large integer weights in n ) to obtain a lower bound of ˜ Ω( n 2 ) .
Considering the above, we would need more involved techniques for constructing a set of ˜Ω( n 2 ) shatterable instances.
Another interesting future direction is to improve upper bounds on the pseudo-dimension by restricting heuristic functions to some classes.
Appendix D will present an illustrative example where we can achieve polylog( n ) upper bounds on the pseudo-dimension by assuming that heuristic functions with much fewer tunable parameters than n can be designed in an instance-specific manner.
We finally discuss limitations of our work.
As mentioned in Section 2, we require every instance to be defined on (subsets of) a fixed vertex set.
Also, our work does not cover the case where heuristic function values can change depending on instance-dependent features.
Studying how to overcome these limitations would also constitute interesting future work.
Acknowledgements
The authors thank Siddharth Prasad for kindly telling a general result of [10] and anonymous reviewers for providing valuable suggestions, particularly on Appendix D. This work was supported by JST
ERATO Grant Number JPMJER1903 and JSPS KAKENHI Grant Number JP22K17853.