## Introduction

Combinatorial optimization problems such as graph partitioning and coloring problems appear in a wide range of applications1. These problems involve discrete search spaces and target finding the optimal solution from a finite set of objects. In computational complexity theory, it is known that many combinatorial problems are NP-hard2. Thus, solving large-scale combinatorial problems often means finding solutions with certain accuracy in a limited time rather than finding the globally optimal solution. On the other hand, it is well known that many important classes of combinatorial problems can be formulated as finding the ground state of lattice spin models including the Ising and Potts models3,4. In this regard, over the years, there has been a growing interest in simulating these models through quantum and classical physical systems for solving combinatorial optimization problems. These include superconducting qubits5, trapped ions6, and most recently photonic oscillator networks, including the coherent Ising machine7,8, the spatial Ising machine9,10,11,12, as well as polariton condensates and laser networks13,14.

Along different lines, numerical simulation of dynamical models governing physical systems has shown promise for solving combinatorial problems15,16,17,18,19,20,21,22. These schemes are built on direct simulation of nonlinear dynamical equations governing networks of interacting neurons with continuous degrees of freedoms that collectively evolve toward equilibrium points with binary states17. Despite their partial success, however, these methods suffer from two fundamental problems; (i) limitations of scaling the size of the network due to an increased computational burden, and (ii) trapping into local minima, which could be far from the global minimum of the governing cost function. Subsequently, there has been a continuous interest in developing novel physics-inspired algorithms that allow for finding good approximations of the solutions to large-scale combinatorial problems.

In this work, inspired by the dynamical equations governing a network of coupled q-photon down-conversion (q-PDC) oscillators, we introduce a new method for approximating the ground state of the planar Potts model. The proposed method is built on the dynamical evolution of a network of first-order nonuniform phase oscillators toward equilibrium states that generally represent the local minima of the Potts Hamiltonian. In order to mitigate the problem of trapping into the local minima, we utilize two different mechanisms that show significant improvement in minimizing the Potts Hamiltonian. The first approach is based on gradually forming the underlying cost function by tuning a parameter that controls the convexity at discrete phase values. The second approach is based on an adiabatic passage of the dynamical system through a chaotic regime which is enabled through numerical chaos that can be controlled by the time-discretization step size. Through examples, we show that the proposed minimalistic model in conjunction with a proper annealing mechanism enables an efficient solution of combinatorial optimization problems.

## Results

### The planar Potts model

The planar Potts model describes a network of interacting q-state spin degrees of freedom, where each spin can take an angle of θ = (2p − 1)π/q (p = 1,   , q) in the two-dimensional plane4. The interaction energy of a pair of spins (i, j) depends on their coupling strength Jij and the cosine of the relative angles (θi − θj) according to $${{{{{{{{\mathcal{H}}}}}}}}}_{ij}\propto -{J}_{ij}\cos ({\theta }_{i}-{\theta }_{j})$$. The planar Potts Hamiltonian is expressed as the sum of the pairwise interactions as4:

$${{{{{{{\mathcal{H}}}}}}}}=-\mathop{\sum}\limits_{ < ij > }{J}_{ij}\cos ({\theta }_{i}-{\theta }_{j}),\,{\theta }_{i}=\frac{(2p-1)\pi }{q},\,p=1,\cdots \,,q$$
(1)

which, is also referred to as the q-state clock model23. For q = 2, it reduces to the Ising Hamiltonian and for q →  it approaches the XY Hamiltonian. Here, it is important to note the difference between the planar and the standard Potts models. The standard Potts Hamiltonian is defined as $${{{{{{{\mathcal{H}}}}}}}}=-{\sum }_{{ < }ij { > }}\,{J}_{ij}\delta ({\theta }_{i},{\theta }_{j})$$, where, δ represents the Kronecker delta function. Clearly, the two models are identical for q = 2 and 3, while the planar Potts deviates from the standard model for q ≥ 4.

### The Potts optimization problem

