Skip to content

[BUG] Problem with only a quadratic constraint (no linear rows) returns nan #1376

@rgsl888prabhu

Description

@rgsl888prabhu

Describe the bug

A problem whose only constraint is a quadratic constraint (no linear
constraint rows) returns nan / NoTermination instead of solving. Adding any
linear row makes it solve correctly.

Steps/Code to reproduce bug

import numpy as np
from cuopt.linear_programming.problem import Problem, MINIMIZE

p = Problem()
x = p.addVariable(lb=-np.inf, name="x")
y = p.addVariable(lb=-np.inf, name="y")
p.addConstraint(2*x*x + 2*x*y + 2*y*y <= 6)   # ONLY a quadratic constraint
p.setObjective(x + y, sense=MINIMIZE)
p.solve()
print(p.Status, p.ObjValue, x.Value)   # 0 nan nan

Output:

0 nan nan

Adding e.g. p.addConstraint(x + y >= -5) before solving makes it return the
correct optimum (-2.0 at x = y = -1).

Expected behavior

A problem with only quadratic (second-order-cone) constraints and no linear rows
should solve normally, not return nan.

Environment details:

Additional context

Surfaced while documenting general-convex-quadratic examples; the barrier / SOC
conversion path appears to require a non-empty linear constraint matrix.

Metadata

Metadata

Assignees

Labels

awaiting responseThis expects a response from maintainer or contributor depending on who requested in last comment.bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions