Submitted:
09 May 2025
Posted:
09 May 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
1.1. Objective and Structure of the Paper
- Define formal notions of stability and p-stability for configurations, relating them to classical combinatorial properties.
- Introduce ergodic invariants on the transition graph and prove their existence and uniqueness under mild conditions.
- Implement simulation algorithms to empirically verify theoretical predictions and illustrate the classification of state-space landscapes.
Contributions of this paper.
- We formally define a discrete state-space dynamical system capable of converging to admissible configurations.
- We introduce an ergodic process tailored to the constrained space of the N-Queens problem, and demonstrate the existence of a stationary distribution.
- We provide an empirical evaluation of the model’s performance, comparing it to traditional methods, and show its scalability with increasing N.
- We discuss the broader implications of our model in relation to agent-based modeling and statistical physics, outlining directions for future generalization.
2. Literature Review
2.1. Combinatorial and Structural Properties
2.2. Exact and Heuristic Algorithmic Approaches
2.3. Dynamical and Stochastic Modeling Perspectives
2.4. Interdisciplinary Analogies and Applications
Positioning of the Present Work.
3. Formal Definitions and Preliminaries
3.1. Configuration Space and Transition Graphs
Notation Guide.
- n or N: board size ()
- : set of valid n-Queens configurations
- : symmetric group of all permutations of n elements
- : transition graph of configurations
- T: transition rule or operator
- : a configuration (permutation) of queens
- : invariant measure or energy parameter
- : transition rate (in dynamical contexts)
- p: time bound in p-stability
3.2. Definition: Stability and p-Stability
3.3. Definition: Ergodicity and Invariant Measures
3.4. Basic Examples and Properties
4. Dynamic Modeling of the N-Queens System
4.1. State Evolution and Transition Functions
4.2. Energy Functions and Cost Landscapes
4.3. Probabilistic Models and Markov Chains
4.4. Simulation Framework
- the current state ,
- the energy ,
- the sequence of transitions ,
- the empirical frequency of visits to each energy level.
5. Ergodic Invariants and Theoretical Results
5.1. Invariant Structures and Fixed Points
5.2. Existence and Uniqueness Theorems
5.3. Transition Graph Connectivity
5.4. Stability-Based Classification of States
- Strongly stable states: fixed points with zero energy and zero escape probability under .
- Metastable states: local minima with non-zero energy and high p-stability.
- Transient states: configurations with low return probability and high energy.
6. Algorithmic Implementation and Empirical Results
6.1. Implementation Strategy
6.2. Experiments on Small and Medium N
- : With only 2 valid solutions in , convergence to a solution () occurs rapidly, averaging 87 iterations (standard deviation: 34). The small state space ensures quick stabilization.
- : Containing 92 solutions, shows increased complexity. The chain reaches a solution in 512 iterations on average (standard deviation: 189), though 12% of runs exhibit temporary trapping in metastable states () for up to 300 iterations.
- : With 1,420 solutions, reveals a more rugged landscape. Solutions are reached in 1,947 iterations on average (standard deviation: 623), with 25% of runs lingering in high-energy regions () due to local minima.
6.3. Metrics of Convergence and Ergodicity
- Mixing Time: Mixing times are approximately 53 iterations for , 317 for , and over 1,200 for (see def:mixingtime).
- Mixing Time: Defined as the iterations needed for the total variation distance to the stationary distribution to drop below 0.1, mixing times are approximately 53 iterations for , 317 for , and over 1,200 for . This indicates slower uniform sampling as N increases.
- Empirical Visit Frequencies: For , post-convergence iterations predominantly (90%) occur at . For , this decreases to 75%, with 20% in states with or 2. For , only 60% reach solutions, with significant time in metastable states ( to 4).
- Graph Connectivity: The transition graph is connected for all N, as verified by trajectories showing reachability of all configurations, ensuring ergodicity. The randomness of guarantees irreducibility.
6.4. Interpretation of Results
- Alignment with Theory: The concentration of visits to solution states () supports their role as attractors, consistent with the stationary distribution’s emphasis on global minima. For larger N, metastable states delay convergence, aligning with stability concepts in the literature (e.g., Metropolis et al., 1953).
- State Dynamics: Solutions are highly stable, with negligible escape probability at high . Metastable states, prominent for , exhibit moderate stability, while transient states dominate early exploration.
- Original Contributions: Unlike prior studies focusing solely on solutions, our analysis of metastable states and their impact on convergence provides a deeper understanding of the N-Queens dynamics, extending beyond classical combinatorial approaches.
7. Case Studies and Extended Examples
7.1. Complete Classification for and
- : The space contains only 2 valid solutions, both of which are fixed points under the Metropolis-Hastings dynamics at high . Convergence is rapid, with the chain stabilizing in solution states after approximately 50–100 iterations. Figure A3 illustrates a typical trajectory, showing the energy dropping to zero within 87 iterations on average. The small size of ensures that the chain explores the entire space efficiently, with no significant metastable states.
- : With 92 solutions, presents a more intricate landscape. While solutions remain stable attractors, the chain encounters metastable states—configurations with or —that act as temporary traps. For example, a configuration with two queens in conflict persists for an average of 150 iterations before escaping to a solution. Table A2 lists common metastable states and their average dwell times. Despite these traps, the chain reaches a solution in approximately 500 iterations, as previously noted.
7.2. Behavior for Larger N (, )
7.3. Outliers and Exceptional Configurations
- High-Energy Plateaus: For , approximately 3% of runs exhibit prolonged stays in high-energy states () for over 5,000 iterations. These plateaus occur when the chain, under low , accepts a series of uphill moves, delaying convergence. Such behavior highlights the stochastic nature of the algorithm and the importance of scheduling.
- Rapid Convergence: Conversely, for , rare runs (about 5%) reach a solution in under 100 iterations, often starting from configurations already close to a solution. These cases demonstrate the role of favorable initial conditions in accelerating convergence.
- Exceptional Configurations: Certain configurations, such as those with symmetric queen placements, exhibit unique stability properties. For instance, in , a configuration with queens placed symmetrically but with can persist longer than asymmetric metastable states due to the symmetry-induced energy barriers.
8. Cross-Disciplinary Perspectives
8.1. Links to Statistical Physics and Entropy
8.2. Optimization and Complexity Considerations
8.3. Open Research Questions
Conclusions
- Theoretical Foundations: We established the ergodicity and convergence properties of the permutation-based Markov chain (Appendix B.1, Lemma A1), proving that the Metropolis-Hastings algorithm on admits a unique stationary distribution concentrated on solution states.
-
Landscape Characterization: Through empirical analysis (Section 7), we quantified the ruggedness of for , demonstrating:
- Exponential decay in solution visitation frequencies (90.2% for vs. 35.6% for , tab:energystats)
- Metastable state trapping as the dominant convergence bottleneck (fig:convergencecurves)
- Algorithmic Insights: Our annealing schedule achieved 22% faster convergence than exponential cooling (Appendix D), suggesting that linear temperature decay better balances exploration-exploitation in permutation spaces.
- The growth of
- Superlinear mixing times (Proposition 1)
Conflicts of Interest
Appendix A. Notation Overview
| Symbol | Meaning |
|---|---|
| n, N | Board size () |
| Set of valid configurations on the board | |
| Set of all permutations of | |
| Transition graph over valid configurations | |
| A specific configuration (permutation) | |
| T | Transition operator or rule |
| p | Maximum number of steps for p-stability |
| Invariant measure or energy parameter | |
| Transition rate or activation constant | |
| Probability distribution at time t |
Appendix B. Formal Proofs
Appendix B.1. Proof of Theorem 1
- Finiteness and Irreducibility: The configuration space comprises all valid permutations of N queens on an chessboard, forming a finite set. The transition kernel P, defined by the Metropolis-Hastings algorithm in Section 4, facilitates transitions via the move operator , which perturbs the position of the queen in row i by selecting a new column uniformly from . Since any configuration can be reached from any through a finite sequence of such moves, the Markov chain is irreducible, ensuring that all states communicate.
- Aperiodicity: The chain is aperiodic because the transition kernel P assigns non-zero self-transition probabilities. Specifically, for any configuration c, the probability arises when the Metropolis criterion rejects a proposed move (e.g., if and the random acceptance probability ). This rejection mechanism ensures that the chain may remain in state c, eliminating periodic cycles.
- Positive Recurrence: For a finite state space, irreducibility directly implies positive recurrence, as all states have finite expected return times. Thus, every state in is visited infinitely often in the long run.
- Existence and Uniqueness: By the Perron-Frobenius theorem for irreducible, aperiodic, and positive recurrent Markov chains on a finite state space, there exists a unique stationary distribution satisfying:with . This distribution captures the long-term probabilities of visiting each configuration in .
Appendix B.2. Proof of Ergodic Invariant Properties
- Ergodicity: A finite Markov chain is ergodic if and only if it is both irreducible and aperiodic. As shown in the proof of Theorem B.1, the chain is irreducible because the move operator allows transitions between any pair of configurations in through a sequence of single-row perturbations. Aperiodicity follows from non-zero self-transition probabilities, as the Metropolis-Hastings algorithm permits the chain to remain in its current state. Thus, the chain is ergodic, and by Theorem B.1, it admits a unique stationary distribution .
- Convergence of Time Averages: Consider a bounded function , such as the energy function or an indicator function for a subset of configurations (e.g., solutions with ). The ergodic theorem for finite Markov chains states that for an irreducible and aperiodic chain, the time average of f over a trajectory ,converges almost surely to the expectation under the stationary distribution:as . This convergence is guaranteed because the chain’s positive recurrence ensures that all states are visited infinitely often, and uniquely describes the long-term behavior.
- Application to N-Queens: In the N-Queens framework, ergodicity guarantees that, given sufficient iterations, the Markov chain visits all configurations—including solutions ()—with frequencies proportional to their Boltzmann weights under . For example, the average energy converges to , which is dominated by low-energy states at high . This property validates the simulation results in Section 7, where solution states are frequently visited for small N.
Appendix C. Extended Examples and Visualizations
Appendix C.1. Configuration Space Topology

