cbls

Constraint-based local search

Docs DOI License: MIT

A constraint-based local search engine for small-to-medium mixed discrete-continuous models whose terms an exact MIP or CP solver cannot take as written: non-convex, transcendental or discontinuous ones. It moves variables, mostly one at a time, to lower the weighted violation of the constraints, weights the ones that stay violated more, and treats the objective as one more constraint that tightens at each solution found: ViolationLS (Davies et al., CPAIOR 2024), over an expression DAG. It comes as a C++17 library, a command-line solver and a Python module.

Left, a small model as an expression DAG, with the cone one variable move re-evaluates highlighted. Right, the search loop of batches, feasibility checks and kicks.

Left: a model’s expression DAG; moving y re-evaluates the amber nodes only. Right: the search loop, with the steps a solve runs only when asked.

Left, a small model as an expression DAG, with the cone one variable move re-evaluates highlighted. Right, the search loop of batches, feasibility checks and kicks.

Left: a model’s expression DAG; moving y re-evaluates the amber nodes only. Right: the search loop, with the steps a solve runs only when asked.

Problem

\[\begin{split}\begin{aligned} \min_x\ & f(x) \\ \text{s.t.}\ & g_i(x) \le 0, && i \in I, \\ & h_j(x) = 0, && j \in J, \\ & x_k \in D_k, && k \in K. \end{aligned}\end{split}\]

Each \(D_k\) is Bool, Int or Float (a range), List (an ordered sequence of distinct elements of \(\lbrace 0, \dots, n-1 \rbrace\)) or Set (a subset of it). \(f\), \(g_i\) and \(h_j\) are expressions over \(x\), not necessarily convex, smooth or continuous; the model’s rows hold within an absolute \(10^{-6}\). Moves keep each \(x_k\) in \(D_k\); the search minimises the weighted violation

\[V_w(x) = \sum_{i \in I} w_i \max(0, g_i(x)) + \sum_{j \in J} w_j \lvert h_j(x) \rvert + w_0 \max(0, f(x) - F),\]

with row weights \(w\) and an objective bound \(F\), each term capped at \(10^{30}\), a NaN too. \(\log\), \(\sqrt{\cdot}\) and fractional powers add rows \(g_i\), held exactly, for their domains.

Method

The search follows ViolationLS (Davies et al., 2024); new here are Float, List and Set variables in a nonlinear expression DAG, and an inner solver.

  1. An expression DAG: a one-variable move re-evaluates only that variable’s cone, and undoes from a log.

  2. The objective is a row, \(f(x) \le F\): \(F = +\infty\) until a feasible point, then strictly below the best objective found.

  3. Batches search: Feasibility Jump moves one variable to the value that lowers \(V_w\) most, Novelty Jump makes compound moves (a few jumps that together lower it), Structural batches move List and Set variables. The weights are guided local search’s: they start at 1; at a local minimum they decay by \(\rho \in \lbrace 0.95, 1 \rbrace\) and violated rows gain 1; a new best or a kick resets them.

  4. An inner solver, if asked for (intensify=True), polishes the Floats at each feasible point with Newton steps and line search. In C++ a problem’s own inner solver plugs in as an InnerSolverHook, so the search specialises without changes to the engine, as the unit-commitment hook does.

  5. On stagnation the search kicks: it perturbs some variables, runs large neighbourhood search if asked for (lns=: randomise part of the variables, repair, keep it if better), or adopts a state from the workers’ shared pool.

Details: method. Limits: no bound and no proof of optimality or infeasibility; tightly coupled equality rows are slow.

Results

Benchmark

Compared against

cbls

Comparator

Reading

MIPfeas: 211 MIPLIB instances, 60 s

CP-SAT (OR-Tools 9.15.6755) at its defaults

140 feasible, primal integral 0.390

175 feasible, primal integral 0.168

CP-SAT ahead

MINLPLib: 195 nontrivial instances, 60 s

SCIP 10.0.2 at its defaults

169 feasible, GM(gap+1) 3.60

187 feasible, GM(gap+1) 2.15

SCIP ahead: ratio 1.68 (95% CI 1.18-2.38), cbls wins/losses/ties 27/62/76 over the 165 in the pool

UC-CHPED: 24 unit-commitment rows, 10-600 s

Pedroso et al. 2014’s method on SCIP 11.0.0 preview; SCIP’s MINLP

lowest primal integral on 23 of 24, best or tied final gap (to 0.01 %) on 6 of 24

Pedroso’s method: lowest primal integral on 1 of 24, best or tied final gap on 21 of 24; SCIP’s MINLP: 0 and 3 of 24

cbls first to good solutions, Pedroso’s method ends better

  • Run November 2026: cbls on 16 threads on AMD Ryzen 9 3950X (16 cores, 32 threads), one run (UC-CHPED: the median of 3 seeds on 20 rows); CP-SAT started 32 workers; SCIP single-threaded, 16 at once (MINLPLib), on 16 threads (UC-CHPED).

  • Primal integral: the gap to the best known, averaged over the time limit; 0 (best known from the start) to 2 (never feasible); MIPfeas: geometric mean shifted 0.001.

  • GM(gap+1): geometric mean of 1 + % gap (negative as 0) over instances both solve with a finite best known; ratio below 1: cbls ahead; a win: the other’s gap+1 over 1 % larger, else a tie.

  • Claim: cbls is behind the exact solvers on MIPLIB and MINLPLib at 60 s; on the non-convex unit-commitment rows it has the lowest primal integral on 23 of 24.

Per-benchmark tables and known issues: results.

Usage

pip install git+https://github.com/spoorendonk/cbls  # Python package and cbls command
$ cbls examples/simple.cbls --time-limit 1 --quiet
Status:     feasible
Objective:  12.500000
...
Solution:
  x = 2.50
  y = 2.50

The figure’s model, in Python:

import cbls

m = cbls.Model()
x, y = m.Int(0, 10, "x"), m.Float(0, 10, "y")
s = x + y
m.add_constraint(s >= 3)
m.minimize(x * x + s * cbls.sin(y))
m.close()

result = cbls.solve(m, time_limit=1)
print(result.feasible, result.objective, result.value(x), result.value(y))

More: quick reference · options · results · method

Citing

@software{spoorendonk2026cbls,
  title   = {cbls: constraint-based local search over an expression DAG},
  author  = {Spoorendonk, Simon},
  year    = {2026},
  version = {0.1.0},
  doi     = {10.5281/zenodo.24758098},
  url     = {https://doi.org/10.5281/zenodo.24758098}
}
  • The concept DOI resolves to the latest release; its Zenodo page lists each version’s own DOI.

  • GitHub’s Cite this repository reads CITATION.cff.

License

MIT. See LICENSE.

benchmarks/uc-chped/pedroso/ is GPL-3.0-or-later; see README.md.