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

Verify whether the given variables satisfy the constraints?

回答済み

コメント

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

    There is no particular single function to achieve that. However, you can fix all variables to a specific value and optimize the model. If the model is infeasible then, you can compute an IIS and write it to a file to see which of the constraints and fixed values cause the infeasibility. You can open the IIS file with any standard text editor.

    A pseudo code would look something like

    model = gp.Model()
    # ...
    # construct model as usual
    # ...
    # add equality constraints to fix variables to some values
    fixedvalues = [...] # list of fixed values for variables you would like to check for feasiblity
    vars = model.getVars()
    for i in range(len(vars)):
    model.addConstr(vars[i] == fixedvalues[i])

    model.optimize()

    if model.status == GRB.OPTIMAL:
    print("Fixed point is feasible")
    elif model.status == GRB.INFEASIBLE:
    print("Fixed point is infeasible. Computing IIS")
    model.computeIIS()
    model.write("IIS.ilp")
    print("IIS written to file IIS.ilp")

    Of course you can generate the fixing equality constraints in a different way.

    Best regards, 
    Jaromił

    0

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