The Potts problem can be stated as finding the spin configuration that minimizes the Potts Hamiltonian. It can be readily viewed as coloring the vertices of a graph using q colors (q-coloring problem), where each vertex is represented by a spin and its color is represented by the spin state, and the graph edges weights are equal to the coupling strengths3. A number of other combinatorial optimization problems such as Max-q-Cut can be expressed in terms of the Potts problem. In this problem, we want to divide the vertices into q disjoint groups such that the total weight of edges between these groups is maximized. For q = 2, the Potts problem reduces to the Ising problem which represents the Max-Cut problem. These problems belong to the NP-hard computational complexity class meaning the solution space grows exponentially with problem size and it becomes prohibitively difficult to find optimum solutions to large-scale problems. For this reason, unconventional computing systems are being developed to find approximate solutions to large-scale problems in shorter times.

It is worth mentioning that much of the research on unconventional methods and devices that target solving combinatorial optimization problems is focused on the Ising problem. These include the D-Wave’s quantum annealing machine5,24, the coherent Ising machine7,8, Hitachi’s CMOS Ising solver25, Fujitsu’s digital annealer26, and Toshiba’s simulated bifurcations machine21. In contrast, developing methods for solving the Potts problem offers an advantage in treating combinatorial problems that can be mapped more efficiently onto the Potts Hamiltonian.

### The q-PDC oscillator

Recently, it was shown that the 3-state Potts model can be simulated with networks of 3PDC oscillators to optically solve certain optimization problems27. This is based on the tristable phase of the parametric spontaneous three-photon downconversion process28. The idea can be extended for building a classical nonlinear oscillator model for the q-photon downconversion (q-PDC) process, in which a photon of frequency qω is down-converted into q photons of frequencies ω. In this manner, we introduce a second-order nonlinear oscillator with complex amplitude a with the dynamics described as $$\dot{a}=-{\gamma }_{l}a+g{({a}^{* })}^{q-1}-{g}_{s}| a{| }^{2(q-1)}a$$, where q = 2, 3, 4,   , and “*” shows complex conjugation. Here, g is the small signal oscillator gain, gs is the gain saturation coefficient, and γl is the rate of intrinsic oscillator losses. The dynamics of this oscillator is governed by a Lyapunov function described as $${{{{{{{{\mathcal{F}}}}}}}}}_{0}={\gamma }_{l}| a{| }^{2}-\frac{g}{q}({a}^{q}+{({a}^{* })}^{q})+\frac{{g}_{s}}{q}| a{| }^{2q}$$.

Figure 1a schematically depicts the q-PDC oscillator and the associated virtual energy diagram for different q values. The corresponding single-oscillator Lyapunov functions are shown in Fig. 1b. These figures clearly indicate a phase transition as a result of increasing the gain g, which marks the onset of self-sustained oscillations with a finite amplitude. The equilibrium oscillator amplitude $$| \bar{a}|$$ obeys the nonlinear relation $$-{\gamma }_{l}| \bar{a}| +g| \bar{a}{| }^{q-1}-{g}_{s}| \bar{a}{| }^{2q-1}=0$$, which can be solved for various gain levels as depicted in Fig. 1c. According to these figures, the phase transition is second-order for q = 2 and first-order for q = 3, 4,   , where by increasing the gain a solution branch appears out of the blue sky29. For the purpose of optimization, a first-order phase transition causes additional complexities because it creates the undesired possibility of the death of oscillators27. However, as discussed later in this paper, by reducing the q-PDC oscillators to phase oscillators this problem will be effectively circumvented.

Next, we consider a network of linearly coupled q-PDC oscillators for q = 2, 3, 4,   . The equations governing the complex amplitudes of the oscillator network follows:

$${\dot{a}}_{i}=-{\gamma }_{i}{a}_{i}+g{({a}_{i}^{* })}^{q-1}-{g}_{s}| {a}_{i}{| }^{2(q-1)}{a}_{i}-\mathop{\sum}\limits_{j}{\kappa }_{ij}{a}_{j},$$
(2)

