Skip to content

[Model] QuadraticProgramming #528

@isPANN

Description

@isPANN

Important

Scoped to Bounded Integer Quadratic Programming. The fully continuous (rational) QP of Garey & Johnson MP2 requires continuous-domain machinery that the library's Problem trait (dims() -> Vec<usize>, a finite product of discrete sets) does not provide. We instead implement a discrete superset of QUBO: integer variables y_i ∈ {-K, ..., K} for a fixed bound K ≥ 1, with linear constraints and quadratic objective. NP-hardness is preserved (Sahni 1974 PARTITION reduction lands in {0,1}^m ⊂ {-K, ..., K}^m). The fully continuous / rational QP version is out of scope for this library and is left as future work; cite Vavasis (1990) for the NP-completeness of the rational form.

Build as optimization, not decision. Value = Min<f64>.
Objective: Minimize the quadratic objective Σ (cᵢyᵢ² + dᵢyᵢ) subject to linear constraints.
Do not add a bound/threshold field for the objective — let the solver find the optimum directly. (The bound field below is the per-variable domain bound K, not an objective threshold.) See #765.

Motivation

QUADRATIC PROGRAMMING (P208) from Garey & Johnson, A6 MP2, restricted to bounded integer variables. A foundational NP-complete optimization problem that bridges integer programming and combinatorial optimization. NP-hardness arises from PARTITION via Sahni (1974); since that reduction places the optimum on {0,1}^m, it remains valid for any per-variable bound K ≥ 1 and the bounded integer variant is therefore NP-hard. Bounded Integer QP is also a strict superset of QUBO (the case K = 1 with y_i ∈ {-1, 0, 1} subsumes {0, 1}-QUBO after a standard affine change of variables) and a superset of QUBO-with-linear-constraints.

