Skip to content

An attempt at achieving data compression using inspiration from the Ising Model

Notifications You must be signed in to change notification settings

TobyH9/spin-press

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpinPress

An attempt at achieving data compression using inspiration from the Ising Model

📌 Overview

This compression scheme introduces a novel approach to data representation by leveraging the Ising model, a mathematical model from statistical mechanics, to encode and reconstruct 2D binary data arrays.


The 2D Ising Model

We define a 2D lattice of size $( N \times N )$, which has spins $( s_{ij} )$, where each spin can take on a value:

$$[ s_{ij} \in {-1, +1} ]$$

Each spin interacts with its nearest neighbours (up, down, left, right), and the energy of a given configuration of spins is defined by the Ising Hamiltonian:

$$[ E = -J \sum_{\langle i,j \rangle} s_{ij} \cdot s_{i'j'} ]$$

Where:

  • The sum is taken over all nearest neighbour pairs $( \langle i,j \rangle )$
  • $( J )$ is the interaction constant (assumed $( J > 0 )$ for ferromagnetic coupling)
  • $( s_{ij}, s_{i'j'} \in {-1, +1} )$

Microstate Realisation

In our compression scheme, we define the energy of a configuration using the above Hamiltonian and try to find the ground state of the system.


⚙️ How It Works

Compression Algorithm (Encoding)

Input:
A 2D binary array of size $( N \times N )$, where each element is a bit (0 or 1) representing meaningful data.

Steps:

  1. Map to Ising Spins:
    Convert the binary array to Ising spins:

    • Bit 1 $( \rightarrow )$ Spin $( +1 )$
    • Bit 0 $( \rightarrow )$ Spin $( -1 )$
  2. Select Minimal Seed Set:
    Identify a minimal subset of spin values and their positions such that:

    • If only these spins are known and fixed in value, with all others being random,
    • Then, under energy minimization to the ground state, the system will evolve into the original spin matrix.
  3. Store the Seed Set:
    Save:

    • A list of coordinates of the necessary spins to fix: $( (i, j) )$
    • Corresponding spin values for these fixed spins: $( s_{ij} \in {-1, +1} )$

Output:
A compressed representation consisting of a small list of $((i, j, s_{ij}))$ entries.


Decompression Algorithm (Decoding)

Input:

  • The list of seed coordinates and spin values
  • The lattice size $( N \times N )$
  • Knowledge of the energy minimization rules (i.e., Ising Hamiltonian)

Steps:

  1. Initialize Lattice:

    • Create an $( N \times N )$ spin lattice
    • Set the spins at the given coordinates to their seed values
    • Initialize all other spins randomly (e.g., sampled from $( {-1, +1} ))$
  2. Find the Ground State:

    • Apply an energy minimization algorithm to evolve the lattice to the ground state whilst keeping the original set of spins fixed throughout.
  3. Map Spins Back to Bits:

    • Convert each spin back to a bit:
      • Spin $( +1 \rightarrow 1 )$
      • Spin $( -1 \rightarrow 0 )$

Output:
The reconstructed binary array — the original uncompressed data.

Any knowledge on whether this problem is solvable as well as the theoretical limits of this scheme are welcomed. Please get in touch: toby.hallett9@gmail.com.

About

An attempt at achieving data compression using inspiration from the Ising Model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages