Combinatorial Optimization ← Back to portfolio
Advanced Algorithms & Graph Theory

Algorithmic Solver for Permutation Grids

Development of a software infrastructure to determine the minimal inversion path for sorting a discrete matrix of dimension \(m \times n\). This system models the configuration space as an interconnected dynamic graph and implements informed search strategies to overcome combinatorial complexity.

Institution: ENSAE ParisTech
Authors: Avner EL BAZ, Stanislas DEKERLE
Stack: Python, PyGame, Min-Heap / Priority Queues

Greedy Complexity

\(\mathcal{O}(m^2n^2)\)

Naive algorithm generating redundant permutations.

Graph Optimization

On-the-fly

BFS/A* coupling avoiding full topology instantiation.

Primary Heuristic

Manhattan

Geometric distance used to guide the priority queue.

Max GUI Frequency

0.5s / act

Adaptive rendering speed for real-time resolution.

Evolutionary Node Expansion Analysis (State Space)

Mathematical Formalization & Informed Heuristics

Evaluating the current matrix state is done by projecting the discrete configuration via a cost function. For the \(A^*\) algorithm, the choice of the next node to explore within the asymmetric Min-Heap structure is dictated by the standard formulation:

\(f(n) = g(n) + h(n)\)

Where \(g(n)\) represents the number of adjacency permutations (swaps) executed from the initial configuration, and \(h(n)\) corresponds to the global Manhattan distance, acting as an admissible lower bound of the system's residual energy:

\(h(S) = \sum_{i=1}^{m \times n} \left| x_i - x_i^* \right| + \left| y_i - y_i^* \right|\)

Handling Non-linear Constraints: The integration of `barriers` can block specific graph edges, potentially making the target unreachable. To prevent infinite exploration of disjoint subgraphs, a connectivity pre-test based on a fast matrix BFS (`valid_barriers`) is executed before any resolution attempt.

Analysis Report

Examine the code structure of the Grid, Graph, and Solver classes, and the PyGame graphics engine.

PDF Preview (Available on wide screens or via download)