How to check which constraints make model infeasible?
AnsweredHi all,
When i try to solve my optimization model i receive the following output, how can i check which constraint makes the model infeasible/how can i fix this best?
furthermore, i get an error when i try to print results. does this have to do with the fact that the model is infeasible? or is there another cause
thanks in advance!
ERROR: evaluating object as numeric value: Y[Pallet.BUY_SELL_WOOD,DC,2,CPM,3] (object: <class 'pyomo.core.base.var._GeneralVarData'>) No value for uninitialized NumericValue object Y[Pallet.BUY_SELL_WOOD,DC,2,CPM,3] ERROR: evaluating object as numeric value: obj (object: <class 'pyomo.core.base.objective.ScalarObjective'>) No value for uninitialized NumericValue object Y[Pallet.BUY_SELL_WOOD,DC,2,CPM,3]
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/tmp8l6uoou0.pyomo.lp Reading time = 0.01 seconds x357: 514 rows, 233 columns, 2073 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 514 rows, 233 columns and 2073 nonzeros Model fingerprint: 0x162a825e Variable types: 229 continuous, 4 integer (4 binary) Coefficient statistics: Matrix range [1e-03, 5e+05] Objective range [7e-02, 5e+01] Bounds range [1e+00, 1e+00] RHS range [1e+00, 1e+05] Presolve removed 39 rows and 49 columns Presolve time: 0.00s Explored 0 nodes (0 simplex iterations) in 0.00 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 model.name="unknown"; - termination condition: infeasibleOrUnbounded - message from solver: Problem proven to be infeasible or unbounded.
-
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,
Marika-1 -
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 lp.py 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!
0 -
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?
0 -
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
solver = po.SolverFactory('gurobi')
result = solver.solve(model, tee = True)--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /var/folders/2_/k_6v02vn7gqgppzb5lpshfth0000gn/T/ipykernel_4036/2827463015.py 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 model.name="unknown"; - termination condition: infeasibleOrUnbounded - message from solver: Problem proven to be infeasible or unbounded.
0 -
I think to set solver-specific options in Pyomo, add a line like
solver.options['DualReductions'] = 0
before solving the model.
0
Please sign in to leave a comment.
Comments
5 comments