Skip to content

BUG: in linearterms of function Model.getTermsQuadratic(cons) #1083

Closed

Description

@stopfereric

The function should return: bilinterms, quadterms, linterms of a quadratic constraint.
But it fails at reporting all the linear terms if the variables associated with them also exist in bilinear or quadratic terms.

Try out the following code and you will see:

import pyscipopt

model = pyscipopt.Model()
var1 = model.addVar(name="var1", vtype='C', lb=None)
var2 = model.addVar(name="var2", vtype='C')
var3 = model.addVar(name="var3", vtype='B')
var4 = model.addVar(name="var4", vtype='B')
cons = model.addCons(
            cons=(
                    8 * var4
                    + 4 * var3
                    - 5 * var2
                    + 6 * var3 ** 2
                    - 3 * var1 ** 2
                    + 2 * var2 * var1
                    + 7 * var1 * var3
                    ==
                    -2))
model.writeProblem("ucp.lp")
bilinterms, quadterms, linterms = model.getTermsQuadratic(cons)

The reporting for the bilinear and quadratic terms works well but for the linear terms there is a bug.
Only the linear term 8 * var4 will be displayed, whereas 4 * var3 and -5*var2 aren't recognized.

Activity

  1. Joao-Dionisio commented on Dec 17, 2025

    @Joao-Dionisio
    Member

    Hey @stopfereric , sorry for the huge huge huge delay. The fix should be in #1132 , but it might be subject to change. In any case, your test passes in that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions