{'fraction_non_alphanumeric': 0.03974313596602114, 'fraction_numerical': 0.010972341608939678, 'mean_word_length': 4.654088050314465, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Gumbel-softmax Optimization: A Simple General Framework for Combinatorial Optimization Problems on Graphs

Many problems in real life can be converted to combinatorial optimization problems (COPs) on graphs, that is to find a best node state configuration or a network structure such that the designed objective function is optimized under some constraints. However, these problems are notorious for their hardness to solve because most of them are NP-hard or NP-complete. Although traditional general methods such as simulated annealing (SA), genetic algorithms (GA) and so forth have been devised to these hard problems, their accuracy and time consumption are not satisfying in practice. In this work, we proposed a simple, fast, and general algorithm framework called Gumbel-softmax Optimization (GSO) for COPs. By introducing Gumbel-softmax technique which is developed in machine learning community, we can optimize the objective function directly by gradient descent algorithm regardless of the discrete nature of variables. We test our algorithm on four different problems including Sherrington-Kirkpatrick (SK) model, maximum independent set (MIS) problem, modularity optimization, and structural optimization problem. High-quality solutions can be obtained with much less time consuming compared to traditional approaches.


Introduction
Combinatorial optimization problems (COPs) ask for optimizing a given objective function whose domain is a discrete but large configuration space [1]. COPs arise in many disciplines and many real-world optimization problems can be converted to COPs. In computer science, there exist a large number of COPs defined on graphs, e.g., maximal independent set (MIS) and minimum vertex cover (MVC) [1]. In these problems, one is asked to give a largest (or smallest) subset of the graph under some constraints. In statistical physics, finding the ground state configuration of spin glasses model where the energy is minimized is another type of COPs [2]. Many problems of network science can also be treated as COPs, for example, modularity optimization [3] asks to specify which community one belongs to that maximize the modularity value. While, structural optimization asks to reveal the underlying network structure under some constraints. For example, finding the network structure to recover the observed network dynamics if the dynamical rules are given. This is also called network reconstruction problem [4,5]. In general, the space of possible solutions of mentioned problems is typically very large and grows exponentially with system size, thus impossible to solve by exhaustion.
Many methods have been proposed to solve COPs. Traditional general optimization methods such as simulated annealing (SA) [6], genetic algorithm (GA) [7], extremal optimization (EO) [8] usually suffer from slow convergence and are limited to system size up to thousand. Although there exist many other heuristic solvers such as local search [9], they are usually domain-specific and require special knowledge.
Recently a great deal of effort has been devoted to applying machine learning to solve COPs. Khalil et al. [10] used a combination of reinforcement learning and graph embedding called S2V-DQN to address combinatorial optimization problems on graphs. Li et al. [11] used graph convolution networks (GCNs) [12] with classic heuristics and achieved state-of-art performance compared to S2V-DQN. However, these two algorithms all belong to supervised learning, thus contain two stages of problem solving: first training the solver and then testing. Although relatively good solutions can be obtained efficiently, it takes a long time for training the solver and the quality of solutions depends heavily on the quality and the amount of the data for training, which is hardly for large graphs. Some techniques have been developed in reinforcement learning area which seeks to solve the problems directly without training and testing stages. For example, REINFORCE algorithm is a typical gradient estimator for discrete optimization. However, it suffers from high variance and time-consuming problems. Recently reparameterization trick developed in machine learning community such as Gumbel-softmax [13,14] provides another approach for differentiable sampling. It allows us to pass gradients through samples directly and this method has not been applied to solving COPs on graphs so far.
In this work, we present a novel optimization method based on Gumbel-softmax, called Gumbel-softmax optimization (CSO) method. Under the naive mean field assumption, we assume that the joint probability of a configuration is factorized by the product of marginal probabilities. The marginal probabilities, which stand for the states of nodes or edges, are parameterized by a set of learnable parameters. We can sample a configuration through Gumbel-softmax and compute the objective function. Then we run backpropagation algorithm and update parameters. Furthermore, GSO can be implemented in parallel easily on GPU to simultaneously solve the optimization problem under different initial conditions, and one solution with the best performance can be selected. We first introduce four different problem in Section 2. Then the details of GSO algorithm is explained in Section 3. In Section 4 we introduce our main results on all four problems, and compare with different benchmark algorithms. The results show that GSO can achieved satisfying solutions and also benefit from time consumption. Finally some concluding remarks are given in Section 5.

Preliminary
The combinatorial optimization problems that we concerned can be formulated as follows. Let's consider N variables s i where i ∈ {1, 2, · · · , N } and each variable can take discrete values: s i ∈ {1, 2, · · · , K}. The combination of the values for all variables is defined as a configuration or a state s = (s 1 , s 2 , · · · , s N ) ∈ {1, 2, · · · , K} N . The objective function E is a map between the configuration space and the real number field, E ∈ {1, 2, · · · , K} N × R. Thus, the goal of the combinatorial optimization problem is to find a configuration s * such that the objective function is minimized, i.e., E(s * ) ≤ E(s) for all s ∈ {1, 2, · · · , K} N . Usually, a set of constraints must be considered which can be formulated as boolean functions on s. Nevertheless, they can be absorbed into the objective functions by introducing the punishment parameter. Therefore, we only consider the optimization problem without constraints in this paper for the simplicity.
Here, we consider two kinds of COPs on graphs: one is node optimization problem, the other is structure optimization problem. The node optimization problem can be stated as follows. Given a graph G = (V, E) where V = {v i } i=1:N is the set of N = |V| vertices in G and E is the set of M = |E| edges. Each vertex is a variable s i ∈ {1, 2, · · · , K} in the optimization.
The structure optimization problem is to find an optimal network structure such the objective function defined on graphs can be optimized. If we treat the adjacency matrix of the graph as the state of the system, and each entry of the matrix is a variable which taking value from {0, 1}, then structural optimization problem is also a COP.
In this work we focus on four typical optimization problems: Sherrington-Kirkpatrick (SK) model SK model [15] is a celebrated spin glasses model defined on a complete graph where all vertices are connected. The objective function, or the ground state energy of this model is defined as where s i ∈ {−1, +1} and J ij ∼ N (0, 1/N ) is the coupling strength between two vertices. We are asked to give a configuration s = (s 1 , s 2 , · · · , s N ) where the ground state energy is minimized. The number of possible configurations is 2 N and in fact, finding the ground state configuration of SK model is an NP-hard problem [2].
Maximal Independent Set (MIS) MIS problem is another well-known NP-hard problem. The reason why we focus on MIS problem is that many other NP-hard problems such as Minimum Vertex Cover (MVC) problem and Maximal Clique (MC) problem can be reduced to an MIS problem. An MIS problem asks to find the largest subset V ⊆ V such that no two vertices in V are connected by an edge in E. The Ising-like objective function consists of two parts: where s i ∈ {0, 1} and the second term provides an penalty for two connected vertices being chosen. α is the hyperparameter for the strenghth of the punishment. The first term is the number of vertices in V .
Modularity optimization Modularity is a graph clustering index for detecting community structure in complex networks [16]. Many modularity optimization methods, e.g., hierarchical agglomeration [17], spectral algorithm [3] and extremal optimization [18] have been proposed and it is suggested that maximizing modularity is strongly NPcomplete [19]. In general cases where a graph is partitioned into K communities, the objective is to maximize the following modularity Q: Structural optimization The problem of structural optimization is to find an optimal network structure for some objective function defined on a network [20,21]. This problem can also be considered as a special example of a COP if the element of the adjacency matrix a ij ∈ {0, 1} is the optimized variable, and a configuration A ∈ {0, 1} N ×N is the adjacency matrix of a potential graph, where N is the number of nodes in the network which is a fixed value.
For example, we can find an optimal network to fit the observed node dynamics, in which, we are asked to optimize the network structure A to match the given observed time series data of all nodes {x 1 , x 2 , · · · , x T }, where x t is the node state vector at t, and T is the length of the time window for our observation. The network dynamical rule F such that x t+1 = F(x t ,Ã) is known but the underlying real network structureÃ is unknown for us. Our task is to recover the real network structureÃ by minimizing the following objective function: Conventionally, this problem is also called network reconstruction problem in [4,5].

Methodology
We will show that one particular computational approach can solve all the problems mentioned above in a unified way. Notice that although the objective functions in Equation 1, 2, and 3 all have Ising-like form, Equation 4 is much more complicated than others because the dynamical rule F may be very complex and even non-analytic. However, we will show that our computational framework can work on all of them.
Naive mean field approximation The basic idea of our method is to factorise the possible solutions into N independent Bernouli variables, this is called naive mean field approximation in statistical physics. We assume that vertices in the network are independent and the joint probability of a configuration s = (s 1 , s 2 , · · · , s N ) can be written as a product distribution [22]: Pr(s i ).
The marginal probability Pr(s i ) ∈ [0, 1] K can be parameterized by a set of parameters θ i which is easily generated by Sigmoid or softmax function.
We sample the possible solution s according to Equation 5, and evaluate the objective function E(s; θ θ θ) under the given parameters. Then by using the automatic differential techniques empowered by current popular deep learning frameworks such as PyTorch [23] and TensorFlow [24], we can obtain the gradient vector ∂E(s; θ θ θ)/∂θ θ θ for all parameters of variables. And the parameters θ θ θ will be updated according to the gradient vector. However, the sampling process in the above procedure is not differentiable which is required in all deep learning frameworks to compute gradient vector because the sampling operation introduces stochasticity.
Gumbel-softmax technique Traditionally we can resort to Monte Carlo gradient estimation techniques such as REINFORCE [25]. Gumbel-softmax [13], a.k.a. concrete distribution [14] provides an alternative approach to tackle the difficulty of non-differentiability. Consider a categorical variable s i that can take discrete values s i ∈ {1, 2, · · · , K}. This variable s i can be parameterised as a K-dimensional vector (p 1 , p 2 , · · · , p K ) where θ i is the probability that θ i = Pr(s i = r), r = 1, 2, · · · , K. Instead of sampling a hard one-hot vector, Gumbel-softmax technique give a K-dimensional sample vector where the i-th entry iŝ where g i ∼ Gumbel(0, 1) is a random variable following standard Gumbel distribution and τ is the temperature parameter. Notice that as τ → 0, the softmax function will approximate argmax function and the sample vector will approach a one-hot vector. And the one-hot vector can be regarded as a sample according to the distribution (p 1 , p 2 , · · · , p K ) because the unitary element will appear on the i th element in the one-hot vector with probability p i , therefore, the computation of gumbel-softmax function can simulate the sampling process. Furthermore, this technique allows us to pass gradients directly through the "sampling" process because all the operations in Equation 6 are differentiable. In practice, it is common to adopt a annealing schedule from a high temperature τ to a small temperature.

Sample from
Pr(s i ) simultaneously via gumbel-softmax technique and then calculate the objective function.
3. Backpropagation to compute gradients ∂E(s; θ θ θ)/∂θ θ θ and update parameters θ θ θ = (θ 1 , θ 2 , · · · , θ N ) by gradient descent. We point out that our method can be implemented in parallel on GPU: we can simultaneously initialize N bs different initial values and calculate N bs objective functions. When the training procedure is finished, we select the result with best performance from N bs candidates. We present our proposed method in Algorithm 1.

Experiment
Experimental settings We conduct experiments on all four problems described in Section 2. For SK model, we optimize the ground state energy with various sizes ranging from 256 to 8192. For MIS problem, we use citation network datasets: Cora, Citeseer and PubMed and treat them as undirected networks. For modularity optimization, we use four real-world datasets studied in [17,3,18]: Zachary, Jazz, C.elegans and E-mail. We compare our proposed method to other classical optimization methods and state-of-the-art deep learning approaches, e.g., (1) simulated annealing (SA) [6]: a general optimization method inspired by Metropolis-Hastings algorithm; (2) Extremal optimization (EO) [8]: a heuristic designed to address combinatorial optimization problems; (3) Structure2Vec Deep Q-learning (S2V-DQN) [10]: a reinforcement learning method to address optimization problems over graphs; (4) GCNs [11]: a supervised learning method based on graph convolutional networks (GCNs).
In practice, we choose the batch size N bs = 128. During optimization, we use Gumbel-softmax estimator to generate continuous samples to calculate the objective function but discrete samples for the final output. We use Adam optimizer [26] with different learning rate {1e − 3, 1e − 2, 1e − 1, 1}, annealing rate {0.99, 0.999, 0.9999} and report results with best performance.
As for the task of structural optimization, we choose Coupled Map Lattice on a given but unknown graphÃ as our dynamical rule, which is widely used to study the chaotic dynamics of spatially extended systems: where s is the coupling constant, deg(i) is the degree of node i and neighbor(i) is the set of neighbor nodes of i on graphÃ. Here, f () is the logistic map function f (x) = λx(1 − x). We conduct our experiments on random 4-regular graphs. We first sample an adjacency matrix A and then estimate the error of dynamics according to Eq 4.
Performance Table 1 Table 2: Results on optimization of ground state energy of SK model for different system size N and instances I. We use different optimizer in gradient descent (GD). We also present the results of parallel version of our proposed method where we choose N bs = 128. We can optimize this objective function through gradient descent (GD) with different optimizer, e.g. Adam or L-BFGS but the results are not satisfying. The reason is that there are too many frustrations and local minima in the energy landscape.
(3) With the implementation of the parallel version, the results can be improved greatly.  Table 3 presents the performance of MIS problem on three citation networks. Our proposed method has successfully found the global optimal solution on Cora dataset and obtained much better results compared to the sophisticated S2V-DQN [10] on all three dataset. Although our results are not competitive with [11], we must stressed that it is a supervised learning algorithm. Besides, it also adopts graph reduction techniques and a parallelized local search algorithm. Our method, however, requires none of these tricks.  On the task of modularity optimization, our method also obtained satisfying results, as shown in Table 4. Comparing to hierarchical agglomeration [17], our proposed method has achieved much higher modularity on all datasets. In Figure 2 we present the partition obtained by our GSO method. Here we present our results on the task of structural optimization in Table 5. We set coupling constant s = 0.2 fixed. Because r ≈ 3.56995 is the onset of chaos in the logistic map function, we choose r = 3.5 and r = 3.8 to present non-chaotic and chaotic dynamics respectively. For a random 4-regular graph with 10 and 30 nodes, our GSO method has obtained very good reconstruction accuracy and the performance obtained on chaotic dynamics is better than that on non-chaotic dynamics.
Time consumption Table 1, 2 and Figure 3 shows the time consumption of different methods on SK model. We compare our proposed method with two baselines: gradient descent (GD) with Adam optimizer and simulated annealing (SA). Although gradient descent takes the least amount of time, its performance is the worst. Compared to simulated annealing, our method takes advantages in both performance and time consumption. As for extremal optimization, it is reported in [27] that it takes nearly 20 hours for N = 1024 and the algorithmic cost is O(N 4 ), which is extremely inefficient and time-consuming. We also plot the dependence of time with system size N in Figure 3. The slope of the log-log plot of time versus N is 1.46, which indicates that the algorithmic cost is less than O(N 2 ).

Conclusion
In this work, we have presented a novel optimization method, Gumbel-softmax optimization (CSO), for solving combinatorial optimization problems on graph. Our method is based on Gumbel-softmax, which allows the gradients passing through samples directly. We treat all vertices in the network are independent and thus the joint distribution is factorized as a product distribution, which enables Gumbel-softmax sample efficiently. Our experiment results show that our method has good performance on all four tasks and also take advantages in time complexity. Comparing to traditional general optimization method, GSO can tackle large graphs easily and efficiently. Though not competitive to state-of-the-art deep learning based method, GSO have the advantage of not requiring neither training the solver nor specific domain knowledge. In general, it is an efficient, general and lightweight optimization framework for solving combinatorial optimization problems on graphs.
However, there is much space to improve our algorithm on accuracy. In this paper, we take the naive mean field approximation as our basic assumption, however, the variables are not independent on most problems. Therefore, much more sophisticated variational inference must considered in the future. Another way to improve accuracy is to combine other skills such as local search in our framework.