Skip to content

Quadratic In-Step Range ​

QuadraticInStepRangeFunction is a closed-interval gate, not a floor or step-rounding operation. For a quadratic polynomial p(x), bounds L≤U, and exterior tolerance ε>0:

gε(p)={p(x),L≤p(x)≤U,0,p(x)≤L−ε or p(x)≥U+ε,undefined,otherwise.

The undefined bands make the continuous-domain boundary contract explicit: strict complements cannot be encoded exactly by finitely many non-strict inequalities. Both implementations create three mutually exclusive binary indicators zin, zlow, and zhigh plus a signed result y. With a positive Big-M constant M, the solver model is:

p(x)−Mzin≥L−M,p(x)+Mzin≤U+M,p(x)+Mzlow≤L−ε+M,p(x)−Mzhigh≥U+ε−M,zin+zlow+zhigh=1,y−p(x)−Mzin≥−M,y−p(x)+Mzin≤M,y−Mzin≤0,y+Mzin≥0.

The one-hot partition forces the inside branch throughout [L,U], the low branch at or below L−ε, and the high branch at or above U+ε. The last four rows set y=p(x) only on the inside branch and y=0 otherwise.

API ​

kotlin
val p = QuadraticPolynomial(
    monomials = listOf(QuadraticMonomial.quadratic(Flt64.one, x, x)),
    constant = Flt64.zero
)
val f = QuadraticInStepRangeFunction(
    x = p,
    lower = Flt64.zero,
    upper = Flt64(4.0),
    bigM = Flt64(100.0),
    outsideTolerance = Flt64(1e-6),
    converter = IntoValue.Identity,
    name = "square_gate"
)
rust
let p = Quadratic::new(
    vec![QuadraticMonomial::new_quadratic(1.0, x_index, x_index)],
    0.0,
);
let f = QuadraticInStepRangeFunction::with_parameters(
    11, "square_gate", p, 0.0, 4.0, 100.0, 1e-6,
);

The old Rust step-floor constructor and with_quadratic_bounds API were removed. A separate floor function should be used when the mathematical operation is L+|s|⌊(U−L)/|s|⌋.

Evaluation and registration ​

Evaluation returns the input on the closed interval, zero beyond the exterior tolerance, and null/None in either undefined tolerance band. Registration adds three binary indicators and the signed result helper, then emits nine rows. A linear input is emitted through the linear mechanism model; a quadratic input is emitted through the quadratic mechanism model.

Tests and source ​