where, ai represents the complex amplitude of the i’th oscillator, κij is the coupling coefficient between the i’th and j’th oscillators, and γi = γl + ∑jκij is the damping factor of the i’th oscillator which is composed of the intrinsic oscillator loss γl and external losses due to dissipative interaction with other oscillators ∑jκij27,30,31. The relative strength of the self-oscillation g and coupling coefficients κij plays a critical role in the dynamics and accordingly in the success of the optimization process which will be discussed later in this paper.

The dynamical system described by Eq. (2) admits a Lyapunov function $${{{{{{{\mathcal{F}}}}}}}}$$, such that $${\dot{a}}_{i}=-\partial {{{{{{{\mathcal{F}}}}}}}}/\partial {a}_{i}^{* }$$ and $${\dot{a}}_{i}^{* }=-\partial {{{{{{{\mathcal{F}}}}}}}}/\partial {a}_{i}$$. The Lyapunov function,

$${{{{{{{\mathcal{F}}}}}}}}=\mathop{\sum}\limits_{i}\left[{\gamma }_{i}| {a}_{i}{| }^{2}-\frac{g}{q}({a}_{i}^{q}+{({a}_{i}^{* })}^{q})+\frac{{g}_{s}}{q}| {a}_{i}{| }^{2q}\right]+\frac{1}{2}\mathop{\sum}\limits_{i,j}{a}_{i}^{* }{\kappa }_{ij}{a}_{j},$$
(3)

serves effectively as a cost function for the oscillator network. The Potts problem can be solved by numerically integrating the dynamical Eq. (2) which is equivalent to applying a gradient-descent minimization of the cost function of Eq. (3). Alternatively, one can start from the cost function $${{{{{{{\mathcal{F}}}}}}}}$$ and apply any gradient-based technique for minimizing $${{{{{{{\mathcal{F}}}}}}}}$$ over its continuous 2n-dimensional phase space32.

### The nonuniform phase oscillators

The cost function of Eq. (3) embeds the planar Potts Hamiltonian, while a faithful representation of the Potts Hamiltonian requires uniform amplitudes for all oscillators18,30,33,34. To reduce the computational burden of numerical simulations, we consider uniform amplitudes for all oscillators, i.e., $${a}_{i}\to {e}^{i{\phi }_{i}}$$, which results in great reduction of the governing 2n-dimensional Lyapunov function to an n-dimensional potential, $${{{{{{{\mathcal{F}}}}}}}}\to {{{{{{{\mathcal{V}}}}}}}}$$, where $${{{{{{{\mathcal{V}}}}}}}}$$ is a function of the phase degrees of freedom ϕi,   , ϕn (In transition from Eq. (3) to Eq. (4), a factor of − 2 is multiplied by the term involving g. This translates into a shift in the q-ary phase states which will not affect the results.):

$${{{{{{{\mathcal{V}}}}}}}}=\frac{g}{q}\mathop{\sum}\limits_{i}\cos (q{\phi }_{i})+\frac{1}{2}\mathop{\sum}\limits_{i,j}{\kappa }_{ij}\cos ({\phi }_{i}-{\phi }_{j}).$$
(4)

This relation is in essence the Lyapunov function governing a network of nonuniform phase oscillators29. This new potential carries the parameter g, which remains as a control parameter to adjust the strength of the self-oscillation of each oscillator compared to its interaction rate with the network. It should be noted that for q = 2 this relation reduces to the cost function introduced in ref. 35 and has been implemented with circuits for solving the Ising model36,37.

In the energy potential of relation (4), the first term operates as a penalty term that tends to enforce the evolution of each oscillator toward a q-ary state. The second term in isolation is equivalent to the XY Hamiltonian without the external field term. Therefore, assuming that the first term can successfully drive the oscillators to q-ary states, ϕi = (2p − 1)π/q, p = 1,   , q, the potential reduces to the planar Potts Hamiltonian. However, this critically depends on the parameter g, which controls the strength of the penalty term.

### Dynamical model and optimization

Considering the energy potential of Eq. (4), we can now write a dynamical model that guarantees descent motion toward the equilibrium points, ideally the global minimum. In doing so, we have the flexibility to deviate from the physics of the system and devise a dynamical model that results in faster and better numerical convergence to equilibrium points. Here, the straightforward approach is a gradient descent according to $${\dot{\phi }}_{i}=-\partial {{{{{{{\mathcal{V}}}}}}}}/\partial {\phi }_{i}$$, which results in:

