Raises:ValueError if strict=True and the problem contains features the solver cannot handle (e.g., integer/binary variables with SciPy).
Automatic method selection (method="auto"):
When method="auto" (default), Optyx automatically selects the best solver based on problem structure:
Problem Type
Selected Method
Linear objective and constraints
linprog (HiGHS LP solver)
Unconstrained, n ≤ 3
Nelder-Mead
Unconstrained, n > 1000
L-BFGS-B
Unconstrained, else
BFGS
Bounds only (no general constraints)
L-BFGS-B
Has equality constraints
trust-constr
Inequality constraints only
SLSQP
Available methods:
Method
Bounds
Constraints
Gradient
Hessian
Description
"auto"
✅
✅
✅
✅
Automatic selection (default)
"linprog"
✅
✅ (linear)
N/A
N/A
HiGHS LP solver (for linear problems)
"SLSQP"
✅
✅
✅
❌
Sequential Least Squares Programming
"trust-constr"
✅
✅
✅
✅
Trust-region constrained optimization
"L-BFGS-B"
✅
❌
✅
❌
Limited-memory BFGS with bounds
"COBYLA"
❌
✅ (ineq)
❌
❌
Constrained Optimization BY Linear Approx
"TNC"
✅
❌
✅
❌
Truncated Newton Conjugate-Gradient
"Powell"
✅
❌
❌
❌
Powell’s conjugate direction method
"Nelder-Mead"
✅
❌
❌
❌
Simplex algorithm (derivative-free)
"CG"
❌
❌
✅
❌
Conjugate gradient
"BFGS"
❌
❌
✅
❌
Broyden-Fletcher-Goldfarb-Shanno
"Newton-CG"
❌
❌
✅
✅
Newton conjugate gradient
"dogleg"
❌
❌
✅
✅
Dog-leg trust-region
"trust-ncg"
❌
❌
✅
✅
Newton conjugate gradient trust-region
"trust-exact"
❌
❌
✅
✅
Nearly exact trust-region
"trust-krylov"
❌
❌
✅
✅
Krylov subspace trust-region
TipRecommended Methods
Linear problems: Use "auto" or "linprog" for best performance
With constraints: Use "SLSQP" or "trust-constr"
Bounds only: Use "L-BFGS-B" for large-scale problems
Unconstrained: Use "BFGS" or "trust-ncg" for smooth problems
NotePerformance
LP problems: ~1x overhead vs raw SciPy (near parity)
NLP problems: ~1.4-2.2x overhead (autodiff cost, but exact gradients)
Repeated solves: 2x-900x speedup due to caching
See the Benchmarks page for detailed performance analysis.
4 Strict Mode
Use strict=True to enforce that the solver can handle all problem features exactly:
# Default: warn and relax integer/binary to continuoussolution = prob.solve() # Works, but may produce fractional values# Strict: fail if problem can't be solved exactlysolution = prob.solve(strict=True) # Raises ValueError for integer/binary
This is useful for production code where you want to ensure correctness:
Prototyping: Use strict=False (default) to quickly test ideas
Production: Use strict=True to catch unsupported configurations early
5 Properties
Property
Type
Description
.name
str | None
Problem name
.objective
Expression
Objective function
.sense
str
"minimize" or "maximize"
.constraints
list[Constraint]
All constraints
.variables
list[Variable]
All decision variables
5.1 Examples
from optyx import Variable, Problemx = Variable("x", lb=0)y = Variable("y", lb=0)prob = ( Problem("demo") .minimize(x**2+ y**2) .subject_to(x + y >=1))print(f"Name: {prob.name}")print(f"Sense: {prob.sense}")print(f"Variables: {[v.name for v in prob.variables]}")print(f"Num constraints: {len(prob.constraints)}")
Name: demo
Sense: minimize
Variables: ['x', 'y']
Num constraints: 1