Gecode 6.4.0
Optimize: sparse optimization and native integer search

This development branch provides an additive API, included with

It is enabled separately from the existing Gecode libraries. A model owns variables, sparse rows, objective data and supported logical/global metadata; a solve returns a historical result rather than a mutable search Space.

Choose the interface and backend

Interface Delivered scope Important boundary
Existing Space, IntVar, BoolVar, SetVar, FloatVar and native search APIs The original CP modeling, global constraints, propagators, search customization and configured parallel search Optimize restrictions below do not remove these existing capabilities. See Programming models and Search engines.
Optimize with Backend::Highs Numerical continuous LP and mixed-integer linear models, including supported binary and semi domains One worker per solve; numerical tolerances and adapter scaling limits apply. Exact and Certified requests are rejected.
Optimize with Backend::Native Finite Integer, Binary and SemiInteger models with exact integral linear data, retained indicators and six typed global families Conservative native coefficient/activity limits; one deterministic worker; no arbitrary continuous or fractional model conversion.
Explicit native LP/frontier/neighborhood APIs Checked integer LP deductions, optional original-row root covers, frontier bounds, binary reliability probes and one bounded incumbent neighborhood Each extension requires an explicit call or setting. No automatic portfolio or commercial-solver performance parity is implied.
QuadraticModel and solve_quadratic Bounded continuous convex minimization or concave maximization expressed as weighted squares plus linear terms Numerical checking; separate model type. No integer QP, quadratic constraints or general nonconvex optimization.

Gecode::Optimize::solve selects native Gecode for active typed globals under Backend::Auto, and HiGHS otherwise. Auto does not select a backend from the requested guarantee: an ordinary linear model requesting Exact must select Native explicitly. Missing or unsupported backends return Unsupported; explicit requests are not silently substituted. Inspect Gecode::Optimize::capabilities, Gecode::Optimize::native_capabilities, Gecode::Optimize::native_lp_capabilities and Gecode::Optimize::quadratic_capabilities for the current build.

A small exact integer model

#include <limits>
namespace O = Gecode::Optimize;
O::Model model;
const auto x = model.add_integer(0, 4, "x");
const auto y = model.add_integer(0, 4, "y");
model.add_row({{x, 1}, {y, 1}}, 3,
std::numeric_limits<double>::infinity(), "demand");
model.minimize({{x, 2}, {y, 1}}, 7);
O::SolveOptions options;
options.backend = O::Backend::Native;
options.guarantee = O::Guarantee::Exact;
options.time_limit_seconds = 10;
const auto result = O::solve(model, options);
if (result.has_solution()) {
const double chosen_y = result.value(y);
(void)chosen_y;
}
// A completed optimum is x=0, y=3, objective=10.
// Check result.termination before claiming optimality.
Optional sparse optimization models, backends and owning results.

For a numerical LP, use Continuous variables and Backend::Highs with Guarantee::Numerical. Consult Building and linking the optional component for the required build.