A Bi-Level Framework for Learning to Solve Combinatorial Optimization on Graphs

Combinatorial Optimization (CO) has been a long-standing challenging research topic featured by its NP-hard nature. Traditionally such problems are approximately solved with heuristic algorithms which are usually fast but may sacrifice the solution quality. Currently, machine learning for combinatorial optimization (MLCO) has become a trending research topic, but most existing MLCO methods treat CO as a single-level optimization by directly learning the end-to-end solutions, which are hard to scale up and mostly limited by the capacity of ML models given the high complexity of CO. In this paper, we propose a hybrid approach to combine the best of the two worlds, in which a bi-level framework is developed with an upper-level learning method to optimize the graph (e.g. add, delete or modify edges in a graph), fused with a lower-level heuristic algorithm solving on the optimized graph. Such a bi-level approach simplifies the learning on the original hard CO and can effectively mitigate the demand for model capacity. The experiments and results on several popular CO problems like Directed Acyclic Graph scheduling, Graph Edit Distance and Hamiltonian Cycle Problem show its effectiveness over manually designed heuristics and single-level learning methods. Code available at <https://github.com/Thinklab-SJTU/PPO-BiHyb>.

Introduction {#sec:introduction}
============

Combinatorial Optimization (CO) is a family of long-standing optimization problems. A large portion of CO problems is NP-hard due to the combinatorial nature, raising challenges for traditional (exact) solvers on even medium-sized problems. Heuristic algorithms are often adopted to approximately solve CO problems within an acceptable time, and there is a growing trend adopting modern data-driven approaches to solve CO problems that achieve better and faster results @DaiNIPS17.

The major line of works solving CO with machine learning (ML) is single-level @ChenNIPS19 [@HuTOG20; @KaraliasNIPS20; @DaiNIPS17; @MaoSIGCOMM19; @NowakDSW18; @VinyalsNIPS15; @WangPAMI21; @ZhangNIPS20], where the prediction of ML module lies in the solution space, assuming the model has enough capacity learning the input-output mapping of the CO problem. However, achieving such an assumption is non-trivial, leading to the following two aspects of challenges. On the one hand, it is challenging to design a model with enough capacity with limited computational resources, and existing models are usually tailored for specific problems which require heavy trail-and-error @HuTOG20 [@VinyalsNIPS15; @WangPAMI21]. On the other hand, training such a heavy model requires either supervision from high-quality labels @KhalilAAAI16 [@VinyalsNIPS15; @WangCVPR21] which are infeasible to obtain for large-sized problems due to the NP-hard nature, or reinforcement learning (RL) @ChenNIPS19 [@DaiNIPS17; @LuICLR19; @MaoSIGCOMM19] which might be unstable due to the challenges of large action space and sparse reward especially for large-sized problems @sutton2018reinforcement. An alternative approach resorts to a hybrid machine learning and traditional optimization pipeline @DuanAAMAS19 [@GasseNIPS19; @HutHooLey10b; @KhalilAAAI16; @SunNIPSWS20; @WangCVPR21; @XuHutHooLey] hoping to utilize the power of traditional optimization methods. However, designing a general hybrid MLCO approach is still non-trivial, as existing methods @DuanAAMAS19 [@WangCVPR21] usually require domain-specific knowledge for the model design. It is again challenging to obtain high-quality supervision labels, and existing methods are based on either problem-specific surrogate labels @GasseNIPS19 [@KhalilAAAI16; @WangCVPR21], or learned with RL while the challenges of RL still exist @DuanAAMAS19 [@SunNIPSWS20].

In this paper, we propose a general hybrid MLCO approach over graphs. We first reduce the complexity of deep learning model by reformulating the original CO into a bi-level optimization, whose objective is to minimize the long-term upper-level objective by optimizing the graph structure, and the lower-level problem is handled by an existing heuristic. We resort to RL and the traditional heuristic can be absorbed as part of the environment, and it is shown that the sparse reward issue is mitigated for the resulting RL problem compared to previous RL-based methods @ChenNIPS19 [@DaiNIPS17; @LuICLR19; @MaoSIGCOMM19]. Specifically, our model is built with standard building blocks: the input graph is encoded by Graph Convolutional Network (GCN) @KipfICLR17, and the actor and critic modules are based on ResNet blocks @HeResNet and attention models @vaswani2017attention. All modules are learned with the Proximal Policy Optimization (PPO) algorithm @SchulmanPPO17. **The contributions of this paper include:**

-   To combine the best of the two worlds, we propose a general hybrid approach that integrates traditional heuristic solvers with machine learning algorithm.

-   We propose a bi-level optimization formulation for learning to solve CO on graphs. The upper-level optimization adopts a reinforcement learning agent to adaptively modify the graphs, while the lower-level optimization involves traditional learning-free heuristics to solve combinatorial optimization tasks on the modified graphs. Our approach does not require ground truth labels.

-   The experiments for graphs up to thousands of nodes on several popular tasks such as Directed Acrylic Graph scheduling (DAG scheduling), Graph Edit Distance (GED), and Hamiltonian Cycle Problem (HCP) show that our method notably surpasses both traditional learning-free heuristics and single-level learning method. Our method generalizes well to graphs of different sizes while having comparable overhead to the single-level learning methods.

Related Work
============

Here we discuss related works listed in recent surveys  @BengioEJOR20 [@YanIJCAI20; @DBLP:journals/corr/abs-2008-12248]. We present their methodologies and compare with our method.

**Learning the end-to-end solution as a sequence.** The major line of existing MLCO works mainly focus on tackling the problem end-to-end by predicting a sequence of solutions @HuTOG20 [@KaraliasNIPS20; @DaiNIPS17; @LiNIPS18; @MaoSIGCOMM19; @NowakDSW18; @VinyalsNIPS15; @WangPAMI21; @ZhangNIPS20]. The pioneering work @VinyalsNIPS15 is designated for traveling salesman problem (TSP), whereby the sequence-to-sequence Pointer Network (PtrNet) model is learned with supervised learning. In @DaiNIPS17, a graph-to-sequence framework is proposed with graph embedding @DaiICML16 and Q-learning @MnihArixv13 for general CO over graphs, and this general framework inspires the major line of MLCO works with applications to DAG scheduling @MaoSIGCOMM19, graph matching @LiuArxiv20, and job shop scheduling @ZhangNIPS20. @LiNIPS18 extends @DaiNIPS17 by problem reduction and supervised learning-based tree search. The framework in @DaiNIPS17 is treated as the RL baseline in this paper. Our approach differs from these single-level end-to-end RL methods @DaiNIPS17 [@LiuArxiv20; @LuICLR19; @MaoSIGCOMM19], which lack the flexibility to borrow the power of traditional methods and often suffer from the fundamental issues in RL: sparse reward and large action space. **Learning to rewrite end-to-end solutions.** Another line of end-to-end learning works predicts rewriting strategies of an existing solution @ChenNIPS19 [@LuICLR19], where the model predictions also lie in the solution space. The agents learn to improve an existing solution in a decision sequence, and problems like job scheduling, expression simplification and routing problems have been studied. These learning-based local search heuristics also fall within the single-level paradigm, while our method incorporates another optimization over the graph structure. The sparse reward issue also exists for @ChenNIPS19 [@LuICLR19], as a long episode is usually required for searching for a satisfying result.

**One-shot unsupervised end-to-end learning.** There is also a growing trend applying one-shot unsupervised methods for the input-output mapping of CO, with maximum clique and graph cut solved by @KaraliasNIPS20, and quadratic assignment problem solved by @WangPAMI21. However, the generalization ability of these methods is still an open question, and complicated constraints are often non-trivial to be encoded in the network's prediction. Moreover, such a one-shot end-to-end network often calls for much higher model capacity compared with our multi-round alternating optimization paradigm. **Hybrid of machine learning and traditional solvers.** Different from learning the solution end-to-end, researchers also propose hybrid machine learning and traditional solver approaches. ML modules are studied as sub-routines for traditional solvers, especially predicting branching strategies for branch-and-bound with either supervised learning @GasseNIPS19 [@KhalilAAAI16] or reinforcement learning @SunNIPSWS20. In @WangCVPR21, the heuristic routine in A\* algorithm is replaced by graph neural network to solve graph edit distance. However, these methods are tailored for special problems, and our aim is to develop a more general framework, where the learning part and heuristic module are two peers alternatively performed. **Bi-level optimization.** Our method is based on bi-level optimization, which is a family of optimization problems where a lower-level optimization is nested inside an upper-level optimization. Bi-level optimization is in general NP-hard @JeroslowBiLevel1985 [@vicente1994descent], and the applications of bi-level optimization can be found ranging from multi-player games @JeroslowBiLevel1985 to vision tasks @liu2021investigating, and there is a loosely relevant attempt @BagloeeBilevel2018 adopting supervised learning to solve a bi-level optimization for transportation.

![An overview of our bi-level hybrid MLCO solver. The graph structure is optimized at the upper level by an RL agent, and the optimized graphs are solved by heuristics at the lower level. The actions can be any modifications of the edges (i.e. adding, deleting edges and modifying edge attributes), and edge deletion is presented in this example.<span data-label="fig:overview"></span>](overview.pdf){width="\textwidth"}

Our Approach {#sec:approach}
============

In this paper, we propose a ****-level ****rid (BiHyb) machine learning and traditional heuristic approach. Sec. \[sec:preliminary\] shows both single-level and bi-level formulations of CO, and Sec. \[sec:rl\] shows the RL approach to the bi-level CO.

Bi-level Reformulation of Combinatorial Optimization {#sec:preliminary}
----------------------------------------------------

Without loss of generality, we consider the classic single-level CO with a single graph $\mathcal{G}$ as: $$%\begin{gathered}
    \min_{\mathbf{x}} f(\mathbf{x} | \mathcal{G}) \qquad
    s.t. \quad h_i(\mathbf{x}, \mathcal{G}) \leq 0,  \text{for}\ i = 1 ... I
    \label{eq:traditional_co}
%\begin{gathered}$$ where $\mathbf{x}$ denotes the decision variable (i.e. solution), $f(\mathbf{x}| \mathcal{G})$ denotes the objective function given input graph $\mathcal{G}$ and $h_i(\mathbf{x}, \mathcal{G}) \leq 0$ represents the set of constraints. For example, in DAG scheduling, the constraints enforce that the solution $\mathbf{x}$, i.e. the execution order of the DAG job nodes, lies in the feasible space and does not conflict the topological dependency structure of $\mathcal{G}$. The popular framework of existing MLCO methods regards Eq. \[eq:traditional\_co\] as a straight-forward end-to-end learning task, and various training methods have been developed, including: <span>1) supervised learning</span> @NowakDSW18 [@VinyalsNIPS15] obtaining training labels by solving small-scaled Eq. \[eq:traditional\_co\] with traditional solvers, however it is nearly infeasible to solve larger NP-hard problems; <span>2) unsupervised learning</span> @KaraliasNIPS20 [@WangPAMI21] adopting the continuous relaxation of Eq. \[eq:traditional\_co\] as the learning objective, but existing methods face challenges when dealing with complicated constraints; and <span>3) reinforcement learning</span> @ChenNIPS19 [@DaiNIPS17] by predicting $\mathbf{x}$ sequentially, but the reward signal is unavailable until $\mathbf{x}$ reaches a complete solution, leading to the sparse reward issue. To ease the challenges introduced by the single-level formulation, we resort to the classic idea of modifying the original problem to aid problem solving, e.g. adding cutting planes for integer programming @gomory2010outline [@TangICML20]. Our proposed framework is capable of handling CO on graphs if all constraints can be encoded by the graph structure, and our motivation is described by the following hypothesis: The optimal solution $\mathbf{x}^*$ to $\mathcal{G}$ can be acquired by modifying $\mathcal{G}$. And we show the feasibility of this hypothesis for a family of problems by introducing the following proposition:

