Search arXivSearch

arXiv · 2504.20017

Constructing Magic Squares: an integer constraint satisfaction problem and a fast approach

Abstract

Magic squares are a fascinating mathematical challenge that has intrigued mathematicians for centuries. Given a positive (and possibly large) integer \( n \), one of the main challenges that still remains is to find, within a computational time, a magic square of order \( n \), that is, a square matrix of order \( n \) with unique integers from \( a_{\min} \) to \( a_{\max} \), such that the sum of each row, column, and diagonal equals a constant \( \mathcal{C}(A) \). In this work, we first present an integer constraint satisfaction problem for constructing a magic square of order \( n \). Nonetheless, the solution time of this problem grows exponentially as the order increases. To overcome this limitation, we also propose a that constructs magic squares depending on whether \( n \) is odd, singly even, or doubly even. Moreover, we provide a proof of the correctness of this novel approach. Our numerical results show that our method can construct magic squares of order up to \num{70000} in less than \num{140} seconds, demonstrating its efficiency and scalability.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

João Vitor Pamplona, Maria Eduarda Pinheiro, Luiz-Rafael Santos. 2026-01-05. Constructing Magic Squares: an integer constraint satisfaction problem and a fast approach. https://arxiv.org/abs/2504.20017

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Subpath-Based Column Generation for Electric Vehicle Routing Problems

Motivated by widespread electrification targets, this paper studies an Electric Vehicle Routing Problem with Time Windows and Nonlinear Charging (EVRPTWNL) that jointly optimizes routing-scheduling decisions and charging decisions given vehicle capacities, time windows and battery capacities. We develop a column generation scheme with a subpath-based label-setting algorithm that decomposes the pricing problem into two phases: (i) generating subpaths between charging stations, and (ii) combining subpaths into paths while optimizing charging decisions in between. We formalize a domination framework to establish the convergence and exactness of the algorithm, and prove that the methodology can solve a range of EVRP variants (e.g., with vehicle capacities, time windows, and nonlinear charging) and relaxation-tightening strategies (e.g., ng-relaxations and subset-row cuts). Computational results show improvements over path-based benchmarks in both computational time and solution quality, especially when time windows become wider, when vehicles can perform multiple tasks on a single charge and when vehicles still need to recharge several times across the planning horizon. Ultimately, the methodology can scale to otherwise intractable instances with up to 100 customers, thereby enhancing fleet management capabilities across electrified logistics areas.

math.OC

Polynomial Scaling is Possible For Neural Operator Approximations of Structured Families of BSDEs

Neural operator (NO) architectures learn nonlinear maps between infinite-dimensional function spaces and are widely used to accelerate simulation and enable data-driven model discovery. While universality results ensure expressivity, they do not address \emph{complexity}: for broad operator classes described only through regularity (e.g.\ uniform continuity or $C^r$-regularity), information-theoretic lower bounds imply that minimax-optimal NO approximation rates scale \emph{exponentially} in the reciprocal accuracy $1/\varepsilon$. This has shifted the focus of NO theory toward identifying additional problem-specific structure, beyond regularity, under which suitably tailored NO architectures can leverage to unlock polynomial scaling in $1/\varepsilon$. We exhibit the first polynomial-scaling regime for NO approximations of solution operators in stochastic analysis; by identifying structured families of \emph{non-Markovian} BSDEs with randomized terminal condition parameterized by the Sobolev-regular terminal condition and by Sobolev-regular additive nonlinear perturbations of the generator. We prove that their solution operator can be approximated (uniformly over the family) by a tailored NO whose number of trainable parameters grows \emph{polynomially} in $1/\varepsilon$. We unlock this polynomial scaling regime by \emph{informing the NO's inductive bias} by factoring out the singular part of the associated semilinear elliptic PDE Green's function and by incorporating the Doléans--Dade exponential of the BSDE's common non-Markovian factor into the NO's decoding layers. As a byproduct, we extend polynomial-scaling guarantees from families of linear elliptic PDEs on regular domains to the semilinear setting.

math.OC

The Competive Spectral Radius of Families of Nonexpansive Mappings

We consider a new class of repeated zero-sum games in which the payoff is the escape rate of a switched dynamical system, where at every stage, the transition is given by a nonexpansive operator depending on the actions of both players. This generalizes to the two-player (and non-linear) case the notion of joint spectral radius of a family of matrices. We show that the value of this game does exist, and we characterize it in terms of an infinite dimensional non-linear eigenproblem. This provides a two-player analogue of Mañe's lemma from ergodic control. This also extends to the two-player case results of Kohlberg and Neyman (1981), Karlsson (2001), and Vigeral and the second author (2012), concerning the asymptotic behavior of nonexpansive mappings. We discuss two special cases of this game: order preserving and positively homogeneous self-maps of a cone equipped with Funk's and Thompson's metrics, and translations of a finite dimensional normed space.

math.OC