The fully continuous / rational case (MP2 as stated in G&J) was open in 1979 (G&J's "(*)" marker) and was shown to be in NP by Vavasis (1990), making it NP-complete. We do not implement the rational version here — the Problem trait's dims() API requires finite discrete domains. Adding continuous-domain support is a separate trait-level design problem, left as future work.

Associated rules:

  • R153: PARTITION to QUADRATIC PROGRAMMING (Sahni-style reduction; lands on {0,1}^m, valid for any K ≥ 1).

Definition

Name: QuadraticProgramming (variant: bounded integer)
Reference: Garey & Johnson, Computers and Intractability, A6 MP2; Sahni (1974) for NP-hardness; Vavasis (1990) for NP-membership of the rational form.

Mathematical definition:

INSTANCE: A positive integer m, a positive integer bound K ≥ 1, a finite set X of pairs (x̄, b) where x̄ ∈ ℤ^m (or rational; integer coefficients suffice for NP-hardness) and b ∈ ℝ, and two m-tuples c̄, d̄ ∈ ℝ^m.

OBJECTIVE: Find an m-tuple ȳ ∈ {-K, -K+1, ..., K-1, K}^m that minimizes Σᵢ₌₁ᵐ (cᵢ yᵢ² + dᵢ yᵢ) subject to x̄ · ȳ ≤ b for all (x̄, b) ∈ X.

The original GJ formulation is a decision problem with threshold B over rationals; here we use the optimization framing with Value = Min<f64> and restrict the variable domain to a finite integer box. The decision answer is YES iff the minimum value ≤ −B (after negating the objective).

Variables

  • Count: m (one variable per dimension of the decision vector ȳ).
  • Per-variable domain: y_i ∈ {-K, -K+1, ..., K-1, K} for a fixed bound K ≥ 1. The dims vector is vec![2*K + 1; m]. The internal config index c ∈ {0, ..., 2K} maps to y_i = c - K.
  • Meaning: yᵢ is the i-th component of the integer decision vector. The feasible region is {-K, ..., K}^m intersected with the polyhedron {ȳ : x̄·ȳ ≤ b for all (x̄, b) ∈ X}. Infeasible configurations evaluate to Min<f64>::infeasible() (or +∞) so the optimum is taken over the feasible set.

Schema (data type)

Type name: QuadraticProgramming
Variants: none (integer domain hard-coded; no graph or weight type parameters).

Field Type Description
num_vars usize Number of variables m
bound usize Per-variable domain bound K; each y_i ∈ {-K, ..., K} so dims = vec![2K+1; m]
constraints Vec<LinearConstraint> Linear constraints x̄·ȳ ≤ b (reuses ILP's LinearConstraint)
quad_coeffs Vec<f64> Quadratic coefficients c̄ = (c₁, ..., cₘ) in objective
lin_coeffs Vec<f64> Linear coefficients d̄ = (d₁, ..., dₘ) in objective

Getter methods:

  • num_vars() → number of variables m
  • bound() → per-variable bound K
  • num_constraints() → number of linear constraints |X|

Complexity

  • Best known exact algorithm: Bounded Integer QP is NP-hard via Sahni (1974) PARTITION → QP (the reduction lands in {0,1}^m, so any K ≥ 1 preserves NP-hardness). No published O*(c^m) bound improves on naive enumeration over the discrete box {-K, ..., K}^m in the general non-convex case; we therefore use the exhaustive bound.
  • Complexity expression: (2*bound + 1)^num_vars

Extra Remark

Full book text (rational version, for reference):

INSTANCE: Finite set X of pairs (x̄,b), where x̄ is an m-tuple of rational numbers and b is a rational number, two m-tuples c̄ and d̄ of rational numbers, and a rational number B.
QUESTION: Is there an m-tuple ȳ of rational numbers such that x̄·ȳ ≤ b for all (x̄,b) ∈ X and such that Σᵢ₌₁ᵐ (cᵢyᵢ² + dᵢyᵢ) ≥ B?

Reference: [Sahni, 1974]. Transformation from PARTITION.
Comment: Not known to be in NP in 1979 [Garey & Johnson, 1979]; resolved by Vavasis (1990): QP is in NP and hence NP-complete. The continuous / rational case is out of scope for this library — Problem::dims() requires finite discrete domains. If we instead require all entries of ȳ be integers in {-K, ..., K} (this issue's scope), NP-hardness is preserved by Sahni's reduction. The Jeroslow (1973) undecidability result concerns unbounded integer variables with quadratic constraints and is not relevant to this bounded-integer formulation.

How to solve

  • It can be solved by (existing) bruteforce. The finite domain {-K, ..., K}^m with dims = vec![2K+1; m] is compatible with BruteForce; infeasible configurations evaluate to +∞.
  • It can be solved by reducing to integer programming. Standard linearization: introduce auxiliary variables z_i = y_i² (encoded via a small constraint gadget over the finite domain {0, ..., K²}), giving a linear objective in (y, z). We do not claim direct ILP solvability in this issue; the dedicated BoundedIntegerQP → ILP reduction can be filed as a follow-up rule.
  • Other: For the K = 1 case with all y_i ∈ {0, 1} (after affine shift), the problem reduces to QUBO-with-linear-constraints. PARTITION instances embedded via Sahni's reduction can be brute-forced directly.

Example Instance

A small Sahni-style PARTITION instance with m = 3, K = 1 (so y_i ∈ {-1, 0, 1}, dims = [3, 3, 3], search space 27).

Underlying PARTITION instance: items with sizes a = (1, 1, 2), total sum S = 4, target half S/2 = 2. We ask whether a subset sums to 2.

QP encoding (Sahni 1974): put c_i = -1, d_i = a_i = (1, 1, 2), and add constraints to force y_i ∈ {0, 1} (i.e., restrict to the {0, 1} slice of {-1, 0, 1}):

Constraint b Meaning
1 (-1, 0, 0) 0 y₁ ≥ 0
2 (0, -1, 0) 0 y₂ ≥ 0
3 (0, 0, -1) 0 y₃ ≥ 0
4 (1, 1, 2) 2 y₁ + y₂ + 2y₃ ≤ 2
5 (-1, -1, -2) -2 y₁ + y₂ + 2y₃ ≥ 2

Constraints 1–3 force y_i ∈ {0, 1} (combined with the domain y_i ∈ {-1, 0, 1}). Constraints 4–5 together force a · y = 2 (subset sums to exactly 2).

Quadratic coefficients: c̄ = (-1, -1, -1).
Linear coefficients: d̄ = (1, 1, 2).

Objective: Minimize Σ (cᵢ yᵢ² + dᵢ yᵢ) = Σ (-yᵢ² + aᵢ yᵢ). For y_i ∈ {0, 1} we have y_i² = y_i, so the objective reduces to Σ (-y_i + a_i y_i) = Σ (a_i - 1) y_i = 0·y₁ + 0·y₂ + 1·y₃.

Expected Outcome

Feasible configurations (satisfying all 5 constraints and y_i ∈ {-1, 0, 1}):

ȳ a·ȳ Objective Σ(-yᵢ² + aᵢ yᵢ)
(1, 1, 0) 2 0
(0, 0, 1) 2 1

All other points in {-1, 0, 1}³ violate at least one constraint (either negativity, or a·y ≠ 2).

Optimal solution: ȳ = (1, 1, 0) with objective value 0. This corresponds to the PARTITION solution {a₁, a₂} = {1, 1} summing to 2.

Suboptimal feasible point: ȳ = (0, 0, 1) with objective value 1 (corresponds to {a₃} = {2} summing to 2; same partition, opposite side).

Infeasible examples: (1, 0, 0) (a·y = 1 ≠ 2); (-1, 0, 0) (violates y₁ ≥ 0); (1, 1, 1) (a·y = 4 > 2).

Brute-force over the 27 configurations confirms the optimum is 0.

References

  • [Sahni, 1974]: [Sahni1974] S. Sahni (1974). "Computationally related problems". SIAM Journal on Computing 3, pp. 262–279.
  • [Vavasis, 1990]: [Vavasis1990] S. A. Vavasis (1990). "Quadratic programming is in NP". Information Processing Letters 36, pp. 73–77.
  • [Kozlov, Tarasov, Khachiyan, 1979]: [Kozlov1979] M. K. Kozlov, S. P. Tarasov, L. G. Khachiyan (1979). "The polynomial solvability of convex quadratic programming". Soviet Mathematics Doklady 20, pp. 1108–1111.
  • [Jeroslow, 1973]: [Jeroslow1973] Robert G. Jeroslow (1973). "There cannot be any algorithm for integer programming with quadratic constraints". Operations Research 21, pp. 221–224.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.modelA model problem to be implemented.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    OnHold

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions