Skip to main content

gurobi.QConstr Not Yet Added

Answered

Comments

5 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?.
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Parijat,

    You encounter this error due to Gurobi's lazy update approach. You can find more information in the documentation of the UpdateMode. To avoid this error, you have to execute the Model.update() function before using any added constraints and/or variables.

    Best regards,
    Jaromił

    0
  • Parijat Mitra
    Gurobi-versary
    Conversationalist
    Investigator

    Thanks for your response, Can you please show a small piece of an example of how to use the Model.update()

    function. 

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    An example would be

    import gurobipy as gp
    from gurobipy import GRB

    # Create a new model
    m = gp.Model("test")
    # Create variables
    x = m.addVar(name="x")
    y = m.addVar(name="y")

    m.addConstr(x*y <= 2)
    m.update()
    0
  • Parijat Mitra
    Gurobi-versary
    Conversationalist
    Investigator

    thank you Juromil Najman

    0

Post is closed for comments.