メインコンテンツへスキップ

Using -1 for lazy value gives wrong result

回答済み

コメント

1件のコメント

  • Erik Halseth
    • Gurobi Staff Gurobi Staff

    Hello Christian,

    Thank you for reaching out to the community forum. We appreciate your contribution.

    To respond to your comments around the usage of lazy attribute = -1, have you seen this article: https://support.gurobi.com/hc/en-us/articles/360025804471-What-is-the-difference-between-user-cuts-and-lazy-constraints?

    In summary, setting the Lazy attribute to -1 instructs Gurobi to treat the constraint as a user cut. When Gurobi does this, it treats the user cut as optional, and the user cuts are not allowed to cut off integer feasible solutions. When the constraints are integrated as lazy constraints (when the attribute takes one values 1,2, or 3), Gurobi spends additional computation time to check for feasibility and validity of the model; this could also result in cutting off integer feasible solutions, impacting the final objective value.

    By way of example, try minimizing a variable x with objective coefficient 1.0, and then toggle between a lazy attribute of -1 and 1, and view the logs for further understanding.

    import gurobipy as gp
    m = gp.Model()
    x = m.addVar(obj=1, vtype="I")
    c = m.addConstr(x >= 1)
    c.Lazy=-1
    m.optimize()
    print(f"\n\n{x.X=}")

     

    Warm thanks,

    Erik H.

    0

サインインしてコメントを残してください。