SVD image compression and nonlinear optimization with Gekko, Pyomo, and CasADi , AIMS Ghana 2025
# Mathematical Optimization: Tools and Techniques
**AIMS Ghana — Block Course, December 2025**
*Ounimborbitibou Djabon*
## Overview
This repository covers two major topics in applied mathematical optimization, developed during the course "Mathematical Optimization: Theory, Methods and Applications" taught by Prof. Dr. Abebe Geletu W. Selassie (AIMS Rwanda) at AIMS Ghana in December 2025.
The first topic is image compression using Singular Value Decomposition (SVD), a fundamental technique in numerical linear algebra. The second topic is the formulation and solution of nonlinear optimization problems, both unconstrained and constrained, using three Python-based optimization frameworks: Gekko, Pyomo, and CasADi.
## Repository Structure
```
optimization-tools/
│
├── notebooks/
│ └── optimization_methods.ipynb # Full annotated notebook: SVD + Gekko + Pyomo + CasADi
│
├── data/
│ ├── Timbuktu.jpg # Input image used for SVD compression
│ └── gray_image.txt # Grayscale pixel matrix of the image (text format)
│
├── images/ # Figures exported from the notebook
│
├── .gitignore
├── requirements.txt
└── README.md
```
## Part 1: Image Compression using SVD
A grayscale image is simply a 2D matrix of pixel intensity values. The Singular Value Decomposition factorizes this matrix as:
$$A = U \Sigma V^T$$
By keeping only the $k$ largest singular values and discarding the rest, we obtain a rank-$k$ approximation of the original image that requires far less storage. This is the Eckart-Young theorem: the rank-$k$ truncation is the best possible approximation of $A$ in both the 2-norm and the Frobenius norm.
We apply this to a photograph of the Great Mosque of Djenné in Timbuktu and compare three compression levels.
### Results
| Compression | Singular values kept | Data retained |
|---|---|---|
| 30% | 30 out of 600 | ~5% of original |
| 50% | 50 out of 600 | ~9% of original |
| 80% | 80 out of 600 | ~14% of …