$${\dot{\phi }}_{i}=g\sin (q{\phi }_{i})-\mathop{\Sigma}\limits_{j}{\kappa }_{ij}\sin ({\phi }_{j}-{\phi }_{i}).$$
(5)

Alternatively, we can consider a pair of phase and angular velocity (ϕi, ωi) with dynamical equations $${\dot{\phi }}_{i}={\omega }_{i}$$ and $${\dot{\omega }}_{i}=-\partial {{{{{{{\mathcal{V}}}}}}}}/\partial {\phi }_{i}-\gamma {\omega }_{i}$$, where γ is an effective friction coefficient. This choice is associated with the following second-order dynamics for the phase oscillators:

$${\ddot{\phi }}_{i}+\gamma {\dot{\phi }}_{i}=g\sin (q{\phi }_{i})-\mathop{\Sigma}\limits_{j}{\kappa }_{ij}\sin ({\phi }_{j}-{\phi }_{i})$$
(6)

To numerically find the equilibrium points, one can apply finite difference to either of Eq. (5) or Eq. (6) to iteratively update the phases at discrete time steps until reaching stable solutions. By applying different finite-difference formulas, different algorithms are obtained, while in general, momentum methods obtained from a discretization of Eq. (6) show faster convergence (please see “Methods”).

In general, restricting the dynamics to a descent motion on the potential landscape of Eq. (4) could result in trapping into local minima. The problem of trapping into the local minima is a long-standing challenge in the optimization of non-convex functions. An interesting approach for avoiding this is to adiabatically increase the gain parameter21,27,33. This approach can be compared with quantum adiabatic optimization38,39. Although a fundamental difference is a lack of a classical counterpart for the quantum adiabatic theorem, which ensures a gradual evolution of the state of the system to the ground state of the final Hamiltonian. Here, the classical potential adiabatically evolves toward the desired combinatorial Hamiltonian, while the shallow local minima are less likely to arise during this process27. In the case of the phase oscillator networks discussed here, by gradually increasing the gain from zero, one can slowly guide the system into a valid (discrete) solution while staying inside the deeper regions of the coupling potential, possibly leading to a good approximation of the ground state solution. Clearly, it is important to increase the gain at an optimal speed that gives the network enough time to search for better solutions, while the caveat is that, slow tuning of the gain generally slows down the stabilization time. Figure 2a–c shows the landscape potential for an all-to-all connected network of n = 3 oscillators for three different gain levels. According to these figures, the potential deforms drastically by increasing the gain.

An alternative approach for bypassing the local minima is a controlled use of chaos. Chaos is by nature different from random fluctuations. However, the possibility of harnessing chaos for optimization has been suggested in previous works and surprisingly it is suggested that chaotic fluctuations can significantly outperform random noise40,41. A controlled transition of the oscillator network from chaos to fixed-point attractors allows for utilizing the exponentially fast searching capability of the network in its chaotic regime to largely avoid trapping into the local minima when reaching an equilibrium. It should be noted that an individual oscillator in Eq. (5), described by the dynamical equation $$\dot{\phi }=g\sin (\phi )$$, is a first-order dynamical system and lacks the minimum dimensionality required for bifurcation and chaos. However, in principle, the dynamical model will be solved numerically, and as it is well known, numerical simulation of ordinary differential equations can induce chaos42. In this case, by using Euler’s method, the phase of the oscillator at a time step t(k+1) can be obtained in terms of the previous step t(k) according to $${\phi }_{i}^{(k+1)}={\phi }_{i}^{(k)}+{{\Delta }}g\sin (q{\phi }^{(k)})$$, where Δ = t(k+1) − t(k) is the time step. It is straightforward to show that this simple iterative relation creates a chaotic map of the equilibrium phase ϕ versus the time step Δ. The chaotic map is depicted as an inset in Fig. 2 for a single oscillator with q = 2. As a result, by time-discretization, computational chaos can be incorporated in the system. Figure 2d–h depicts the dynamics of the three coupled oscillators for different values of the step size which clearly shows the chaotic dynamics for large step sizes. Tuning the parameter Δ allows a transition between equilibrium and chaos. Here, by starting with a large time step, the randomly initialized system evolves into a chaotic regime, and then by reducing the time step, the system makes an adiabatic passage from chaos to equilibrium.

