symbopt
symbopt finds global extrema of SymPy expressions under real constraints. Use it when you need symbolic values, exact optimizer coordinates, open-boundary behavior or a global bound. A local search can miss another basin; symbopt combines structural rules, algebraic methods, numerical proposals and proof checks to decide what each result establishes. It currently supports only continuous optimization, no discrete optimization.
Typical applications include fitting polynomial models, allocating resources with linear or quadratic costs, bounding nonlinear designs and checking proposed polynomial inequalities. The application tutorial develops these tasks with executable examples.
Installation
python -m pip install symbopt
Python 3.11 or newer is required. SymPy provides symbolic arithmetic, SciPy and NumPy provide numerical proposals, and python-flint provides Arb enclosures. Optional backends add function analysis, semialgebraic reasoning and numerical mixed-integer quadratic optimization:
python -m pip install 'symbopt[funcprops,semialg]'
python -m pip install 'symbopt[scip]'
Values and optimizing points
import sympy as sp
from symbopt import minimize, maximize, minimize_result, minval, argmin
x, y = sp.symbols("x y", real=True)
assert minimize((x - 2) ** 2, x >= 0, variables=x) == [0, {x: 2}]
assert maximize(
3 * x + 2 * y, [x >= 0, y >= 0, x + y <= 4, x <= 2], variables=(x, y)
) == [10, {x: 2, y: 2}]
assert minval(x**4 - 2 * x**2, variables=x) == -1
assert argmin(x**4 - 2 * x**2, variables=x) == ({x: -1}, {x: 1})
minimize and maximize return plain [value, optimizer] lists. The optimizer is a coordinate mapping or a tuple of mappings for represented isolated optima. Omitted coordinates in a represented partial mapping are free. An empty mapping can also indicate that no optimizer was represented; detailed attainment distinguishes these cases. Value-only helpers return a proved infimum or supremum when available; argmin and argmax return represented attained optimizers. A complete description of every positive-dimensional optimizer set is not always available.
An infimum can be unattained
minval()/ maxval() return a certified infimum/supremum when available.
They do not require attainment. argmin() and argmax() return represented
optimizer mappings and return () for a certified but unattained extremum.
result = minimize_result(x, x > 0, variables=x)
assert result.certified and result.optimum_value == 0
assert result.attained is False
assert argmin(x, x > 0, variables=x) == ()
assert minimize(x, x > 0, variables=x) == [0, {x: 0}]
The last compact mapping identifies a limiting coordinate, not a feasible minimizer. Detailed results distinguish attainment, infeasibility, unboundedness and unfinished work. Use minimize_result, maximize_result or full_output=True to inspect candidates, bounds, proof objects, diagnostics and the solver plan. If the pipeline cannot prove a global value, minval returns None; a numerical best candidate can still be inspected in the detailed result.
Constraints may be relations, And, Or or finite iterables. Or denotes alternative feasible regions. Supply variables=x or variables=(x, y) to distinguish decisions from parameters. bounds={x: (0, 1)} adds actual domain constraints; box_bounds controls interval search. Symbol sign assumptions are used when use_symbol_assumptions=True. Integer decision symbols require the explicitly selected optional quadratic SCIP backend.
Capabilities and limits
| Task | Supported methods | Boundary of the claim |
|---|---|---|
| Fixed univariate polynomial and rational extrema | Exact critical points, poles, exclusions, boundary values and limits | Exact coefficient isolation and comparisons must complete |
| Linear and convex quadratic programs | Numerical LP/QP proposals with exact feasibility and KKT reconstruction | Numerical solver success alone is not an exact proof |
| Nonconvex quadratic models | Exact stationary faces, rational spatial bounds and optional SCIP | Native methods need supported rational continuous domains; SCIP bounds are numerical |
| Parametrised quadratics | Selected PSD stationary forms and scalar affine intervals | General parameter-region stratification is unsupported |
| Polynomial global optimization | Structural bounds, SOS, moments, finite sublevel boxes and optional semialg |
The portfolio is not a complete solver for every polynomial problem |
| Algebraic, Abs and Piecewise expressions | Source-preserving graph lifts, owned branches and exact reductions | Unsupported branch geometry or unresolved feasibility can leave partial results |
| Periodic and selected elementary expressions | Rational trigonometric reductions, independent periodic components, domain and limit analysis | General transcendental global optimization is unsupported |
| Finite-box analytic optimization | Verified interval branch-and-bound with Arb | Function grammar, finite domain, precision and search budgets limit completion |
| Local optimization and critical points | Stationarity, KKT, critical cones and numerical local search | Local classification / candidates do not establish a global optimum, obviously |
| Integer optimization | Explicit optional SCIP for quadratic models | No general exact integer optimization route |
The full capability matrix and limitations state the supported cases. A finite work budget can leave a supported problem unresolved. An unsupported or unknown result does not establish infeasibility.
Evidence and package roles
symbopt owns optimization strategy, value and attainment decisions, and optimizer certificates. funcprops supplies domains, roots, shape and image information, while semialg supplies supported real-algebraic projection and reasoning. funcprops does not require symbopt. An exact image contains attainable values, while an interval enclosure may contain missing values. See ranges and extrema.
Numerical candidates, rigorous interval bounds and exact global certificates have separate statuses. An SOS certificate replays its polynomial identity, Gram matrices, basis, domain multipliers and bound; cached flags cannot establish verification. Exact interval endpoints are rounded outward before numerical search. A tolerance-screened proposal cannot establish an exact feasible witness; original constraints and the objective value are checked again before primal proof claims. A positive optimization gap is a bound, not an exact optimum. The certification guide explains these contracts.
working_precision records a precision request and backend provenance. High-precision inexact input bypasses float64-only fast paths; it does not make every numerical backend arbitrary precision. Optional semialg policy accepts auto, candidate and complete, with cost-aware dispatch in automatic mode. See precision and solver selection.
Learn and look up
- Quickstart, problem formulation and understanding results.
- Application examples, tutorial notebook and documentation index.
- Optimization over regions: pass
region=for SymPy sets, Boolean formulas or optionalsemialggeometry; combine membership with constraints and bounds, reuse prepared regions, reduce covering parametrisations and compute exact optimizer-set formulas or parameter-family relations. - Polynomial and rational methods, global quadratics, univariate analysis and SOS proofs
- Public API, known issues, testing
Development
python -m pip install -e '.[test,docs,lint,release]'
python -m pytest -q -m 'not unsupported and not reference_corpus'
python -m pytest -q tests/reference/corpus
ruff check .
ruff format --check .
python -m sphinx -W --keep-going -b html docs docs/_build/html
The test suite includes exact mathematical oracles, certificate mutations, numerical differential checks, executable documentation and a bounded reference corpus. The testing guide distinguishes supported checks, expected failures and resource-limited cases.
License
GNU General Public License, GPL-3.0-only. See LICENSE.
Metadata
Release files for symbopt 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| symbopt-0.2.0.tar.gz | 471.4 kB | With provenance | Details for symbopt-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| symbopt-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for symbopt-0.2.0-py3-none-any.whl |
Total release size: 751.9 kB
Release files / symbopt-0.2.0.tar.gz
| Download URL | symbopt-0.2.0.tar.gz |
|---|---|
| Size | 471.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42eb690616dccf942e47da3607768936a8349d3a54fbdf3debf08ef4920c00ef
|
|
BLAKE2b-256 checksum How to use checksums |
0aa5d0f390831c05bb4c351a2b629f099b1a79c70010d4ec3a8c961ce139e4b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logRelease files / symbopt-0.2.0-py3-none-any.whl
| Download URL | symbopt-0.2.0-py3-none-any.whl |
|---|---|
| Size | 280.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8f75e0eb3681ddf9572391a3ebcfcb6bf70dc7e8a2aa936d08b42f34e724ad2
|
|
BLAKE2b-256 checksum How to use checksums |
b42610a31da163bc13b95ca04754b59fc334512f7ba912bdbcd54c01a5f5625b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logSecurity for symbopt 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for symbopt-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.