                                                   Neural Genetic Search in Discrete Spaces

                                                                          Construction with 𝑝!∗
                   F                                                                  𝑡! + 1
  A                                                  𝑡′
           G
               E
       C
 B                 D   𝐬" G−A −B −D −C −E −F −G
     𝒢 = (𝒱, ℰ)        𝐬 # B−G −A −F −E −D −C −B   E−D −B             Crossover       E−D −B −C             Mutate       E−D −B −C −G −A −F −E




Figure 3. An illustration of crossover and mutation in TSP (Section 3.1.1). At t = t′ , the token-restriction crossover masks out edges not
included in the parents, and then the pretrained policy gives the distribution over the remaining valid edges. At t = t′ + 1, since all edges
included in the parents are invalid ( ), the constraint-enforcing mutation activates, allowing selection of any unvisited node.


3.1.1. A C ONCRETE E XAMPLE : TSP                                         the function f as rankP (s), which ranges from 0 (highest
                                                                          reward) to P − 1 (lowest reward). Rank-based prioritized
We provide a concrete example with the traveling sales-
                                                                          sampling probability is defined as:
man problem (TSP) to provide further insight into how the
                                                                                                                         −1
crossover and mutation work. Generally, a TSP instance is                                Pr(s) ∝ (κ|P| + rankP (s))           .            (5)
defined on a complete graph G = (V, E), where V is the
set of N nodes and E is the set of edges. The goal is to                  To generate a pair of parents, we sample two chromosomes
find a tour that visits each node exactly once and returns to             without replacement and repeat this independently until we
the starting point, minimizing the total travel distance; the             obtain Noff pairs. Those pairs are fed into the crossover and
reward is defined as the negative total distance. Note that               mutation process to generate the next generation. In the
the vocabulary V is the set of edges E, and a token is an                 replacement phase, we use P ∪ O, instead of P and sample
edge, i.e., st ∈ E.                                                       Npop chromosomes without replacement.

Figure 3 illustrates how new offspring solutions are gener-               Algorithm 1 Neural Genetic Search
ated using NGS in TSP. A route is constructed sequentially
                                                                          Require: Npop , Noff , the number of iterations Niter , a pre-
by choosing edges, with the constraint that each node cannot
                                                                              trained policy pθ∗
be visited more than once. At time step t, the policy samples                                    Npop
                                                                           1: P = {(si , r(si ))}i=1 , where si ∼ pθ∗ (s) {Eq. (1)}
an edge that connects the current node to the next node. This
                                                                           2: for i = 1 to Niter do
sequence of selected edges is directly used as a chromosome.
The policy masks out the edges connecting the current nodes                3:    O←∅
to already-visited nodes to prevent repeated visits. Once all              4:    for n = 1 to Noff do
nodes are visited, a tour is formed by returning to the starting           5:       Select parents (s1 , s2 ) from P using Eq.(5)
node. During offspring generation, the parent vocabulary is                6:       Generate offspring s ∼ pNGS(s1 ,s2 ,µ) (s) {Eq.(4)}
defined as the set of edges that appear                                    7:       O ← O ∪ {(s, r(s))}
                                   SN in either of the two                 8:    end for
parent routes; that is, Vs1 ,s2 = t=1 {s1t , s2t ∈ E} where
s1 , s2 are selected parents. This in turn defines pcross as in            9:    Replace P by sampling Npop chromosomes
Eq. (2). If no edge in the parent set remains valid—they                         from P ∪ O using Eq. (5).
                                                                          10: end for
all lead to visited nodes—the token restriction on parents
is relaxed through constraint-enforcing mutation, allowing
the policy to choose from any edge connected to unvisited                 3.3. Algorithmic Overview and Viewpoints
nodes to maintain route validity.
                                                                          The NGS algorithm is summarized in Algorithm 1. NGS
3.2. Rank-based Selection and Replacement                                 offers an improved search capability for the sequential gen-
                                                                          erative models by gracefully combining the strength of GA
For selection and replacement, we employ rank-based pri-                  with the neural policy pθ∗ . A more detailed analysis of its
oritized sampling (Tripp et al., 2020; Kim et al., 2023).                 time and memory complexities can be found in Appendix D.
Rank-based sampling works as a stochastic elitism, provid-                Below, we highlight two perspectives on NGS: 1) as a novel
ing controllability for balancing the stochasticity and the               decoding strategy that leverages evolutionary principles and
eagerness in selection. In this section, we define rank with              2) as a GA enhanced by learned operators.
regard to reward, but it is possible to use multiple criteria ;
see Appendix A.2.                                                         3.3.1. NGS AS A DECODING STRATEGY
Assume that the population P is filled with |P| chromo-                   NGS can be viewed as a decoding scheme for sequential
somes. We denote the rank of a sequence s in P respect to                 generative models because it converts the learned (condi-

                                                                      4
