newton-sos

Crates.ionewton-sos
lib.rsnewton-sos
version0.2.2
created_at2025-11-21 22:15:07.038314+00
updated_at2025-12-22 16:10:24.303773+00
descriptionDamped Newton method to solve low-rank problems arising from KernelSOS and Sum-of-Squares relaxations.
homepagehttps://github.com/agroudiev/newton-sos
repositoryhttps://github.com/agroudiev/newton-sos
max_upload_size
id1944370
size109,824
Antoine Groudiev (agroudiev)

documentation

README

newton-sos

Damped Newton method to solve low-rank problems arising from KernelSOS and Sum-of-Squares relaxations

Installation

This project is implemented using both Rust and Python. The Python bindings are created using PyO3, and maturin as the build system.

maturin can be installed directly using pip:

pip install maturin

To build the Rust code and install it directly as a Python package in the current environment, run:

maturin develop --release --features python

This is equivalent to building the wheels and installing it in the current environment:

maturin build --release --out dist --features python
pip install dist/newton_sos-*.whl

Usage

Rust

An example is provided in examples/polynomial.rs. To run it, use:

cargo run --example polynomial --release

Solving an SDP using the library can be done in three steps. First, define a problem by constructing a Problem struct. Then, compute the kernel matrix using the Problem::initialize_native_kernel method with the desired kernel parameters. Finally, call the solve method on the Problem instance to solve the optimization problem:

let problem = Problem::new( ... ); // Define the problem
problem.initialize_native_kernel( ... ); // Compute the kernel matrix
let result = solve(problem, ... ); // Solve the optimization problem

Another function called solve_parallel is also provided to solve multiple problems in parallel.

Python

An example is provided in examples/polynomial.py. To run it, use:

python examples/polynomial.py

after installing the package as described above.

The steps to solve an SDP using the Python bindings are similar to the Rust version. First, define a problem by creating an instance of the Problem class. Then, compute the kernel matrix using the initialize_native_kernel method with the desired kernel parameters. Finally, call the solve method on the Problem instance to solve the optimization problem:

problem = Problem( ... )  # Define the problem
problem.initialize_native_kernel( ... )  # Compute the kernel matrix
result = problem.solve( ... )  # Solve the optimization problem
Commit count: 0

cargo fmt