Skip to main content

Reading matrix variables in in callback / Python matrix API

Answered

Comments

6 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff 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?.
  • Matthias Miltenberger
    • Gurobi Staff Gurobi Staff

    Hi Sven,

    Thank you for pointing this out! This is indeed a missing feature and we will most likely add it for the next version.

    Cheers,
    Matthias

    0
  • Robert Luce
    • Gurobi Staff Gurobi Staff

    I wonder about one detail in your message though:  In your callback you do

        v = m.cbGetNodeRel([m._visitors])
    vv = v.getAttr('x')

    where m._visitors is an MVar object, so my expectation would be that v (and not vv) is an ndarray containing the relaxation values for m._visitors.  What would you expect v to be instead?

    0
  • Sven Rahmann
    • Gurobi-versary
    • First Comment
    • First Question

    Dear Robert,

    probably you're right. I thought that v would be something like an Mvar populated with the values in attribute x, but I suppose cbGet NodeRel gives you directly the ndarray? In any case, the error suggests that this is indeed not implemented yet.

    Thanks for the observation.

    Best,

    Sven

    0
  • Robert Luce
    • Gurobi Staff Gurobi Staff

    Hello Sven,

    in the next bugfix release 9.0.1 (due in the next few weeks or so), you'll be able to query relaxation and solution values on MVar objects in the callback. The result of such a query is an ndarray of the same shape as the MVar itself.

    Robert

    0
  • Sven Rahmann
    • Gurobi-versary
    • First Comment
    • First Question

    Hello Robert,

    that is excellent news; thank you.

    Sven

    0

Post is closed for comments.