This is my following question (3rd) after the two questions I asked before. You can find them below:
1st Finding out reason of Pyomo model infeasibility
2nd Pyomo Util Module Not Found
As you said @Qi Chen (2nd questions answer), I did following:
you can simply take the function at https://github.com/Pyomo/pyomo/blob/master/pyomo/util/infeasible.py and place it in your own code (along with the associated required imports)
By the way above log_infeasible_constraints
function is meant by saying function.
But I encounter an error, that I cannot figure out, why. Here are some pre-knowledge about the model:
- I am not allowed to share some info about the model so I censored them by changing their names to
some_vars
, orxxx
, etc... Gamma
is a variable in the model, and also the objective to minimize. So it is normal that it does not have any value on an infeasible model?- How do I fix the
log_infeasible_constraints
function to show me; "this constraint is making your model infeasible, because of this variable value", or something similar?
Error:
WARNING: Loading a SolverResults object with a warning status into model=xxxxx;
message from solver=Model was proven to be infeasible.
ERROR: evaluating expression: No value for uninitialized NumericValue object
Gamma
(expression: some_var[some_index1] +
some_var[some_index2] + some_var[some_index3] +
some_var[some_index4] + some_var[some_index5] +
some_var[some_index6] + some_var[some_index7] +
some_var[some_index8] + some_var[some_index9] +
some_var[some_index10] - 0.0 - Gamma)
ERROR: evaluating object as numeric value: some_var[some_index1] +
some_var[some_index2] + some_var[some_index3] +
some_var[some_index4] + some_var[some_index5] +
some_var[some_index6] + some_var[some_index7] +
some_var[some_index8] + some_var[some_index9] +
some_var[some_index10] - 0.0 - Gamma
(object: <class 'pyomo.core.kernel.expr_coopr3._SumExpression'>)
No value for uninitialized NumericValue object Gamma
Traceback (most recent call last):
File "xxxxx.py", line 464, in <module>
report_tuples=report_tuples)
File "xxxxx.py", line 213, in xxx_xxxxxx
now = master.created
File "xxxxx.py", line 36, in log_infeasible_constraints
if constr.has_ub() and value(constr.body - constr.upper) >= tol:
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\numvalue.py", line 161, in value
tmp = numeric(exception=exception)
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 208, in __call__
exception=exception))
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 812, in _apply_operation
return sum(c*next(values) for c in self._coef) + self._const
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 812, in <genexpr>
return sum(c*next(values) for c in self._coef) + self._const
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 217, in _evaluate_arglist
yield value(arg, exception=exception)
File "C:\Program Files\Anaconda3\lib\site-packages\pyomo\core\kernel\numvalue.py", line 170, in value
% (obj.name,))
ValueError: No value for uninitialized NumericValue object Gamma