2

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:

  1. I am not allowed to share some info about the model so I censored them by changing their names to some_vars, or xxx, etc...
  2. 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?
  3. 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
oakca
  • 1,408
  • 1
  • 18
  • 40
  • It seems to me, that you should probably initialize the variable Gamma with a value. Maybe 0 or inf. – mjd Aug 27 '18 at 10:22
  • Yeah but, do you thing does it make sense to init an objective(min) with 0 for example? I ll try tomorrow with inf. Will edit here. – oakca Aug 28 '18 at 23:06
  • @mjd So I tried setting a value, now it gives the same error to an other variable. Should I now initialize every variable with a value... makes no sense to me.. – oakca Aug 29 '18 at 10:07

0 Answers0