An open API service indexing awesome lists of open source software.

https://github.com/evya1/cvx-optimization-to-ml

Convex Optimization and Polynomial System Solver with Dockerized Symbolic Computation via msolve, Sagemath & C++
https://github.com/evya1/cvx-optimization-to-ml

convex convex-optimization cvx cvx-pipeline-framework cvxopt linear-algebra msolve pose-detection pose-estimation rigid-transformations

Last synced: 6 months ago
JSON representation

Convex Optimization and Polynomial System Solver with Dockerized Symbolic Computation via msolve, Sagemath & C++

Awesome Lists containing this project

README

          

# ๐Ÿง  cvx-optimization-to-ml

**C++ Convex Optimization and Polynomial System Solver with Dockerized Symbolic Computation via `msolve`**

This project is a modular C++ pipeline designed for convex optimization and algebraic computation, integrating symbolic solvers like [`msolve`](https://msolve.lip6.fr/) to compute real roots of polynomial systems within Docker. It uses Eigen for linear algebra operations and supports clean reproducible builds via CMake and Make.

---

## ๐Ÿ“ฆ Features

- ๐Ÿงฎ Symbolic solution of multivariate polynomial systems via msolve (Docker-integrated).
- ๐ŸŒ€ Modular structure with Eigen-powered vector/matrix manipulation.
- ๐Ÿณ Full Docker environment for reproducible builds and isolated math toolchain (FLINT, GMP, MPFR).
- ๐Ÿ› ๏ธ Developer-friendly `Makefile` with helper targets for running, testing, and Docker workflows.

---

## ๐Ÿš€ Quick Start Guide

### โœ… Requirements

Make sure the following tools are installed **on your host machine**:

- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
- [Git](https://git-scm.com/)
- Optionally: `make` and `cmake` (if you want to build outside Docker)

---

### ๐Ÿ“ฅ Clone the Repository

```bash
git clone https://github.com/evya1/cvx-optimization-to-ml.git
cd cvx-optimization-to-ml
```

---

### ๐Ÿณ Build and Run via Docker (Recommended)

#### 1. Build the Docker Image

```bash
make docker
```

This builds a two-stage image:

- Stage 1 compiles FLINT and msolve from source.
- Stage 2 produces a minimal runtime image with your binary and tools installed.

#### 2. Run the Main Program (Binary)

```bash
make docker-run
```

This runs `/cvx-optimization-to-ml` inside the container.

#### 3. Run msolve on an Example

```bash
make msolve-test-real-roots-sec4p1
make show-msolve-output-sec4p1
```

This will:

- Run `msolve` on `ms_test_inputs/real_roots_sec4p1.ms`
- Output the result to `ms_outputs/real_roots_sec4p1.out`
- Print the content to your terminal

---

## ๐Ÿ› ๏ธ Developer Workflow (Local Build)

### 1. Build Locally

```bash
make build
```

### 2. Run the Program

```bash
make run
```

### 3. Run Tests (optional)

```bash
make test
```

> โš ๏ธ Currently a placeholder โ€“ you'll need to implement test cases under `/tests`.

---

## ๐Ÿงช Directory Structure

```text
.
โ”œโ”€โ”€ CMakeLists.txt # CMake project definition
โ”œโ”€โ”€ Dockerfile # Multi-stage Dockerfile
โ”œโ”€โ”€ Makefile # All build + docker logic
โ”œโ”€โ”€ include/ # Header files (rotate.hpp)
โ”œโ”€โ”€ src/ # Main source code
โ”‚ โ”œโ”€โ”€ main.cpp
โ”‚ โ””โ”€โ”€ rotate.cpp
โ”œโ”€โ”€ ms\_test\_inputs/ # Sample .ms file for msolve
โ”‚ โ””โ”€โ”€ real\_roots\_sec4p1.ms
โ”œโ”€โ”€ ms\_outputs/ # Output of msolve runs
โ”‚ โ””โ”€โ”€ real\_roots\_sec4p1.out
โ”œโ”€โ”€ build/ (or cmake-build-debug/) # Local CMake build artifacts
โ””โ”€โ”€ tests/ # (Placeholder) test files
```

---

## ๐Ÿ“š Technologies Used

- **C++17**, **Eigen** โ€“ Linear Algebra
- **FLINT**, **GMP**, **MPFR** โ€“ Number theory / multiprecision
- **msolve** โ€“ Real root solver (symbolic polynomial systems)
- **CMake** โ€“ Build configuration
- **Docker** โ€“ Isolated build + runtime
- **Makefile** โ€“ Workflow automation

---

## ๐Ÿง  Example Problem Solved

The provided `real_roots_sec4p1.ms` solves the following polynomial system:

```text
x + 2y + 2z = 1
x^2 + 2y^2 + 2z^2 = x
2xy + 2yz = y
```

Run `make msolve-test-real-roots-sec4p1` to compute its real solutions.

---

## ๐Ÿค Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change or add.

---

## ๐Ÿ™Œ Acknowledgments

- [msolve authors](https://msolve.lip6.fr/)
- [Eigen](https://eigen.tuxfamily.org/)
- [FLINT](http://flintlib.org/)