Skip to main content

matmul: Input operand 0 does not have enough dimensions error

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Eli Towle
    • Gurobi Staff

    Model.addVars() returns a tupledict of Var objects. The \( \texttt{@} \) operator must be used with MVar objects, which are created using Model.addMVar(). For example:

    m = gp.Model('matrix1')

    R = np.eye(4)
    u = m.addMVar(shape=4, name='u')
    m.setObjective(u @ R @ u, GRB.MINIMIZE)

    You might find the matrix1.py and matrix2.py examples helpful.

    1
  • Waseem Akram
    • Gurobi-versary
    • Conversationalist
    • First Question

    I got it. Thank you!

    0

Post is closed for comments.