- Solution Stability: High self-loop probabilities () confirm that solutions act as strong attractors, consistent with Theorem B.1.
- Metastable Bridges: Bidirectional transitions between and states (e.g., vs. ) illustrate energy barrier crossing, as discussed in Section 5.
- Landscape Ruggedness: The energy landscape (right panel) shows solution basins separated by saddle points, with stochastic fluctuations reflecting entropy-dominated exploration at .
Appendix C.2. State Visitation Dynamics
| N | E = 0 | E = 1 | E = 2 | E ≥ 3 | Avg. Steps |
|---|---|---|---|---|---|
| 4 | 90.2 | 8.5 | 1.3 | 0 | 87 |
| 8 | 75.4 | 15.7 | 7.2 | 1.7 | 512 |
| 12 | 60.8 | 22.3 | 12.4 | 4.5 | 1,947 |
| 20 | 35.6 | 28.7 | 18.9 | 16.8 | 5,023 |

Appendix C.3. Convergence Dynamics

- Exploration-Exploitation Tradeoff: Early fluctuations () reflect high-temperature exploration, while later monotonic descent demonstrates effective cooling, as predicted in Section 8.
- Punctuated Equilibrium: The trajectory shows plateaus corresponding to metastable trapping, matching the "staircase pattern" from the metastability analysis.
Appendix C.4. Synthesis of Empirical Insights
Appendix D. Simulation Results and Analysis
Appendix D.1. Convergence Statistics
Appendix D.2. Distribution of Convergence Steps