We define $\mathbb{G}$ as the set of all graphs that can be modified from $\mathcal{G}$, and $\mathbb{X}$ as the set of all feasible solutions of $\mathcal{G}$. If the heuristic algorithm is a surjection from $\mathbb{G}$ to $\mathbb{X}$, for $\mathcal{G}$ and its optimal solution $\mathbf{x}^*$, there must exist $\mathcal{G}^* \in \mathbb{G}$, such that $\mathbf{x}^*$ is the output of the heuristic by solving $\mathcal{G}^{*}$.

By the definition of surjection, since $\mathbf{x}^*\in \mathbb{X}$, there must exist at least one graph $\mathcal{G}^* \in \mathbb{G}$ such that $\mathbf{x}^*$ is the output of the heuristic algorithm by solving $\mathcal{G}^{*}$.

We take *DAG scheduling* as an example to clarify this Proposition. Without loss of generality, we define processing the nodes $1$ to $n$ sequentially as a feasible solution. Then, we can modify the graph as follows: if the edge connecting $i$ to $i+1$ does not exist, it is added. After adding all edges from $1$ to $n$, processing the nodes from $1$ to $n$ sequentially is the only feasible solution, which is also the output of any heuristic algorithm. The above construction method applies for all solutions in $\mathbb{X}$.

**Some Remarks.** Our hypothesis and proposition provide the theoretical grounding of developing graph-modification methods to tackle combinatorial problems. It is worth noting that $\mathcal{G}^*$ only suggests that graph modification is a promising direction and finding $\mathcal{G}^*$ given $\mathcal{G}$ is usually NP-hard in practice. In this paper, we propose to improve the solving quality for heuristic algorithms by finding optimized (not necessarily optimal) graphs by learning based on the bi-level reformulation of the original single-level problem. Due to practical reasons, we restrict the max number of modifications.

In the bi-level reformulation of the original single-level problem, an optimized graph $\mathcal{G}^\prime$ is introduced: $$\begin{split}
    \min_{\mathbf{x}^\prime, \mathcal{G}^\prime} %F(\mathbf{x}^\prime, \mathcal{G}^\prime | \mathcal{G}) \qquad %\\
    %\begin{split}
   \ f(\mathbf{x}^\prime| \mathcal{G}) \qquad 
            s.t. \quad &H_j(\mathcal{G}^\prime, \mathcal{G}) \leq 0,  \text{for}\ j = 1 ... J \\
               & \mathbf{x}^\prime \in \arg \min_{\mathbf{x}^\prime} \left\{ f(\mathbf{x}^\prime| \mathcal{G}^\prime) : h_i(\mathbf{x}^\prime, \mathcal{G}^\prime) \leq 0, \text{for}\ i = 1 ... I \right\}
    %\end{split}
    \label{eq:bilevel_co}
\end{split}$$ where $f(\mathbf{x}^\prime | \mathcal{G}), f(\mathbf{x}^\prime | \mathcal{G}^\prime)$ are the objectives for upper- and lower-level problems, respectively. The lower-level problem is the CO given the optimized graph $\mathcal{G}^\prime$, which is solved by a heuristic algorithm. The solved decision variable $\mathbf{x}^\prime$ is further fed to the upper-level problem, whose objective $f(\mathbf{x}^\prime | \mathcal{G})$ denotes the original CO objective computed by $\mathbf{x}^\prime$. The upper-level constraints $H_j(\mathcal{G}^\prime, \mathcal{G}) \leq 0$ ensure that the feasible space of $\mathcal{G}^\prime$ is a subset of $\mathcal{G}$, and $\mathcal{G}^\prime$ has at most $K$ modification steps from $\mathcal{G}$. The upper-level problem optimizes $\mathcal{G}^\prime$ by an RL agent, by regarding Eq. \[eq:bilevel\_co\] as the environment.

