# Method cbls is a local search over complete assignments: every variable always has a value, and the search changes values until every row holds and the objective is as low as it can get. How far an assignment is from feasible is the weighted violation $V_w$ of its rows. It follows ViolationLS [1], which combines: - **Feasibility Jump (FJ):** pick a variable and move it to the value that lowers $V_w$ most, its jump value; - **guided local search (GLS) weights:** at a local minimum, where no such move lowers $V_w$, the rows still violated gain weight, so that satisfying them becomes worth more and the search leaves the minimum; - **Novelty Jump:** compound moves, a short sequence of jumps kept when together they lower $V_w$; - **the objective as one more row**, $f(x) \leq F$: after each feasible point $F$ drops below its objective, so the objective row is violated again until the search finds a better one. New here: - Float, List and Set variables in a nonlinear expression DAG; - structural moves for List and Set; - an adaptive objective step; - an inner solver for Floats, and hooks for a problem's own inner solver; - large neighbourhood search (LNS): on every few kicks, randomise part of the variables and repair with FJ, keeping the result if it is better; - a portfolio of workers sharing incumbents and the objective bound. Two deviations: the batch kind is drawn every batch, and a kick starts from the incumbent. The algorithms below leave out guards, tolerances and caps. | Name | Default | Options | |---|---|---| | threads | 0 (one per core) | `--threads`, `threads=`; 1 = one search | | time limit, seed | 10 s, 42 | `--time-limit`, `--seed`; `time_limit=`, `seed=` | | iteration cap | 0 (none) | `max_iterations` | | [Novelty Jump](#novelty-jump) | on, 0.5 of scalar batches | `use_compound_moves`, `novelty_jump_probability` | | [structural batch](#structural-moves) | auto: 0.33 with List/Set, 1 with no scalar work, else 0 | `structural_batch_probability` | | [structural selection](#structural-moves) | Auto | `structural_selection`, `structural_sample_size` (8), `structural_neighbours`; C++: `move_generators`, `default_structural_generators` | | [objective tie-break](#feasibility-jump) | on | `fj_objective_tie_break` | | [feasibility tolerance](#violation-and-weights) | $10^{-6}$ | `feasibility_tolerance` | | [inner solver](#inner-solver) | off | `--intensify`, `intensify=True`; C++: `FloatIntensifyHook` fields | | [LNS](#diversification) | off | `--lns φ`, `lns=φ`; `--lns-interval`, `lns_interval` (3) | | [FPR](#diversification) | 0; repair off | `fpr_batch_probability`, `fpr_dag_propagation`, `lns_repair_fpr` | | [kick cadence](#diversification) | 100 batches, $p = 0.1$, 300 | C++: `perturbation_period`, `perturbation_probability`, `unproductive_iterations`, `batch_iterations` (1000) | | [worker variants, Float jitter](#diversification) | off, 0 | `diversify_workers`, `float_start_jitter` $\in [0, 1]$ | | [shared bound, pool size](#diversification) | on, $\max(10, 2N)$ | C++: `ParallelConfig::share_objective_bound`, `pool_capacity` | Plain names are `cbls.SearchConfig` fields (C++ `SearchConfig`); flags are both CLIs'; keywords are `cbls.solve`'s; C++ marks what only C++ reaches. ## Model and evaluation The model, $\min f(x)$ s.t. $g_i(x) \le 0$, $h_j(x) = 0$, $x_k \in D_k$, is a DAG: variables are leaves, nodes are operations, each row is a comparison node. Moving $x_v$ changes only its cone $C(v)$, the nodes reachable from $v$. A row affine in $x_v$ is scored in closed form from its cached slope instead. Commit is Probe without the log. ```{pcode} \begin{algorithm} \caption{Probe and rollback} \begin{algorithmic} \Function{Probe}{$v, a$} \State $L \gets [(n, \mathrm{val}(n)) : n \in C(v)]$; $x_v \gets a$ \State $\mathrm{val}(n) \gets \mathrm{eval}(n)$ for each $n \in C(v)$, in topological order \EndFunction \Function{Rollback}{$v, a_0$} \State $x_v \gets a_0$; $\mathrm{val}(n) \gets b$ for each $(n, b) \in L$, with no re-evaluation \EndFunction \end{algorithmic} \end{algorithm} ``` ## Violation and weights $$ v_i(x) = \min\bigl(10^{30}, \max(0, g_i(x))\bigr), \qquad v_j(x) = \min\bigl(10^{30}, \lvert h_j(x) \rvert\bigr) $$ - $V_w(x) = \sum_r w_r\, v_r(x)$ over every row, the objective row $v_0 = \max(0, f(x) - F)$ included; NaN reads as $10^{30}$. - A row holds at $v_r \le \tau = 10^{-6}$ (absolute); the implicit domain rows ($\log$ argument $\ge 10^{-9}$, $\sqrt{\cdot}$ and fractional-power arguments $\ge 0$) only at $v_r = 0$. Feasible: every row but the objective row holds. - Weights start at 1 and reset to 1 at each new best and each kick. At a local minimum, $w_r \leftarrow \rho\, w_r + [\, v_r(x) > \tau \,]$ for every row, with $\rho \in \lbrace 0.95, 1 \rbrace$ drawn uniformly at the start, at each new best and at each kick. ## Feasibility Jump $$ \Delta_v(a) = V_w(x[v{:=}a]) - V_w(x), \qquad a_v^* = \arg\min_{a \in K_v} \Delta_v(a), \qquad s_v = -\Delta_v(a_v^*), $$ ties going to the first candidate in the order below. | Type | Candidates $K_v$ | |---|---| | Bool | $1 - x_v$ | | Int, window $\le 256$ wide | every integer in the domain window | | Int, wider | the window's ends, $x_v \pm 1$, a 32-point grid | | Float | $x_v - v_c / \partial_v v_c$ for up to 4 violated rows $c$ of $v$ (Newton, clamped), the midpoint, the bounds | - A variable that reaches a Ceil, Floor, Round or Element node also gets that node's breakpoints. - Once the search stalls, a Float at a stationary point of its violated rows also gets $x_v \pm \lbrace 10^{-6}, 10^{-2} \rbrace (\lvert x_v \rvert + 1)$. - A violated objective row gives a Newton candidate onto $f = F$: this is how the search descends $f$. - Objective tie-break: before the first feasible point the objective row is inert; for an affine $f$, an exact tie in $\Delta_v$ goes to the candidate that lowers $f$ most, and a jump that only lowers $f$ scores the smallest positive double. ```{pcode} \begin{algorithm} \caption{Feasibility Jump batch} \begin{algorithmic} \For{$L = 1000$ iterations} \State $S \gets \emptyset$ \While{$|S| < 5$ and $Q \setminus S \ne \emptyset$} \State draw $v$ uniformly from $Q \setminus S$; if $J_v$ is stale, $J_v \gets (a_v^*, s_v)$ \State if $s_v \le 0$, $Q \gets Q \setminus \{v\}$, else $S \gets S \cup \{v\}$ \EndWhile \If{$S \ne \emptyset$} \State $v \gets \arg\max_{u \in S} s_u$; $x_v \gets a_v^*$ \State invalidate $J$ of $v$'s row neighbours; add those in violated rows to $Q$ \ElsIf{no row is violated} \State \Return feasible \Else \State $w_r \gets \rho\, w_r + [v_r > \tau]$ for every row; add the variables of violated rows to $Q$ \Comment{local minimum} \EndIf \EndFor \end{algorithmic} \end{algorithm} ``` $Q$: the variables in a violated row; $J$: the cached jumps. A batch also ends after 300 iterations without a new low of the unweighted real-row violation (an unproductive batch, see [Diversification](#diversification)). ## Novelty Jump A Novelty batch searches compound moves under $w'_r = w_r$ for rows violated at entry and $w'_r = w_r / 1024$ otherwise; a move that breaks a satisfied row lifts it to $w_r$. With $s'_v$ the jump score under $w'$, $s_v$ that jump's score under $w$, $s_m$ the summed $s$ of the moves on the stack $T$ and $s_c$ the best $s$ tried at this level, a variable passes the filter $$ F(v):\quad s_m + s'_v > 0 \ \ \lor\ \ s_v > s_c . $$ ```{pcode} \begin{algorithm} \caption{Novelty Jump} \begin{algorithmic} \Function{Search}{$s_m, b$} \State $s_c \gets 0$ \While{$b \ge 0$} \State $v \gets$ the highest $s'_v$ of up to 3 draws from $Q' \setminus T$ that pass $F(v)$ \If{there is none} \State \Return false \EndIf \State $s_c \gets \max(s_c, s_v)$; apply $v$'s jump; push $v$ on $T$ \If{$s_m + s_v > 0$ or \Call{Search}{$s_m + s_v, b$}} \State \Return true \Comment{commit the compound move} \EndIf \State undo $v$; $b \gets b - 1$ \EndWhile \State \Return false \EndFunction \Function{ApplyNoveltyJump}{} \For{$b = 0, 1, 2$} \While{\Call{Search}{$0, b$}} \State clear $T$; $b \gets 0$ \EndWhile \State reset $w'$ on the rows that changed \EndFor \EndFunction \end{algorithmic} \end{algorithm} ``` Search and ApplyNoveltyJump are [1]'s Algorithms 5 and 4. A Novelty batch is GLS over ApplyNoveltyJump (a local minimum updates the weights as in FJ), charged 3 iterations per move and 1 per weight update against the same 1000. ## Structural moves List and Set variables move only in structural batches, LNS and kicks. Every move keeps its variable in its domain (distinct elements, size in $[\text{min}, \text{max}]$, a partition's cover). A move $m$ is scored over the rows $R(m)$ it can change, $\Delta(m) = \sum_{r \in R(m)} w_r \bigl(v_r(m(x)) - v_r(x)\bigr)$. | Variable | Moves | |---|---| | List | swap, 2-opt, relocate, or-opt (2, 3), insert, exchange, remove | | Set | add, remove, swap | | ListPartition | relocate, swap, 2-opt\*, and insert/remove under an at-most-once cover, between member lists | ```{pcode} \begin{algorithm} \caption{Structural batch, first improving} \begin{algorithmic} \For{each generator $g$ (one per List or Set, one per partition), until the deadline} \State $C \gets$ the candidates $g$ generates at $x$; $x_a \gets x$ \For{$m \in C$} \If{$V_w(m(x)) - V_w(x_a) < -10^{-12}$} \State $x_a \gets m(x)$ \EndIf \EndFor \State $x \gets x_a$ \EndFor \end{algorithmic} \end{algorithm} ``` Each $m$ is an edit of $x$. Selection (`structural_selection`): - `FirstImprovingSample`: the algorithm above. - `BestOfSample`: commits the best of at least `structural_sample_size` candidates. - `ViolationGuided`: the same, only for generators whose variables reach a violated row. - `GranularBest`: offers, per partition element, every move pairing it with one of its $k$ nearest neighbours [3]. - `Auto`: `GranularBest` with a neighbour list, else `FirstImprovingSample`. ## Objective bound $$ F = \begin{cases} +\infty & \text{before the first feasible point,} \\ f^* - 1 & f \text{ integer-valued,} \\ f^* - \delta\,(\lvert f^* \rvert + 1) & \text{otherwise,} \end{cases} $$ with $f^*$ the best feasible objective. $\delta$ starts at $10^{-3}$, becomes $\min(10^{-3}, 2\delta)$ at each recorded incumbent and $\max(10^{-6}, \delta/10)$ at a full-period stall, where $F$ is recomputed; it is both the smallest improvement asked for and, through the Newton candidate onto $F$, the descent step. A model without an objective stops at its first feasible point. ## Inner solver With `intensify`, the Floats are polished after each feasible batch on $A(x) = f(x) + V_w(x)$, and the point is recorded again if it stays feasible. Candidates for one Float, each clamped to its bounds, skipping $\lvert \partial \rvert \le 10^{-12}$: $$ x_v - \frac{v_c}{\partial_v v_c} \ \text{(first 3 violated rows } c \text{ of } v\text{)}, \qquad x_v - 0.1 \cdot 2^{-k}\, \partial_v f \ \ (k = 0, \dots, 4). $$ The minimum-norm Newton step on row $c$ moves every Float with $\lvert \partial_v v_c \rvert > 10^{-12}$ (at least two) by $\Delta x = -v_c \nabla v_c / \lVert \nabla v_c \rVert^2$. ```{pcode} \begin{algorithm} \caption{Intensify} \begin{algorithmic} \Repeat \State for each Float $v$: commit its candidate with the lowest $A$, if below $A(x)$ \State for each of the first 5 violated rows $c$: take the minimum-norm Newton step if $A$ drops \Until{neither half improved, or after 3 sweeps} \end{algorithmic} \end{algorithm} ``` This polish is one `InnerSolverHook`, the generic one. In C++ a hook of your own takes its place: problem-specific code the search calls after each feasible batch, and after every batch if it asks, which may change any value and is recorded only if the point is feasible and improves. That is how cbls specialises to a problem without changing the engine; the [UC-CHPED page](uc-chped.md#a-problem-specific-inner-solver) shows one, and the [C++ reference](cpp.md#inner-solver-hooks) the contract. ## Diversification ```{pcode} \begin{algorithm} \caption{Solve} \begin{algorithmic} \State $x \gets$ scalars at their domain value closest to 0, List and Set random; $F \gets +\infty$ \While{budget left} \State kind $\gets$ Structural w.p. $p_s$, else Novelty w.p. 0.5, else FJ, drawn every batch; run one batch \State if $x$ is feasible: record it; \Call{Intensify}{}; record it \State if a new best: $w \gets 1$; redraw $\rho$; stall $\gets 0$; else stall $\gets$ stall $+ 1$ \If{stall $\ge 100$} \State shrink $\delta$; adopt from the pool unless LNS is due, else \Call{Kick}{} \ElsIf{the FJ batch was unproductive and stall $\ge 5$} \State \Call{Kick}{} \Comment{stall kept} \EndIf \EndWhile \State \Return the best point, or the closest approach \Function{Kick}{} \State $x \gets$ the incumbent or the adopted point, if there is one \State \Call{DestroyRepair}{} if LNS is due, else \Call{Perturb}{$p = 0.1$}; $w \gets 1$; redraw $\rho$ \EndFunction \end{algorithmic} \end{algorithm} ``` - **Perturb:** each scalar takes a uniform value in its domain window with probability $p$, each List/Set $\max(1, \operatorname{round}(p\,\lvert e \rvert))$ random moves; if nothing moved, one scalar is forced to a new value. - **LNS** (`lns` $= \phi$): due every `lns_interval`-th kick that may run it (after the first feasible point, only full-period kicks may). It ruins and recreates each ListPartition (SISR [2]), randomises $\max(1, \lfloor \phi n \rfloor)$ other variables (whole registered sequences where given), repairs with FJ (2000 iterations, at most 2 s), and keeps the result only if $(\text{real violation}, f)$ is lexicographically smaller. - **FPR** [4]: a batch fixes integer variables one at a time under propagation of the linear rows (with `fpr_dag_propagation`, also monotone nonlinear rows) and repairs with FJ; `lns_repair_fpr` runs one such dive on LNS's destroyed scalars before its FJ repair. - **Pool:** feasible first, then by $f$; capacity $\max(10, 2N)$; each worker submits every incumbent at once. Adopt draws uniformly from the better half; it adopts nothing from an empty pool and never the current point. - **Portfolio:** $N$ workers, each a search on a copy sharing the model's structure. At each batch boundary a worker lowers its $F$ to the bound of the pool's best feasible objective; one whose search ends with time left restarts from its own point with a new seed. One thread is reproducible per seed; more are not. - **Worker variants:** `diversify_workers` gives workers 1–7 (mod 8) fixed variants of the Novelty probability, kick cadence, FPR, LNS interval and tie-break. `float_start_jitter` $J$ moves each Float's start by a uniform draw in $\pm J \min(\max(1, \lvert x \rvert), \text{half its width})$, in a direct solve and on odd portfolio workers. ## Limits - No lower bound and no proof of optimality or infeasibility: a run ends at its budget, and "infeasible" means no feasible point was found. - Tightly coupled equality rows are slow: a one-variable jump that fixes one row breaks the others, and only weights and compound moves get through. ## References 1. T. O. Davies, F. Didier, L. Perron. ViolationLS: Constraint-Based Local Search in CP-SAT. CPAIOR 2024. 2. J. Christiaens, G. Vanden Berghe. Slack Induction by String Removals for Vehicle Routing Problems. Transportation Science 54(2), 2020. 3. P. Toth, D. Vigo. The Granular Tabu Search and Its Application to the Vehicle-Routing Problem. INFORMS Journal on Computing 15(4), 2003. 4. D. Salvagnin, R. Roberti, M. Fischetti. A fix-propagate-repair heuristic for mixed integer programming. Mathematical Programming Computation, 2024.