Examples and Validation

This chapter lists runnable entry points that exercise the three method families. All example scripts live in the examples/ directory at the repository root (except the benchmark runners, which live in benchmarks/).

API Quick Reference

Script

Primary classes

Solver dependency

examples/Rosenbrock.py

SDPRelaxations

CVXPY/CLARABEL (default) or CVXOPT

examples/GPExample.py

OptimizationProblem, GPRelaxations

GP solver backend

examples/SONCExample.py

OptimizationProblem, SONCRelaxations

GP solver backend

examples/SONCExample33.py

OptimizationProblem, SONCRelaxations

GP solver backend

SDP Example

Run from the repository root with the virtual environment activated:

source .venv/bin/activate
python examples/Rosenbrock.py

Expected behavior:

  1. Initializes an SDPRelaxations object with semigroup-algebra expressions.

  2. Solves an SDP lower-bound problem via the selected solver (CLARABEL by default).

  3. Prints solver summary, objective values, and timing information.

Geometric Programming Example

Run:

python examples/GPExample.py

Expected behavior:

  1. Builds an OptimizationProblem from semigroup-algebra expressions.

  2. Constructs a GPRelaxations model with transformation matrix \(H\).

  3. Prints transformation matrix information and GP solution details.

SONC Examples

Run:

python examples/SONCExample.py
python examples/SONCExample33.py

Expected behavior:

  1. Builds constrained SONC models from semigroup-algebra expressions.

  2. Prints a certified lower bound when the solver succeeds.

  3. Reports runtime and solver status if GP solving is unavailable in the current environment.

Example 3.3 Traceability

The script examples/SONCExample33.py is aligned with the Section 3.3 benchmark used in the repository and is paired with checks in tests/test_sonc_section3.py.

Backend Comparison Benchmark

The cross-backend benchmark (SymEngine vs SymPy) has been archived to benchmarks/archive/ since the rewrite branch was merged into master. The gallery runner remains the primary benchmark entry point:

python benchmarks/run_gallery.py

Additional Examples

The following scripts exercise mean polynomial forms, separating polynomials, and other specialized relaxation techniques:

  • examples/pqforms.py — Power-mean form certificates for nonnegativity.

  • examples/SOSONCSchickSeparating.py — Schick’s SOS+SONC separating example.

  • examples/Rosenbrock.py, examples/Giunta.py, examples/Parsopoulos.py — Classic benchmark problems.

  • examples/McCormick.py — McCormick relaxation on non-convex objective.

Regression Validation

Run the test suite from the repository root with the virtual environment activated:

source .venv/bin/activate
python -m pytest Irene/tests/ tests/ -q

This is the recommended consistency check after modifying optimization modules or documentation examples. Individual test files can be run separately, e.g.:

python -m pytest tests/test_sosonc.py -v