### Optimization results

We consider the Ising problem (q = 2) on an instance from the Biq-Mac library43, which involves a collection of quadratic binary programming problems. We chose the example of the “g05_100.6” graph, which is an unweighted graph with n = 100 nodes and an edge probability of 0.5 between any two nodes, containing a total of 2475 edges. Any other graph from this dataset essentially provides similar insights. Figure 3 shows the results of numerical simulation of the dynamical model of Eq. (5) with constant gain (a–c), adiabatic gain (d–f), and chaotic annealing (g–i).

The first column depicts the time-evolution of the Ising Hamiltonian (Eq. (1)) for 1000 random initial conditions. The distribution of the Ising energy associated with the steady-state solutions is shown in the second column. The last column exemplifies the dynamics of the phases for one simulation instant. For adiabatic deformation of the energy landscape (d–f), the gain is linearly increased from zero. It is observed that at over 45% of the initial conditions lead to the best-known solution (ground state), compared to 5% for the constant gain scenario (shown in panels (a–c)). By comparing the dynamics of the phases in panels (c) and (f), it is apparent that for the case of constant gain, the phases quickly settle into their final values. This is expected given the presence of many local minima that could involve the initial phase state in their basin of attraction. In this case, the dynamical system rapidly stabilizes in a local minimum. In the adiabatic gain regime, on the other hand, excursions continue to happen for longer simulation times, which indicates the evolving nature of the energy landscape.

For the case of the chaotic search (Fig. 3g–i), the gain is set to a constant value, similar to the first row, but the step size is reduced linearly, from Δti = 10Δ0 to Δtf = Δ0. According to Fig. 3h, 40% of initial conditions lead to the ground state. Here, the distribution of the steady-state energies turns out to be broader than the adiabatic gain case, and spanning over higher energy levels that are associated with local minima. Here, the rapidly evolving chaotic motion of the phases as depicted in Fig. 3i allows the system to explore distant parts of the phase space that otherwise would not be accessible.

Next, we apply the proposed method to solve the Ising problem on 100-node instances from all classes in the Biq-Mac library43. This library involves nine classes of 100-node graphs, each containing ten instances. The results are shown in Fig. 4. In this figure, each panel shows the distribution of the steady-state energies for 1000 random initial conditions. The horizontal axis is the total number of steps, ranging from 10 steps up to 700. According to this figure, in almost all cases the top 20% of the ensemble reach the ground state with under 200 time steps.

In contrast with the Ising problem, to the best of our knowledge, the Potts problem (considering the case of q = 3) lacks a collection of benchmark problems with known solutions. Here, we generated sets of randomly connected 3-colorable graphs with different sizes and connection densities, with each set having 100 random instances. In general, average graph density or average degree of the graph is known to be a measure of the hardness for coloring problems, acting as an order parameter, with low-density graphs being generally harder to color44. Therefore, we focused on relatively low-density graphs with 500 and 1000 nodes and average degree of 9 (Fig. 5a, c) and 18 (Fig. 5b, d) (see “Methods” for details). In these simulations, the time-step size was set to a constant 0.01, while the gain is adiabatically tuned from 0 to 2.5. Each panel in Fig. 5 shows the distribution of the Potts energy associated with the steady-state phase of the oscillator networks versus the total number of time steps. The phases are initiated with uniform random values in the range − πϕi(0) ≤ π. Here, again, the top 20% of the solutions find the ground state in less than 200 steps.

## Discussion

