Skip to main content

How to check which constraints make model infeasible?




  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Anne,

    I recommend checking this article How do I resolve the error "Model is infeasible or unbounded"? first.

    If your model is infeasible, attributes associated with a solution like ObjVal have no values and you will get an error if you try to access them. It is recommended to check whether a solution was found before accessing solution attributes for example by checking the SolCount attribute of the model.

    Best regards,


  • Anne Li van der veen
    First Comment
    First Question

    Hi Marika, 

    thanks for your reply. i tried the Model.computeIIS() already, but unfortunately i do not get it working in my code. for the example, i am unable to load the packages required. is there any other way to access it or would you be able to provide the correct syntax for this?


    thanks in advance!


  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Anne,

    did you set the  DualReductions parameter to 0, call reset on the model, and optimize once again as discussed here? Since you have the output "Model is infeasible or unbounded" you have to check whether it is infeasible or unbounded first.

    In case your problem is indead infeasible and you encounter problems with computeIIS(), could you share the code snippet and the error you get?

  • Anne Li van der veen
    First Comment
    First Question

    hi, im not able to set the DualReductions parameter to 0 for some reason. Im using the pyomo packages and gurobi as a sovler. 

    solver = po.SolverFactory('gurobi')
    result = solver.solve(model, tee = True)


    AttributeError                            Traceback (most recent call last)
    /var/folders/2_/k_6v02vn7gqgppzb5lpshfth0000gn/T/ipykernel_4036/ in <module>
    ----> 1 model.obj.setParam(GRB.Param.DualReductions,0)
    AttributeError: 'ScalarObjective' object has no attribute 'setParam'
    Set parameter Username
    Academic license - for non-commercial use only - expires 2023-02-12
    Read LP format model from file /var/folders/2_/k_6v02vn7gqgppzb5lpshfth0000gn/T/tmpqalpqvlb.pyomo.lp
    Reading time = 0.01 seconds
    x357: 322 rows, 229 columns, 4105 nonzeros
    Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (mac64[x86])
    Thread count: 2 physical cores, 4 logical processors, using up to 4 threads
    Optimize a model with 322 rows, 229 columns and 4105 nonzeros
    Model fingerprint: 0xfae1e91b
    Variable types: 225 continuous, 4 integer (4 binary)
    Coefficient statistics:
      Matrix range     [1e-08, 5e+05]
      Objective range  [7e-02, 5e+01]
      Bounds range     [1e+00, 1e+00]
      RHS range        [1e+00, 2e+04]
    Warning: Model contains large matrix coefficient range
             Consider reformulating model or setting NumericFocus parameter
             to avoid numerical issues.
    Presolve removed 89 rows and 125 columns
    Presolve time: 0.00s
    Explored 0 nodes (0 simplex iterations) in 0.01 seconds (0.00 work units)
    Thread count was 1 (of 4 available processors)
    Solution count 0
    Model is infeasible or unbounded
    Best objective -, best bound -, gap -
    WARNING: Loading a SolverResults object with a warning status into"unknown";
          - termination condition: infeasibleOrUnbounded
          - message from solver: Problem proven to be infeasible or unbounded.
  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    I think to set solver-specific options in Pyomo, add a line like

    solver.options['DualReductions'] = 0

    before solving the model.


Please sign in to leave a comment.