Skip to content

Error when adding a constraint with a partially initialized Symmetric matrix #3771

@araujoms

Description

@araujoms

If I have a Symmetric or Hermitian matrix that contains some #undef, I get an error when trying to use that in a constraint, even though the undefined elements shouldn't affect the result of the calculation. MWE:

using LinearAlgebra
using JuMP
model = Model()
@variable(model, x[1:4])
M = Matrix{AffExpr}(undef,(2,2))
M[1]=x[1]
M[3]=x[2]
M[4]=x[3]
M2=Symmetric(M)
@constraint(model, M2 == Symmetric(randn(2,2)))

Note that if I complete the matrix then the constraint is added correctly:

M[2]=x[4]
@constraint(model, M2 == Symmetric(randn(2,2)))

Of course, the code I'm showing here doesn't make any sense, but this is just a MWE, I swear I got this error when doing a legitimate computation.

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