\[tb!\] \[alg:bilevel-rl\] $\mathcal{G}^0 \leftarrow \mathcal{G}$;\

Reinforcement Learning Algorithm {#sec:rl}
--------------------------------

We resort to reinforcement learning to optimize $\mathcal{G}^\prime$ in Eq. \[eq:bilevel\_co\], which can be viewed as a data-driven embodiment of the classic bi-level optimization method by solving two levels of problems alternatively @TalbiBiLevel2013. In Sec. \[sec:MDP\] we present the Markov Decision Process (MDP) formulation of the bi-level optimization in Eq. \[eq:bilevel\_co\], in Sec. \[sec:PPO\] we describe the PPO learning algorithm in our approach.

### The MDP Formulation {#sec:MDP}

Eq. \[eq:bilevel\_co\] is treated as the learning objective and optimized by RL in a data-driven manner. In this section, we discuss the Markov Decision Process (MDP) formulation for adopting RL to this bi-level optimization problem. The policy roll-out steps are summarized in Alg. \[alg:bilevel-rl\]. In the following, $\mathcal{G}^0$ equals $\mathcal{G}$ meaning the original graph, and $\mathcal{G}^{k} (k\neq 0)$ equals $\mathcal{G}^\prime$ meaning the modified graph after action $k$.

**State.** The current graph $\mathcal{G}^k$ is treated as the *state*, whose nodes and edges encode both the problem input and the current constraints. The starting *state* $\mathcal{G}^0$ represents the original CO problem.

**Action.** The *action* is defined as adding, removing or modifying an edge in $\mathcal{G}^k$. Since there are at most $m^2$ edges if $\mathcal{G}^k$ has $m$ nodes, we shrink the action space to $O(m)$ by decomposing the edge selection as two steps: firstly selecting the starting node, and then selecting the ending node.

**State transition.** After taking an *action*, $\mathcal{G}^k$ transforms to $\mathcal{G}^{k+1}$ with one edge modified. The new graph $\mathcal{G}^{k+1}$ is regarded as the new *state* and is adopted for *reward* computation. The episode ends when it reaches the max number of actions $K$. In our implementation, we empirically set $K \leq 20$ for graphs up to thousands of nodes, therefore the sparse reward issue is mitigated compared to single-level RL methods (20 actions v.s. 1000+ actions per episode).

**Reward.** The new graph $\mathcal{G}^{k+1}$ results in a modified lower-level optimization problem whose objective becomes $f(\mathbf{x}^{k+1} | \mathcal{G}^{k+1})$, and $\mathbf{x}^{k+1}$ is solved by an existing heuristic. The *reward* is computed as the decrease of upper-level objective function given $\mathbf{x}^{k+1}$: reward $=f(\mathbf{x}^{k}| \mathcal{G})-f(\mathbf{x}^{k+1} | \mathcal{G})$.

### Proximal Policy Optimization (PPO) {#sec:PPO}

We resort to the popular Proximal Policy Optimization (PPO) @SchulmanPPO17 as the RL framework. PPO is the simplified version of Trust Region Policy Optimization (TRPO) @SchulmanICML15 where the model update is restricted within a "trust region" to avoid model collapse. PPO is easier to implement than TRPO with comparative performance @SchulmanPPO17, maximizing the objective: $
    J(\theta) = \min(r_\theta\cdot A, \ clip(r_\theta, 1-\epsilon, 1+\epsilon)\cdot A)
    \label{eq:ppo}
$ where $r_\theta$ is the importance sampling ratio parameterized by model parameter $\theta$, $A$ is the advantage value computed by the discounted accumulative reward minus the critic network prediction, and $\epsilon$ is a hyperparameter controlling the boundary of trust region. Some common policy-gradient training tricks are also adopted: we normalize the accumulated rewards during model update, and we add an entropy regularizer to encourage exploration beyond local optimums.

Experiments and Case Studies {#sec:exp-and-case-study}
============================

We show the implementations and experiments on three challenging CO problems: DAG scheduling in Sec. \[sec:dag\], graph edit distance (GED) in Sec. \[sec:ged\], and Hamiltonian cycle problem (HCP) in Sec. \[sec:hcp\]. Our bi-level RL method PPO-BiHyb is compared with learning-free heuristics, and a single-level RL peer method namely PPO-Single following the general framework @DaiNIPS17, which also covers the majority of RL-based methods @fu2021aaai [@HuTOG20; @kool2018attention; @LiuArxiv20; @MaoSIGCOMM19; @ZhangNIPS20]. We also implement Random-BiHyb which performs random graph modification under our bi-level optimization framework. The model capacity and training/inference time of PPO-Single are kept in line with PPO-BiHyb for fair comparison.

Case 1: DAG Scheduling {#sec:dag}
----------------------

The Directed Acyclic Graph (DAG) is the natural representation of real-world jobs with dependency, and the DAG scheduling problem is the abstraction of parallel job scheduling in computer clusters: each node represents a computation job with a running time and a resource requirement, and the node may have several parents and children representing data dependency. The cluster has limited total resources, and jobs can be executed in parallel if there are enough resources and the concurrent jobs do not have data dependency. Such an optimization problem is in general NP-hard @Forti2006dag, and the objective is to minimize the makespan of all jobs, i.e. finish all jobs as soon as possible.

### Implementation Components {#sec:dag-impl}

**MDP Formulation.** As shown in Fig. \[fig:state-action-reward-dag\], *state* is the current DAG $\mathcal{G}^{k}$, *action* is defined as adding an edge to $\mathcal{G}^{k}$, resulting in a new DAG $\mathcal{G}^{k+1}$. The added edge enforces additional constraints such that the decision space is cut down to elevate the heuristic's performance. Here $\mathbf{x}$ represents the scheduled execution order, and the Critical Path heuristic is adopted on $\mathcal{G}^{k+1}$ to compute $\mathbf{x}^{k+1}$. The *reward* is computed by subtracting the previous makespan by the new makespan: $f(\mathbf{x}^{k}| \mathcal{G})-f(\mathbf{x}^{k+1}| \mathcal{G})$.

**State Encoder.** We adopt GCN @KipfICLR17 to encode the state represented by DAG. Considering the structure of DAG, we design two GCNs: the first GCN processes the original DAG, and the second GCN processes the DAG with all edges reversed. The node embeddings from two GCN modules are concatenated, and an attention pooling layer is adopted to extract a graph-level embedding. $$\mathbf{n} = \left[\text{GCN}_1(\mathcal{G}^{k})\ || \ \text{GCN}_2(\text{reverse}(\mathcal{G}^{k}))\right], \ \mathbf{g} = \text{Att}(\mathbf{n})$$ where $\mathbf{n}$ (\# of nodes $\times$ embedding dim) is the node embedding, $\left[ \cdot\ ||\ \cdot \right]$ means concatenation.

**Actor Net.** To reduce action space, the edge selection is decomposed into two steps: first selecting the starting node and then the ending node. The action probabilities of selecting the starting and ending nodes are predicted by two independent 3-layer ResNets blocks @HeResNet, respectively, and the input of the second ResNet contains additionally the feature vector of the selected starting node. $$P(\mathbf{a}_1) = \text{softmax}(\text{ResNet}_1(\left[\mathbf{n}\ ||\ \mathbf{g}\right])),\
    P(\mathbf{a}_2|\mathbf{a}_1) = \text{softmax}(\text{ResNet}_2(\left[\mathbf{n}\ ||\ \mathbf{n}[\mathbf{a}_1]\ ||\ \mathbf{g}\right]))$$ the subscript of $\mathbf{n}[\mathbf{a}_1]$ denotes the embedding for a node $\mathbf{a}_1$. For training, we sample $\mathbf{a}_1, \mathbf{a}_2$ according to their probabilities $P(\mathbf{a}_1), P(\mathbf{a}_2|\mathbf{a}_1)$ respectively. For testing, beam search is performed with a width of 3: actions with top-3 highest probabilities are searched, and all searched actions are evaluated by the improvement of makespan, and only the top-3 actions are maintained for the next search step.

**Critic Net.** It is built by max pooling over all node features, and the pooled feature is concatenated with the graph feature from state encoder, and finally processed by another ResNet for value prediction. $$\widetilde{V}(\mathcal{G}^{k}) = \text{ResNet}_3\left([\text{maxpool}(\mathbf{n}) \ ||\ \mathbf{g}]\right)$$

\[11\]<span>r</span><span>0.5</span>

\[t\]<span>1</span>

![image](tpch-generalization.pdf){width="\textwidth"}

**Heuristic Methods.** Solving DAG scheduling with hundreds of nodes is nearly infeasible for existing commercial solvers, and real-world scheduling problems are usually tackled by fast heuristics e.g. *Shortest Job First* which schedules the shortest job greedily and *Critical Path* algorithm which prioritizes jobs on the critical path. We also consider the novel *Tetris* scheduling @GrandlSIGCOMM14 where jobs are arranged as a Tetris game on the two-dimension space of makespan and resource. Since *Critical Path* is empirically effective, we use it as the lower level optimization algorithm in our PPO-BiHyb learning method.

**Learning Methods.** There are some efforts to train a scheduler in data centers with RL @MaoSIGCOMM19 and learning a job shop scheduler with RL @ZhangNIPS20. They can be viewed as embodiments with tailored techniques for specific problems based on the end-to-end single-level pipeline @DaiNIPS17. Since the problem settings in @MaoSIGCOMM19 [@ZhangNIPS20] are different with ours, we re-implement the single-level RL baseline PPO-Single following @DaiNIPS17, where the model details are in line with our PPO-BiHyb. To validate the effectiveness of PPO, we also compare Random-BiHyb which performs random search instead of PPO when modifying the graph, and its search steps are equal to PPO-BiHyb.

\[tab:dag\]

### Experimental Results {#sec:dag-exp}

Results are reported for scheduling jobs from TPC-H dataset[^3], which is composed of business-oriented queries and concurrent data modifications, represented by Directed Acyclic Graphs (DAGs). Each DAG represents a unique computation job, and each node in DAG has two properties: execution time and resource requirement. The DAG in TPC-H dataset has 9.18 nodes in average, and the smallest job has 2 nodes and the largest one has 18 nodes. The average resource requirement is 125.8, and the minimum is 1 and the maximum is 593. The average task duration is 1127.2 sec, and the minimum is 16.3 sec and the maximum is 4964.5 sec. We jointly schedule multiple DAGs and assume there are 6000 total resources (i.e. the heaviest job node consumes around 10% of total resources), to reflect real-world business scenarios. We build 50 training and 10 testing samples for all experiments, where each sample is composed of a number of DAGs (e.g. 50, 100, 150) which are randomly sampled from the TPC-H dataset with fixed random seed.

Table \[tab:dag\] reports the result on scheduling jobs from TPC-H dataset, where our PPO-BiHyb outperforms learning-free heuristics and the single level learning method. We control the beam search width of PPO-Single as 10 allowing its inference time to be $10\times$ longer than ours, but its performance is still inferior to the heuristic Critical Path method. Random-BiHyb can improve the lower-level heuristic algorithm but its performance is still inferior to PPO-BiHyb, suggesting the effectiveness of both our bi-level optimization framework and PPO training. We also study the generalization of our learning approach, which is critically important for real-world applications. As shown in Fig. \[fig:dag-generalization\], our models are learned with TPC-H-50/100/150 datasets, and we report their test results on the unseen datasets ranging from TPC-H-50 to 300 at 50 interval. The plotted results are the improvement of makespan w.r.t. Critical Path. All our learning models generalize well with unseen data, even on larger problems with up to 300 DAGs ($\sim$2800 nodes). The generalization results of PPO-Single are omitted because they are consistently inferior to the Critical Path heuristic. The reason that our method generalizes soundly, in our analysis, is because learning the graph-optimization strategy is easier compared to directly learning the solution, and the strength of heuristics is exploited with our approach.

Case 2: Graph Edit Distance {#sec:ged}
---------------------------

The graph edit distance (GED) problem is NP-hard @AbuICPRAM15 and can be readily used in modeling a family of pattern recognition tasks requiring to measure the similarity between graphs, with applications to drug discovery @RiesenSSPR08, malware detection @LiICML19 and scene graph edition @ChenECCV20. Given two graphs, the objective is finding the cheapest edit path from one graph to the other, and the costs of edit operations are defined by problem-specific distance metrics. For example, for molecule graphs, we may define an edit cost between different atom types (i.e. different node types), and also an edit cost for creating/removing a chemical bound (i.e. adding/removing an edge).

### Implementation Components {#implementation-components}

**Bi-level Optimization Formulation.** Since GED involves two graphs, the formulation of the bi-level optimization of GED is a generalization from Eq. \[eq:bilevel\_co\]: $$\begin{split}
    \min_{\mathbf{x}^\prime, \mathcal{G}^\prime_1} 
   \ f(\mathbf{x}^\prime| \mathcal{G}_1, \mathcal{G}_2) \qquad 
            s.t. \quad &H_j(\mathcal{G}^\prime_1, \mathcal{G}_1) \leq 0,  \text{for}\ j = 1 ... J \\
               & \mathbf{x}^\prime \in \arg \min_{\mathbf{x}^\prime} \left\{ f(\mathbf{x}^\prime| \mathcal{G}^\prime_1, \mathcal{G}_2) : h_i(\mathbf{x}^\prime, \mathcal{G}^\prime_1, \mathcal{G}_2) \leq 0, \text{for}\ i = 1 ... I \right\}
    \label{eq:bilevel_co_2graphs}
\end{split}$$ where $f(\mathbf{x}^\prime| \mathcal{G}_1, \mathcal{G}_2)$ is the upper-level objective: the graph edit cost given $\mathcal{G}_1, \mathcal{G}_2$ and $\mathbf{x}^\prime$. The decision variable $\mathbf{x}^\prime$ encodes the node editions from $\mathcal{G}_1$ to $\mathcal{G}_2$, based on which the edge editions can be induced. The upper-level constraints $H_j(\mathcal{G}^\prime_1, \mathcal{G}_1) \leq 0$ ensure that $\mathcal{G}^\prime_1$ has at most $K$ modification steps from $\mathcal{G}_1$. The lower-level GED problem is defined between $\mathcal{G}_2$ and the modified $\mathcal{G}_1^\prime$, where $f(\mathbf{x}^\prime| \mathcal{G}^\prime_1, \mathcal{G}_2)$ is the lower-level objective, and $h_i(\mathbf{x}^\prime, \mathcal{G}^\prime_1, \mathcal{G}_2) \leq 0$ are the constraints of the lower-level GED.

**MDP Formulation.** As shown in Fig. \[fig:state-action-reward-ged\], since there are two graphs, we discriminate the graphs by subscripts $\mathcal{G}_1, \mathcal{G}_2$, and the MDP formulation is a generalized version of Sec. \[sec:MDP\]. More specifically, the RL agent is restricted to modifying $\mathcal{G}_1$ and keeping $\mathcal{G}_2$ fixed. The *state* is defined as the current version of first graph $\mathcal{G}_1^k$, and *action* is defined as adding or removing an edge from $\mathcal{G}_1^k$. The new graph $\mathcal{G}_1^{k+1}$ is designed to better align with $\mathcal{G}_2$, where the node-to-node alignment is encoded by the decision variable $\mathbf{x}^{k}$ which is obtained by solving $f(\mathbf{x}^{k} | \mathcal{G}_1^{k}, \mathcal{G}_2)$ with IPFP heuristic. The upper-level objective $f(\mathbf{x}^k | \mathcal{G}_1, \mathcal{G}_2)$ is computed as the edit distance between the original graphs $\mathcal{G}_1, \mathcal{G}_2$ using $\mathbf{x}^{k}$.

**State Encoder.** The state encoder is built with GCN @KipfICLR17 to aggregate graph features and Sinkhorn-Knopp (SK) network @SinkhornAMS64 for propagation across two graphs. Following @WangPAMI20, the SK module accepts a similarity matrix (by inner-product of $\mathbf{n}_1$ and $\mathbf{n}_2$), and outputs a doubly-stochastic matrix which can be utilized as the cross-graph propagation weights. As the action is taken on the first graph, we compute the difference of the node features of graph 1 and the propagated features from graph 2 through SK net. Similar to the DAG model, graph-level features are obtained via attention pooling. $${
    \mathbf{n}_1=\text{GCN}(\mathcal{G}_1^k), \ \mathbf{n}_2 = \text{GCN}(\mathcal{G}_2), \ \mathbf{n} = \mathbf{n}_1 - \text{SK}(\mathbf{n}_1 \mathbf{n}_2^\top) \cdot \mathbf{n}_2; \ \mathbf{g}_1 = \text{Att}(\mathbf{n}_1), \ \mathbf{g}_2 = \text{Att}(\mathbf{n}_2)
}$$

**Actor Net.** The action of selecting an edge to add or delete is also decomposed by two node-selection steps. The starting node selection is predicted by 3-layer ResNet module, and the ending node selection is predicted by an attention query. The edge is deleted if it already exists, or added otherwise. The beam width is set as 3 during evaluation. $$P(\mathbf{a}_1) = \text{softmax}\left(\text{ResNet}(\mathbf{n})\right),\ P(\mathbf{a}_2|\mathbf{a}_1) = \text{softmax}(\mathbf{n} \cdot \text{tanh}(\text{Linear}\left(\mathbf{n}[\mathbf{a}_1])\right)^\top)$$

**Critic Net.** We follow the graph-wise similarity learning method @BaiWSDM19 to implement the critic net, where the graph-level features are processed by a neural tensor network (NTN) @SocherNIPS13 followed by 2 fully-connected regression layers whose output is one-dimensional: $$\widetilde{V}(\mathcal{G}^{k}_1, \mathcal{G}_2) = \text{fc}\left(\text{NTN}\left(\mathbf{g}_1, \mathbf{g}_2\right)\right)$$

**Heuristic Methods.** Based on the comprehensive evaluation on different GED heuristics by @BlumenthalVLDBJ20, we select 4 best-performing heuristics: *Hungarian* @RiesenIVC09 which simplifies the original problem to a bipartite matching problem, *RRWM* @ChoECCV10 which solves GED via relaxed quadratic programming, *Hungarian-Search* @RiesenMLG07 which is a search algorithm guided by Hungarian heuristic, and *IPFP* @BougleuxICPR16 which combines searching and quadratic programming. We empirically find *IPFP* best performs among all heuristics, therefore we base our PPO-BiHyb method on it.

**Learning Methods.** There are efforts to learn graph-wise similarity via deep learning @BaiWSDM19 [@LiICML19], which are regression models and ignores the combinatorial nature of graph similarity problems. @WangCVPR21 proposes neural-guided A\* search, however, the learning is supervised. In this paper, we compare with PPO-Single by reimplementing @LiuArxiv20 for GED. The model details and RL algorithm are kept in line with our PPO-BiHyb for fair comparison. The beam search width of PPO-Single is set to 20 so that the inference time of PPO-Single is comparable with our hybrid method. We also compare with Random-BiHyb which performs equal step numbers of random search w.r.t. PPO-BiHyb.

### Experimental Results {#sec:ged-exp}

\[10\]<span>r</span><span>0.3</span>

![image](ged-confusion-matrix.pdf){width="30.00000%"}

Results on GED are reported on AIDS dataset[^4] containing chemical compounds for anti-HIV research @RiesenSSPR08. The atoms are treated as nodes, and the atom types are encoded by one-hot features and we define an edit cost of 1 for different node types. Besides, we also define the cost for node/edge addition/deletion as 1. The AIDS dataset is split into three subsets w.r.t. the size of graphs, namely AIDS-20/30, AIDS-30/50, and AIDS-50+, and we exclude graphs smaller than 20 nodes because they are less challenging and can be solved exactly within several hours. We randomly build 50 training and 10 testing samples for all tests with fixed random seed.

The evaluation for GED on AIDS is presented in Tab. \[tab:ged\_aids\], where our method surpasses all learning-free heuristics and also performs better than single-level RL baseline PPO-Single. We also conduct a generalization study among different problem sizes, and Fig. \[fig:ged\_confusion\_mat\] shows the objective scores from the sensitivity test for training/testing on GED problems with different sizes. The color map represents the percentage of improvement w.r.t. IPFP, where the darker color means more improvement. Our model can generalize to problem sizes unseen during training, but the generalized performance is usually inferior compared to training and testing with the same problem size.

Case 3: Hamiltonian Cycle Problem {#sec:hcp}
---------------------------------

The Hamiltonian cycle problem (HCP) arises from the notable problem of seven bridges of Königsberg proposed by Leonhard Eule @euler1741solutio. Given a graph, the HCP arises as a decision problem on whether there exists a Hamiltonian cycle, which is known to be NP-complete @Gare90NPComplete. We handle HCP by transforming it into the more general traveling salesman problem (TSP) in a fully-connected graph, where the existing edges in HCP are defined with length 0, and non-existing edges are with length 1. If a tour is found whose length is 0, then it is a Hamiltonian cycle. It is worth noting that HCP has not been discussed by most ML-TSP works @fu2021aaai [@joshi2019efficient; @kool2018attention; @VinyalsNIPS15], which focus on the special case of Euclidean TSP with 2D coordinates.

### Implementation Components {#implementation-components-1}

**MDP Formulation.** \[sec:hcp-mdp\] The HCP instances are converted to TSP as discussed above, to leverage existing powerful TSP heuristics. As shown in Fig. \[fig:state-action-reward-hcp\], *state* is defined as the current graph $\mathcal{G}^{k}$ and *action* is defined as increasing an edge length in $\mathcal{G}^{k}$, resulting in a new graph $\mathcal{G}^{k+1}$. The increase of edge length softly prohibits the heuristic from traveling this edge and the LKH method @helsgaun2000effective is adopted on graph $\mathcal{G}^{k+1}$ to obtain the new tour $\mathbf{x}^{k+1}$. The *reward* is the decrease of the current tour length w.r.t. the previous tour length: $f(\mathbf{x}^{k}|\mathcal{G})-f(\mathbf{x}^{k+1}|\mathcal{G})$.

**State Encoder.** We encode HCP graph with GCN @KipfICLR17. The node embeddings from GCN modules are then processed by an attention pooling layer to extract a graph-level embedding. $$\mathbf{n} = \text{GCN}(\mathcal{G}^{k}), \ \mathbf{g} = \text{Att}(\mathbf{n})$$

**Actor Net.** After obtaining the tour solved by the heuristic algorithm, we increase the length of any selected edge by 10 from the tour (10 is randomly set, and our approach seems not sensitive to this number), which empirically makes the edge harder to be selected in a tour later. The first action probabilities of selecting the starting node are predicted by a 3-layer ResNet block @HeResNet. The second action is selecting the ending node, which is adjacent to the starting node on the tour and is predicted by an attention query. $$P(\mathbf{a}_1) = \text{softmax}(\text{ResNet}_1(\left[\mathbf{n}\ ||\ \mathbf{g}\right])),\
    P(\mathbf{a}_2|\mathbf{a}_1) = \text{softmax}\left(\mathbf{n} \cdot \text{tanh}(\text{Linear}( \mathbf{n}[\mathbf{a}_1]))^\top\right)$$

For training, we sample $\mathbf{a}_1, \mathbf{a}_2$ according to $P(\mathbf{a}_1), P(\mathbf{a}_2|\mathbf{a}_1)$. For evaluation, we perform a beam search with a width of 12 and maintain the top-12 actions by the improvement of the LKH algorithm.

**Critic Net.** It is built by max-pooling from all node features, and the pooled feature is concatenated with the graph-level feature from the state encoder, which are finally processed by a 3-layer ResNet. $$\widetilde{V}(\mathcal{G}^{k}) = \text{ResNet}_2\left(\left[\text{maxpool}(\mathbf{n}) \ ||\ \mathbf{g}\right]\right)$$

**Heuristic Methods.** The performance of heuristics varies with the sizes and characteristics of instances. We choose three algorithms, *Nearest Neighbour* @reinelt2003traveling who greedily travels to the next nearest node, *Farthest Insertion* @rosenkrantz1977analysis who repeatedly insert the non-traveled node with the farthest distance to the existing tour, and the third version of *Lin-Kernighan Heuristic (LKH3)* @helsgaun2000effective which succeeds in discovering the best-known solutions for many TSP instances. For LKH3, we can set the number of random restarts (5 by default) to trade-off time for accuracy. We name the default LKH config as *LKH3-fast* which is also adopted for lower-level optimization in our PPO-BiHyb for its time-efficiency, and we also compare with *LKH3-accu* with 100 random restarts.

\[9\]<span>r</span><span>0.46</span>

<span>0.98</span>

\[tab:hcp\]

**Learning Methods.** Most deep learning TSP models are designated to handle fully connected 2D Euclidean TSP @fu2021aaai [@joshi2019efficient; @kool2018attention; @VinyalsNIPS15], which is a different setting compared to our HCP testbed. Therefore, we implement PPO-Single following the most general framework @DaiNIPS17, and the model details are kept in line with our PPO-BiHyb. We also compare with the Random-BiHyb baseline.

### Experimental Results {#experimental-results}

We use the FHCP benchmark @FHCPdataset composed of 1001 hard HCP instances. All instances are known to have valid Hamiltonian cycles, however, finding them is non-trivial for standard HCP/TSP heuristics. Table \[tab:hcp\] shows the result from a subset of FHCP benchmark. As mentioned in Sec. \[sec:hcp-mdp\], we convert HCP instances to binary TSP instances, whose tour lengths are denoted as "TSP objective". When the TSP objective is 0, it means that a Hamiltonian cycle is found. We use 50 training instances and 20 testing instances, and the model is trained on graphs of sizes from 250 to 500. Our method is comparative with the novel heuristic *LKH3-accu* and can even surpass in terms of found Hamiltonian cycles, which is the objective of HCP. We set the beamwidth of PPO-Single as 12 allowing its inference time to be $10\times$ longer than ours, but its performance is still inferior to our bi-level PPO-BiHyb. The Random-BiHyb baseline also improves the performance of LKH3-fast which is adopted for solving the lower-level problem.

Discussions {#sec:discussion}
===========

**Limitations in model design.** In this paper, we adopt the vanilla GCN implemented by TorchGeometric @TorchGeometric, and the detailed configurations can be found in Appendix \[sec:hyperparameter\]. The main purpose of our model design is to validate the effectiveness of the proposed bi-level optimization framework, and we adopt standard building blocks without heavy engineering, from which perspective we agree that there are room for further improvement. One possible direction may be adopting GNN-neural architecture search methods @GaoIJCAI20 [@ZhaoICDE21]. **Potential negative impacts.** Our approach may potentially decrease the job opportunities and burden the workload of employees in companies, and it calls for the companies and social groups to take more responsible roles when facing the negative effects that come along with optimization tools.

**Conclusion.** We present a bi-level optimization framework based on hybrid machine learning and traditional heuristics, where the graph structure is optimized by RL to narrow down the feasible space of combinatorial problems. The new optimization problems are solved by fast heuristics. Experiments on large real-world combinatorial problems show the effectiveness of our approach. Our method also shows good generalization ability from small training instances to larger testing instances.

This work was partly supported by National Key Research and Development Program of China (2020AAA0107600), Shanghai Municipal Science and Technology Major Project (2021SHZDZX0102), NSFC (U19B2035, 61972250, 72061127003), and Ant Group through Ant Research Program. The author Runzhong Wang was also partly supported by Wen-Tsun Wu Honorary Doctoral Scholarship, AI Institute, Shanghai Jiao Tong University. We would also like to thank Chang Liu, Jia Yan and Runsheng Gan for their valuable discussions when we were working on this paper.

Checklist {#checklist .unnumbered}
=========

1.  For all authors...

    1.  Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?

    2.  Did you describe the limitations of your work?

    3.  Did you discuss any potential negative societal impacts of your work?

    4.  Have you read the ethics review guidelines and ensured that your paper conforms to them?

2.  If you are including theoretical results...

    1.  Did you state the full set of assumptions of all theoretical results?

    2.  Did you include complete proofs of all theoretical results?

3.  If you ran experiments...

    1.  Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?

    2.  Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?

    3.  Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?

    4.  Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?

4.  If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...

    1.  If your work uses existing assets, did you cite the creators?

    2.  Did you mention the license of the assets?

    3.  Did you include any new assets either in the supplemental material or as a URL?

    4.  Did you discuss whether and how consent was obtained from people whose data you're using/curating?

    5.  Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?

5.  If you used crowdsourcing or conducted research with human subjects...

    1.  Did you include the full text of instructions given to participants and screenshots, if applicable?

    2.  Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?

    3.  Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?

Comparison with Other General MLCO Frameworks {#sec:mlco-comparison}
=============================================

Since obtaining ground-truth labels is non-trivial for NP-hard combinatorial tasks, there exist several efforts developing general MLCO methods without any requirement of ground-truth labels, including @ChenNIPS19 [@KaraliasNIPS20; @DaiNIPS17], our single-level baseline PPO-Single and our proposed PPO-BiHyb. Here we make a comparison concerning the model details and the capable problems of these methods.

We would also like to discuss the limitations of the approaches including ours. For S2V-DQN @DaiNIPS17 and NeuRewritter @ChenNIPS19, training the RL model is challenging due to the sparse reward and large action space issues especially for large-scale problems. Specifically, for graphs with $m$ nodes, the action space of S2V-DQN and NeuRewritter is $m$, and S2V-DQN requires $O(m)$ actions to terminate for most problems when the number of decisions is proportional to $m$. This conclusion also holds for PPO-Single. NeuRewritter may take any number of actions, but the more actions it takes, the more likely it will reach a better solution. In comparison, the action space of our PPO-BiHyb is $m^2$ (and decomposed as two sub-actions with space $m$), and the number of actions is restricted under 20 for graphs up to 2800 nodes. Therefore, from the perspective of learning, we cut the number of actions (i.e. mitigate the sparse reward issue) to ease RL training.

As shown in Tab. \[tab:mlco-comparison\], the PPO-Single that serves as a baseline in our paper is designed following S2V-DQN @DaiNIPS17, and we set the RL method as PPO and use beam search when decoding, to make a fair comparison between PPO-Single and PPO-ByHib.

Erdős GNN @KaraliasNIPS20 is a novel framework with unsupervised learning, however, its main limitation is that this framework is incapable of handling constraints beyond simple node constraints. As shown in Tab. \[tab:mlco-comparison\], NerRewritter is most general because it can be viewed as a learning-based local search meta-heuristic that represents the family of meta-heuristics including popular algorithms e.g. simulated annealing and genetic algorithm, and S2V-DQN and our PPO-BiHyb can handle most CO over graphs. It is also worth noting that there are some problems that are beyond our knowledge to tackle, e.g. the expression simplify problem, and it may requires experts with specific domain knowledge to generalize our proposed framework to more combinatorial problems.

Implementation Details on PPO-Single
====================================

We have discussed the model details of PPO-BiHyb in Sec. \[sec:exp-and-case-study\], and in this section, we discuss the model details of the single-level RL baseline PPO-Single.

Case 1: DAG Scheduling {#case-1-dag-scheduling}
----------------------

**MDP Formulation.** Following the implementation from @MaoSIGCOMM19, the job nodes are scheduled in sequential order with PPO-Single. Here *state* is the current DAG $\mathcal{G}^k$ with a timestamp, and some of the nodes are already scheduled by the current timestamp. To represent the current state of the problem, the finished nodes, running nodes and unscheduled nodes are marked by different node attributes, so that the state information is fully encoded by the nodes and edges of $\mathcal{G}^k$. *Action* is defined as scheduling the next node to be executed, and we define a "wait" action to move timestamp until the next event when any node finishes. After a node finishes, it will free some resources, and sometimes add some available nodes to be scheduled. The *reward* is computed as the negative makespan time.

**State Encoder.** In line with PPO-BiHyb, we also adopt GCN @KipfICLR17 to encode the state represented by DAG. Considering the structure of DAG, we design two GCNs: the first GCN processes the original DAG, and the second GCN processes the DAG with all edges reversed. The node embeddings from two GCN modules are concatenated, and an attention pooling layer is adopted to extract a graph-level embedding. $$\mathbf{n} = \left[\text{GCN}_1(\mathcal{G}^{k})\ || \ \text{GCN}_2(\text{reverse}(\mathcal{G}^{k}))\right], \ \mathbf{g} = \text{Att}(\mathbf{n})$$

**Actor Net.** Following PPO-BiHyb, the action net is built with a 3-layer ResNets block @HeResNet. Since we are adopting a single-level RL method, only one action is selected at each step: $$P(\mathbf{a}) = \text{softmax}(\text{ResNet}_1(\left[\mathbf{n}\ ||\ \mathbf{g}\right]))$$ For training, we sample $\mathbf{a}$ according to $P(\mathbf{a})$. For testing, beam search is performed with a width of 10: actions with top-10 highest probabilities are searched, and all searched actions are evaluated by their current makespan, and only the best-10 actions are maintained for the next search step.

**Critic Net.** Also in line with PPO-BiHyb, the critic net is built by max pooling over all node features, and the pooled feature is concatenated with the graph feature from state encoder, and finally processed by another ResNet for value prediction. $$\widetilde{V}(\mathcal{G}^{k}) = \text{ResNet}_2\left([\text{maxpool}(\mathbf{n}) \ ||\ \mathbf{g}]\right)$$

Case 2: Graph Edit Distance {#case-2-graph-edit-distance}
---------------------------

**MDP Formulation.** Our embodiment of PPO-Single on GED follows @LiuArxiv20. Since there are two graphs, we discriminate the graphs by subscripts $\mathcal{G}_1, \mathcal{G}_2$. The *state* is defined as the current partial solution between two graphs. At each *action*, the RL agent is required to firstly select a node from $\mathcal{G}_1$ and then select a node from $\mathcal{G}_2$. We further add "void nodes" to stand for node addition/deletion operations. *Reward* is defined as the negative edit length obtained by editing $\mathcal{G}_1$ to $\mathcal{G}_2$.

**State Encoder.** The state encoder is built with GCN @KipfICLR17 to aggregate graph features and the differentiable Sinkhorn-Knopp (SK) algorithm @SinkhornAMS64 for message passing across two graphs, and such designs are in line with our PPO-BiHyb. $$\mathbf{n}_1=\text{GCN}(\mathcal{G}_1), \ \mathbf{n}_2 = \text{GCN}(\mathcal{G}_2), \ \mathbf{S} = \text{SK}(\mathbf{n}_1 \mathbf{n}_2^\top)$$ The predicted doubly-stochastic matrix by SK is processed by considering the partial matching matrix. For PPO-Single, if one node is already matched, we assign the corresponding row/column in $\mathbf{S}$ as the known matching information, and we get the modified matrix $\mathbf{S}^\prime$. The difference of node features between two graphs is obtained: $$\mathbf{n} = \mathbf{n}_1 - \mathbf{S}^\prime \cdot \mathbf{n}_2$$ Graph-level features are obtained via attention pooling, which are fed to the critic net. It is worth noting that the matched nodes and the corresponding edges are occluded when computing the graph-level features. $$\mathbf{g}_1 = \text{Att}(\mathbf{n}_1), \ \mathbf{g}_2 = \text{Att}(\mathbf{n}_2)$$

**Actor Net.** Since we are aiming to predict the edit operations from $\mathcal{G}_1$ to $\mathcal{G}_2$, the actor net is designed to selected two nodes from two graphs separately. The node selection from the first graph is done by a ResNet module, and the node selected from the second graph is done by an attention query based on the selected first node. $$P(\mathbf{a}_1) = \text{softmax}\left(\text{ResNet}(\mathbf{n})\right),\ P(\mathbf{a}_2|\mathbf{a}_1) = \text{softmax}(\mathbf{n}_2 \cdot \text{tanh}(\text{Linear}\left(\mathbf{n}[\mathbf{a}_1])\right)^\top)$$ $P(\mathbf{a}_1),P(\mathbf{a}_2|\mathbf{a}_1)$ are used to sample the actions $\mathbf{a}_1, \mathbf{a}_2$ in training, and the beamwidth is set as 10 for evaluation.

**Critic Net.** Following PPO-BiHyb, the graph-level features are processed by the neural tensor network (NTN) @SocherNIPS13 followed by 2 fully-connected regression layers whose output is the one-dimensional value prediction: $$\widetilde{V}(\mathcal{G}_1, \mathcal{G}_2) = \text{fc}\left(\text{NTN}\left(\mathbf{g}_1, \mathbf{g}_2\right)\right)$$

Case 3: Hamiltonian Cycle Problem {#case-3-hamiltonian-cycle-problem}
---------------------------------

**MDP Formulation.** Since we handle HCP by transforming it to a TSP, our implementation of PPO-Single on HCP is in line with @DaiNIPS17, where *state* is defined as the graph $\mathcal{G}^k$, and the current partial tour is encoded by the edges of $\mathcal{G}^k$ as a weight of 10. In comparison, the edge weights of the original graph can be only 0 or 1. *Action* is defined as selecting the next node to be visited. The *reward* is defined as the negative value of the current tour length.

**State Encoder.** Following PPO-BiHyb, we encode HCP graph with GCN @KipfICLR17. The node embeddings from GCN modules are then processed by an attention pooling layer to extract graph-level embeddings. $$\mathbf{n} = \text{GCN}(\mathcal{G}^{k}), \ \mathbf{g} = \text{Att}(\mathbf{n})$$

**Actor Net.** Following @DaiNIPS17 [@VinyalsNIPS15], the action of selecting the next visited node is achieved by attention. More specifically, the attention query is the feature of the previous visited node, and the keys are the features of all non-visited nodes. $$P(\mathbf{a}^k|\mathbf{a}^{k-1}) = \text{softmax}\left(\mathbf{n} \cdot \text{tanh}(\text{Linear}( \mathbf{n}[\mathbf{a}^{k-1}]))^\top\right)$$ Here $\mathbf{a}^k$ means the action at step $k$, and $\mathbf{a}^0$ is fixed as the first node. For training, we sample $\mathbf{a}^k$ according to $P(\mathbf{a}^k|\mathbf{a}^{k-1})$. For evaluation, we perform a beam search with a width of 12 and maintain the best-12 actions by the tour length.

**Critic Net.** In line with PPO-BiHyb, the critic net is built by max-pooling from all node features, and the pooled feature is concatenated with the graph-level feature from the state encoder. The features are then processed by a 3-layer ResNet module. $$\widetilde{V}(\mathcal{G}^{k}) = \text{ResNet}\left(\left[\text{maxpool}(\mathbf{n}) \ ||\ \mathbf{g}\right]\right)$$

Model Hyperparameters {#sec:hyperparameter}
=====================

In this section we describe the model parameters for both PPO-Single in Tab. \[tab:hparam-bihyb\] and PPO-BiHyb in Tab. \[tab:hparam-single\]. The model structures are kept to be the same, and some training/evaluation statistics might be different concerning the differences between single-level and bi-level frameworks. Take the DAG scheduling problem as an example, the number of actions in each episode is different between these two methods. For a scheduling problem with $m$ nodes, the single-level PPO-Single requires more than $m$ actions to reach a complete solution (including the "wait" actions we defined for PPO-Single), but the number of actions in PPO-BiHyb is restricted to be $K$, and we empirically set $K=20$ to produce satisfying results. Since the PPO-Single is with a longer episode, we set larger $\gamma=0.99$ hoping the agent will focus more on the long-term reward in the long episode. We also increase the number of timesteps between two model updates for PPO-Single to reduce the variance of gradients. The width of beam search is also different to ensure that the inference time of PPO-Single is no less than ours, but as shown in the main paper, the performance of PPO-Single is still inferior to our PPO-BiHyb given more time budgets. We set the upper-limit of training time to be 48 hours for all models.

We also set separate learning rates for the GNN module and the other modules, because we empirically find the GNN easy to collapse when learning with reinforcement learning on combinatorial optimization. Besides, there are some recent attempts (e.g. submission in this link[^5]) studying the power of randomly initialized GNNs. We empirically find the randomly initialized GNN learned with reduced learning rate produces satisfying result with our MLCO testbed.

Inference Time
==============

In this section, we report the inference time of both PPO-Single baseline and our PPO-BiHyb on all test cases, as shown in Tab. \[tab:inference-time\].

It is worth noting that our PPO-BiHyb is slower than the heuristic algorithm adopted for lower-level optimization because this heuristic algorithm is called multiple times in the RL routine. We also consider more time-consuming heuristics, and the following heuristics considered in our experiments are with a comparable inference time with PPO-BiHyb: Hungarian-search for GED and LKH-accu for HCP. For DAG scheduling, we tried by firstly formulating DAG scheduling as an integer linear programming, and then solving the relaxed linear programming problem by the GLOP solver delivered with Google ORTools. However, it did not converge within 24 hours for even the smallest test set (TPC-H-50), thus we gave up this baseline.

A Study on How RL Modifies the Graph
====================================

In this section we include a brief study on the AIDS dataset for graph edit distance problem about the relation between the number of actions taken by RL and the reward. Here we list the average number of actions, the average reward values, and the Pearson correlation for all test instances:

  -------- -------- -------- -------- -------- --------
                                               
   \# act   reward   \# act   reward   \# act   reward
    4.1      8.3      2.7      9.3      3.4      24.9
                                               
  -------- -------- -------- -------- -------- --------

  : For PPO-BiHyb on AIDS dataset, the average number of actions and the reward, and the Pearson correlation between number of actions and the reward.

\[tab:my\_label\]

The average number of actions is relatively small with respect to the number of nodes, suggesting that in general, the RL agent learns to modify a small fraction of "critical edges" that can lead to a large reward. Besides, we also compute the Pearson correlation between the number of actions and the reward, and only the largest AIDS-50+ has a large correlation. It is not surprising because a larger graph should require more modifications to achieve a better reward, and for smaller graphs, such correlation seems not significant.

Computer Resources {#sec:computer-resources}
==================

Experiments on DAG scheduling and GED are conducted on an internal cluster with Tesla P100 GPU, Intel E5-2682v4 CPU @ 2.50GHz and 128GB memory. Experiments on HCP are conducted on our workstation with RTX2080Ti GPU, Intel i7-7820X CPU @ 3.60GHz and 64GB memory. All experiments are run with only one GPU.

Broader Impact {#sec:broader-impact}
==============

In this paper, we propose a general ML approach to solve CO over graphs, whose applications can be found in scheduling real-world tasks to increase efficiency. We would like to discuss the broader impact of this paper according to the following aspects:

*a) Who may benefit from this research.* The companies and organizations who use our optimization technique and their shareholders may benefit from this research, as our technique is aimed to increase efficiency, cut expenses and increase profits. Besides, a broader range of people may also benefit, because an increased efficiency usually means a save of resources and perhaps less pollution, which will further benefit the whole society.

*b) Who may be put at risk from this research.* The proposed optimization method may take the place of some job positions e.g. dispatchers who used to perform the optimization tasks with human expertise. The optimization method may also burden the workload of employees when pursuing the optimization goal. Therefore, it might be appealing to take account of the happiness of employees when scheduling, and it calls for more responsibilities of the company to provide training programs and new positions for the affected people and to care more about the rights of the workers.

*c) What are the consequences of failure of the system.* A failure of our ML-based CO approach will fail to cut the cost of finishing the task. More specifically, the performance will degenerate to be the same as the performance of the heuristic method adopted to solve the lower-level optimization. In most cases, the underlying task will not fail because the heuristic will still provide a feasible (although sub-optimal) solution.

Licenses and Further Information on Used Assets {#sec:asset}
===============================================

The following datasets and codebases are used for this research and we list their license information as follows:

-   The usage of TPC-H dataset is under clause 9 of the End-User License Agreement (EULA) of TPC[^6]: "THE TPC SOFTWARE IS AVAILABLE WITHOUT CHARGE FROM TPC".

-   The AIDS dataset is collected by @RiesenSSPR08 and is free for academic use.

-   The open-source repository GEDLIB @BlumenthalVLDBJ20 is under LGPL-3.0 License.

-   The FHCP challenge dataset is publicly available and the authors require to cite their paper @FHCPdataset in new publications.

-   LKH-3 is an implementation of the Lin-Kernighan traveling salesman heuristic, which is described in @helsgaun2017extension. The code is distributed for research use. The author reserves all rights to the code.

All datasets and codebases are publicly available. The datasets cover problems that arise from business computing, anti-HIV molecules and pure Hamiltonian graph data, which are not closely related to human identities and shall not contain offensive or biased information.

[^1]: Part of the work was done while the first author was working as an intern at Ant Group.

[^2]: Junchi Yan is the corresponding author.

[^3]: <http://tpc.org/tpch/default5.asp>

[^4]: <https://wiki.nci.nih.gov/display/NCIDTPdata/AIDS+Antiviral+Screen+Data>

[^5]: <https://openreview.net/forum?id=L7Irrt5sMQa>

[^6]: <http://tpc.org/TPC_Documents_Current_Versions/txt/TPC-EULA_v2.2.0.txt>

{'source': 'arXiv_out/2106'}