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

How to compute the objective and feasibility of a manually given solution?

回答済み

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jaromił Najman
    • Gurobi Staff

    One easy way is to fix every variable to its sol value. The following pseudo code should give you an idea

    sol = ... # given solution values
    for var in model.getVars():
    # fix variable to its sol value
    var.lb = sol[var]
    var.ub = sol[var]

    # optimize model
    model.optimize()

    if model.status == GRB.OPTIMAL:
    print(model.ObjVal) # print objective value
    print(model.MaxVio) # print maximum violation of the solution

    if model.status == GRB.INFEASIBLE:
    # if given sol values are infeasible generate an IIS file called iis.ilp
    # to easily check why it is infeasible
    model.computeIIS()
    model.write("iis.ilp")

    For additional information please refer to the Attributes documentation and How does Gurobi compute the IIS for infeasible models?

    Best regards, 
    Jaromił

    0

投稿コメントは受け付けていません。