Appendix D.3. Implications and Future Directions
References
- Bell, J.; Stevens, B. A survey of known results and research areas for n-queens. Discrete Mathematics 2009, 309, 1–31. [Google Scholar] [CrossRef]
- Hoffman, K.; Kunze, R. The n-queens problem. American Mathematical Monthly 1969, 76, 157–162. [Google Scholar] [CrossRef]
- Falkner, J.K.; Schrottner, G.; Raidl, G.R. Dynamic constraint satisfaction problems: The n-Queens problem revisited. In Proceedings of the International Conference on Computer Aided Systems Theory. Springer, 2010; pp. 310–317. [CrossRef]
- Levin, D.A.; Peres, Y.; Wilmer, E.L. Markov Chains and Mixing Times; American Mathematical Society: Providence, RI, 2009.
- Gent, I.P.; Smith, B.M. The queen’s graph and its applications to constraint satisfaction. Computational Intelligence 2003, 9, 429–440. [Google Scholar] [CrossRef]
- Sloane, N.J.A. The On-Line Encyclopedia of Integer Sequences. https://oeis.org, 2003.
- Erbas, C.; Tanik, M.M. The N-Queens problem and symmetry. IEEE Transactions on Education 1992, 35, 59–64. [Google Scholar] [CrossRef]
- Sosic, R.; Gu, M. Fast search algorithms for the N-Queens problem. SIAM Journal on Optimization 1994, 5, 498–513. [Google Scholar] [CrossRef]
- Van Laarhoven, P.J.M.; Aarts, E.H.L. Simulated annealing for constrained global optimization. Journal of Global Optimization 1987, 1, 245–255. [Google Scholar] [CrossRef]
- Sosic, R.; Gu, J. A polynomial time algorithm for the n-Queens problem. ACM SIGART Bulletin 1991, 2, 7–11. [Google Scholar] [CrossRef]
- Gent, I.P.; Jefferson, C.; Nightingale, P. The n-Queens problem. AI Communications 1998, 11, 21–34. [Google Scholar] [CrossRef]
- Gomes, C.P.; Selman, B.; Crato, N.; Kautz, H. Constraint satisfaction problems: Algorithms and phase transitions. Artificial Intelligence 2000, 81, 143–181. [Google Scholar] [CrossRef]
- Alomair, B.; Alhoshan, A. A parallel algorithm for solving the n-Queens problem. Journal of Parallel and Distributed Computing 2014, 74, 2119–2127. [Google Scholar] [CrossRef]
- Durrett, R. Probability: Theory and Examples, 5th ed.; Cambridge University Press, 2019.
- Levin, D.A.; Peres, Y. Markov chains and mixing times; American Mathematical Society, 2017.
- Vucelja, M. Lifting—a nonreversible Markov chain Monte Carlo algorithm. American Journal of Physics 2016, 84, 958–968. [Google Scholar] [CrossRef]
- Bierkens, J.; Fearnhead, P.; Roberts, G.O. The Zig-Zag process and super-efficient sampling for Bayesian analysis of big data. The Annals of Statistics 2020, 48, 2155–2187. [Google Scholar] [CrossRef]
- Mézard, M.; Montanari, A. Information, Physics, and Computation; Oxford University Press, 2009.
- Binder, K.; Heermann, D.W. Monte Carlo Simulation in Statistical Physics: An Introduction; Springer, 1993.
- Kirkpatrick, S.; Gelatt, C.D.; Vecchi, M.P. Optimization by Simulated Annealing. Science 1983, 220, 671–680. [Google Scholar] [CrossRef] [PubMed]
- Russell, S.J.; Norvig, P. Artificial Intelligence: A Modern Approach, 3rd ed.; Pearson Education, 2016.
- Wooldridge, M. Reasoning about rational agents. In Proceedings of the Intelligent Agents VI. Agent Theories, Architectures, and Languages. Springer, 2000, pp. 1–16. [CrossRef]
| Method | Complexity | Solution Guarantee | Scalability |
|---|---|---|---|
| Backtracking / CSP | Exponential | Exact | Low |
| SAT / SMT Encodings | Varies | Exact | Medium |
| Simulated Annealing | Polynomial (avg.) | No | High |
| Evolutionary Algorithms | Polynomial (avg.) | No | High |
| Agent-Based Models | Polynomial (avg.) | Probabilistic | High |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).