Skip to content

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

@stopfereric

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.

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