Skip to content

Add optional optimization APIs and automatic native strategies - #1

Closed
pavelmk wants to merge 1 commit into
codex/solver-parity-basefrom
codex/solver-parity-pr
Closed

pavelmk wants to merge 1 commit into
codex/solver-parity-basefrom
codex/solver-parity-pr

Conversation

@pavelmk

@pavelmk pavelmk commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Add Gecode::Optimize for applications that need owning optimization models,
explicit result guarantees and reusable solve workflows. Native integer solving
now chooses suitable strengthening automatically. An opt-in race can compare
that policy with ordinary Gecode search before committing the remaining budget.
Existing Gecode modeling, propagation and search interfaces remain available.

Changes

  • Add sparse models, starts, LP/MPS exchange, sessions, ordered objectives,
    diagnostics, repair, pools, scenarios and documented C/Python bindings.
    HiGHS supplies numerical LP/MILP and bounded weighted-square continuous QP;
    the native bridge retains its exact integer subset and supported globals.
  • Add checked LP deductions, verified cover cuts, frontier search, reliability
    branching and bounded binary neighborhoods. Structural native selection uses
    compatible mechanisms without problem-family labels or reference objectives.
  • Compose bounded exact presolve, independent components and symmetry constraints
    for identical columns. Restore original coordinates and objective offsets;
    incomplete component solutions never become full-model incumbents or proofs.
  • Strengthen eligible binary knapsack models with exact DP, rolling value rows
    and packed traceback. Separate work, memory and local time caps provide a
    fallback to native search, with independently checked original witnesses.
  • Add NativeRaceOptions and solve_native_race in C++. Two bounded sequential
    probes compare the automatic policy and ordinary BAB. Selection uses validated
    incumbents and valid bounds; the chosen strategy restarts under the same global
    time, node and cancellation budget. Keep the best original incumbent and bound
    even if restarting makes no progress.

Racing is opt-in: the ordinary automatic dispatcher does not silently enable it.
Exploration and restarting can increase total CPU work or solve time. Configurable
trials of several seconds or longer may pay off by finding a much better strategy
for the remaining solve. Early progress is a heuristic, not a speedup guarantee.
The new racing option is not exposed through MiniZinc/FlatZinc yet. No conflict
learning or parallel racing is added.

Validation and measured limits

The complete isolated Release build passes 75/75 CTest entries, including
FAST. Focused racing checks also pass without checked LP and without native
backends. Exhaustive min/max oracle checks cover strategy selection, shared node
limits, retained exact results, starts and interruption. Generator checks preserve
every historical input's JSON and text bytes and independently validate larger
feasible witnesses. Earlier sanitizer validation remains separately documented;
this racing change does not claim a new sanitizer run.

The final benchmark compares the
preserved pre-algorithm Gecode runtime, current automatic racing and frozen
family presets. Ten seconds includes all exploration and restarting. Each
configuration expands until an observed failed upper size, then refines the
bracket to adjacent sizes or approximately 2% for larger inputs. Both repetitions
and every knapsack variant must pass at the reported lower size. All initial
observations remain in the amended, uncapped study.

These are seeded-instance brackets, not mathematical maximum-size guarantees.
Original witnesses are independently checked; large-instance exact optimality is
backend-reported. The same families informed development and preset selection.
The comparison measures combined policies, not an ablation establishing that
racing alone caused the gains. Historical studies remain separate.

General MIQP/QCP/nonlinear optimization and production learning remain outside
scope. Remote platform CI and a rebuild of the older wheel are still pending.

Review base

This draft targets codex/solver-parity-base (e10562fd9), the preserved pre-project source snapshot. The review branch matches the full codex/solver-parity integration tree in one commit. MiniZinc controls are layered in a separate follow-up PR.

Introduce Gecode::Optimize owning sparse models, explicit result guarantees,
starts, exchange, sessions and reusable optimization workflows. Supply numerical
LP/MILP and bounded weighted-square continuous QP through HiGHS, plus an exact
native integer bridge retaining supported globals and documented C/Python APIs.

Select compatible checked LP, cover cuts and branching automatically. Compose
bounded exact presolve, independent components and identical-column symmetry.
Restore original witnesses, offsets and proofs under one shared solve budget.
Use rolling knapsack value rows and packed traceback with work/memory/time caps.

Add opt-in sequential strategy racing in C++, with configurable exploration.
Probe automatic and ordinary native search, select from checked incumbents and
bounds, and restart under the remaining shared time/node/cancellation budget.
Preserve the best probe result. Explicitly document increased CPU/solve-time
costs and the possibility of discovering a much better strategy for longer solves.
Do not expose the new racing option through MiniZinc yet; add no conflict learning.

Validation: complete isolated Release build and 75/75 CTest entries pass;
focused racing checks pass without checked LP and without native backends.
Exhaustive original-oracle, shared-budget and larger-generator checks pass.
Preserve historical observations and add the final three-cohort comparison:
original pre-algorithm native runtime, current automatic racing and frozen
family presets. Expand to observed failed upper inputs without study ceilings,
then refine and confirm sampled brackets. Charge exploration to the same ten
seconds and retain all witnesses, outcomes, settings and provenance. State
nonmonotonicity, backend-reported optimality and combined-policy attribution.
@pavelmk pavelmk closed this Sep 7, 2026
@pavelmk
pavelmk deleted the codex/solver-parity-pr branch September 7, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant