Skip to main content

Multi-scenario infeasible

Answered

Comments

4 comments

  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    The first scenario is not feasible. Try replacing the scenario-related lines by

    # Scenario 0 
    Attack_base['10', '11'].Rhs = 1
    Attack_base['12', '11'].Rhs = 1
    model.update()

    This will lead to an infeasible/unbounded model.

    Have a look at this article for more hints on debugging that scenario. Hint: generating the IIS and writing it to a file will help you identify the problem :-)

    Kind regards,
    Ronald

    0
  • BOHAO WANG
    • Gurobi-versary
    • First Comment
    • First Question

    # Scenario 0                                                                                                
    model.Params.ScenarioNumber = 0
    model.ScenNName = "pipe (10, 11), (12, 11)"
    Attack_base['10', '11'].ScenNRhs = 1
    Attack_base['12', '11'].ScenNRhs = 1
    model.update()

    # Scenario 1
    model.Params.ScenarioNumber = 1
    model.ScenNName = "pipe (9, 10), (32, 31)"
    # Attack_base['10', '9'].ScenNRhs = 1
    # Attack_base['32', '31'].ScenNRhs = 1

    Thank you for your reply. But it seems still not work. I have checked it. In this way (as the picture or code above shows)the model is feasible actually. And what's the difference between Rhs and ScenNRhs when I want to change the right hands of a constrain in a scenario? The example multiscenario.py uses ScenNRhs? Thanks again for your help.

     

    0
  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    There's a caveat here (please refer to this page in the documentation on the meaning of the model status for multi-scenario models):

    A status of OPTIMAL indicates that optimal solutions were found (subject to tolerances) for all scenarios that have feasible solutions, and that the other scenarios were determined to be infeasible. 

    So, although the log file suggests that "something" was optimal, this actually refers to the solution of the second scenario even though the first scenario is actually infeasible.

    When you iterate over the scenarios and query the ScenNObjVal/ScenNObjBound attributes of the model, you will see that these are (negative) infinity for the first scenario when running your code, indicating that this scenario is infeasible.

    for i in range(model.NumScenarios):
    model.Params.ScenarioNumber = i
    print(f'Scenario {i}: obj={model.ScenNObjVal}, bound={model.ScenNObjBound}')

    Similarly, when you make the change I suggested earlier (solve only a single model with no scenarios), you will see the infeasibility reported as the status and explained in the ILP file that is being generated:

    Maximize
     
    Subject To
     Attack_Constrains[10,11]: Attack[10,11] - Attack[11,10] = 0
     Attack_Base[10,11]: Attack[10,11] = 1
     Attack_Base[11,10]: Attack[11,10] = 0
    Bounds
    Binaries
     Attack[10,11] Attack[11,10]
    End
    0
  • BOHAO WANG
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you very much. I have solved my problem.

    0

Please sign in to leave a comment.