Skip to main content

gurobi.QConstr Not Yet Added

Answered

Comments

4 comments

  • 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

Please sign in to leave a comment.