In summary, inspired by the q-photon downconversion parametric oscillator, we introduced a nonuniform phase oscillator that emulates a q-state spin in the two-dimensional plane. This provided an efficient route for searching for the ground state of the planar Potts Hamiltonian by numerically integrating the dynamical equations governing a network of phase oscillators that collectively evolve toward an equilibrium point. The dynamics of the oscillator network is restricted in the phase space to a Lyapunov function which is, in general, a non-convex function. Therefore, it is important to devise schemes that can prevent trapping into the local minima of the Lyapunov function. Here, to reduce the problem of trapping into the local minima, we considered two different approaches based on the gradual formation of the cost function and by controlled passage through chaos. Our numerical results confirm that both schemes greatly improve the success of solving the optimization problem.

The proposed method is ideally suited for parallel computing and application to large-scale optimization problems that can be formulated as the planar Potts model. This method is based on two parallel matrix–vector multiplications in conjunction with nonlinear function evaluations. In terms of the computational burden, the matrix–vector multiplication is the bottleneck of the proposed method. Therefore, speed-up can be achieved by parallel computing methods and systems.

It is worth stressing that for q ≥ 4, the clock Hamiltonian deviates from the standard Potts Hamiltonian. In this case, terms associated with unequal spin angles are penalized unevenly and depending on the relative angle of the two interacting spins. In this case, the clock model can still be used to approximate the ground state of the standard Potts model, while the approximation clearly deteriorates for larger q values.

## Methods

For numerical calculations, a simple approach is to discretize the first-order dynamical model of Eq. (5) by using the first-order forward difference relation for the derivative term. This results in the Euler’s method for solving ordinary differential equations which is based on a single-step updating of the dynamical variables in subsequent time steps k according to:

$${{{\Phi }}}^{(k+1)}={{{\Phi }}}^{(k)}-{{{\Delta }}}_{k}\nabla {{{{{{{{\mathcal{V}}}}}}}}}^{(k)}$$
(7)

where, Δk = t(k+1) − t(k) is the time-step size, $${{\Phi }}={({\phi }_{1},\cdots ,{\phi }_{n})}^{t}$$, and $$\nabla {{{{{{{\mathcal{V}}}}}}}}$$ is the potential gradient,

$$\nabla {{{{{{{\mathcal{V}}}}}}}}=-g\sin (q{{\Phi }})+\cos ({{\Phi }})\odot K\sin ({{\Phi }})-\sin ({{\Phi }})\odot K\cos ({{\Phi }}),$$
(8)

where, K is the connectivity matrix with elements κij and ‘  ’ shows the entryways vector product.

In addition, we considered discretization of the second-order model of Eq. (6) by utilizing the central difference formula for the second derivative and the backward difference formula for the first derivative. This results in a two-step updating rule (known as the momentum method in numerical analysis):

$${{{\Phi }}}^{(k+1)}=(1+{\mu }_{k}){{{\Phi }}}^{(k)}-{\mu }_{k}{{{\Phi }}}^{(k-1)}-{\eta }_{k}\nabla {{{{{{{{\mathcal{V}}}}}}}}}^{(k)}$$
(9)

where, μk = 1 − γΔk and $${\eta }_{k}={{{\Delta }}}_{k}^{2}$$. The convergence rate of the difference relations (9) can be controlled with the two parameters μk and ηk. In numerical simulations, for the adiabatic deformation approach, we used the two-step relation (9) by taking μk = (k − 1)/(k + 2) and with a constant ηk. For the chaotic annealing approach, we used the single-step relation (7), with a linearly decreasing ηk.

The random graphs used for the 3-coloring problem were generated as described below. For a given number of nodes n, three partitions with n1, n2, and n3 nodes were considered such that n1 + n2 + n3 = n. Then, a full 3-partite graph was generated by connecting each node from one partition to all nodes of the other two partitions, while no edges exist in each partition. Next, the existing edges were removed at random with a probability of 0 < p0 < 1, to create a random 3-colorable graph with the desired edge density. To obtain the energy distributions in each panel of Fig. 5, we first generated an ensemble of 102 random graphs with similar statistics, and in each case considered the a set of 102 random initial conditions. We then ran the simulations for all of the 104 combinations of random graphs and initial conditions, for each given total number of steps, and plotted the resulting energy distribution.