Thanks to visit codestin.com
Credit goes to github.com

Skip to content

agroudiev/newton-sos

Repository files navigation

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

Citing

If you use this code in your research, please use the following citation:

@software{newton_sos,
  author = {Groudiev, Antoine},
  title = {{Newton-SOS}: Damped Newton method to solve low-rank problems arising from KernelSOS and Sum-of-Squares relaxations},
  url = {https://github.com/agroudiev/newton-sos},
  version = {0.2.2},
  date = {2025-12-22},
}

About

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

Topics

Resources

License

Stars

Watchers

Forks