                                                  Neural Genetic Search in Discrete Spaces

                     Initialize                         Select                      Crossover & Mutate                Evaluate
                                           Population            Parents                           𝑝!∗                           0.79
                                                                                                                                 0.46




                                                                                                                       …
                                                                                                                                 0.61
                                                                                                                                 0.74
                       𝐬 ∼ 𝑝!∗




                                              …




                                                                                                                       …
                                                                                        Generation with
                                                                                    parent-conditioned mask                      0.25


                                                                       Replace the population

Figure 2. Overview of GA with NGS. (1) The pretrained generative policy sequentially constructs sequences, which correspond to
chromosomes, to initialize the population. From this population, (2) parents are selected, and then (3) the policy reproduces offspring by
sampling new sequences with a parent-conditioned mask. Finally, (4) the newly generated candidates replace members of the population,
completing one evolutionary cycle.


multaneously, increasing the likelihood of finding global op-                   distribution after the crossover with parents (s1 , s2 ) as:
tima. GAs have been successfully applied to various fields,
including routing (Vidal et al., 2012; Nagata & Kobayashi,                         pcross(s1 ,s2 ) (st |s<t ) ∝ I(st ∈ Vs1 ,s2 )pθ∗ (st |s<t ),     (2)
2013; Kobeaga et al., 2018; Wouda et al., 2024), molecu-                        where I is an indicator function. As a result, the crossover
lar design (Morris et al., 1998; Jensen, 2019; Nigam et al.,                    operator functions as a parent-conditioned generative pro-
2021; Kerstjens & De Winter, 2022), scheduling (Murata                          cess.
et al., 1996; Gonçalves et al., 2005), and robotics (Davidor,
1991; Lamini et al., 2018; Ismail et al., 2008).                                Mutation. In classical GA, mutation introduces diversity by
                                                                                allowing new genetic material that may not appear in either
                                                                                parent. Analogously, our mutation allows new components
3. Neural Genetic Search                                                        by un-masking the masked tokens. Thus, mutation removes
We begin by assuming a pretrained sequential generative                         the effect of the crossover and reverts to the normal sequence
policy pθ∗ .The only requirement is that the policy pθ∗ sam-                    generation. This mutation is conducted in two cases:
ples solutions in a factorized manner as in Eq. (1), which                      • Constraint-enforcing mutation. If all tokens in Vs1 ,s2
allows a flexible use of training approaches and architec-                        cannot satisfy the specific constraints in the sequence, i.e.,
tures.1 An overview of our algorithm is provided in Figure 2
                                                                                  P
                                                                                    st ∈V 1 2 pθ (st |s<t ) = 0, we forcibly do the mutation.
                                                                                                 ∗
                                                                                          s ,s
and Algorithm 1.
                                                                                • Stochastic mutation. Even if constraints are met, we
                                                                                  apply mutation with probability µ ∈ [0, 1].
3.1. Crossover and Mutation
                                                                                Considering the mutation, the next token distribution is then
We propose a problem-agnostic crossover and mutation
                                                                                modified further as:
operations that integrate readily into the generative process
of the pretrained model.                                                               pNGS(s1 ,s2 ,µ) (st |s<t )
Crossover. Given two parent chromosomes (s1 , s2 ),                                     = Ms<t ,s1 ,s2 ,µ · pθ∗ (st |s<t )                          (3)
we define our crossover operation as token-restriction,                                    + (1 − Ms<t ,s1 ,s2 ,µ ) · pcross(s1 ,s2 ) (st |s<t ),
i.e., the vocabulary for a child is restricted to Vs1 ,s2 =                     where the binary variable M indicates whether or not the
{s11 , . . . , s1T } ∪ {s21 , . . . , s2T }.2 With this restricted vocab-       mutation occurs, i.e.,
ulary, the pretrained generative policy constructs new se-
quences while ensuring they follow structural constraints                         Ms<t ,s1 ,s2 ,µ
from the parents. The crossover is simply implemented by                            
                                                                                    1                  if
                                                                                                               P
                                                                                                                       pθ∗ (st |s<t ) = 0
masking out the tokens not in Vs1 ,s2 during the sequence                         =                        st ∈Vs1 ,s2
generation process in Eq. (1). We define the next token                             
                                                                                       Y ∼ Bernoulli(µ) otherwise.
    1
      Though we aim to maximize the reward function, the policy
can be trained via supervised learning by distilling pre-collected              The resulting probability of a sequence s being generated
solutions with expert-designed solvers; see Section 5.1.3.                      by the policy with NGS conditioned on parents s1 and s2
    2
      We fixed the number of parents to two, but note that it is                becomes:
allowed to use more than two parents in our algorithm.
                                                                                                                T
                                                                                                                Y
                                                                                        pNGS(s1 ,s2 ,µ) (s) =         pNGS(s1 ,s2 ,µ) (st |s<t ).   (4)
                                                                                                                t=1

                                                                            3
