Pyomo不可行检查算法错误

时间:2018-08-27 09:47:15

标签: python function pyomo utility

这是我之前问过的两个问题之后的第三个问题。您可以在下面找到它们:

第一 Finding out reason of Pyomo model infeasibility
第二 Pyomo Util Module Not Found

正如您所说的@Qi Chen(第二个问题的答案),我做到了:

  

您只需在以下位置使用功能   https://github.com/Pyomo/pyomo/blob/master/pyomo/util/infeasible.py   并将其放在您自己的代码中(以及相关的必填   进口)

通过log_infeasible_constraints函数上方的方式是说函数

但是我遇到一个错误,我无法弄清楚为什么。以下是有关模型的一些预知识:

  1. 不允许我分享有关模型的某些信息,因此我通过将其名称更改为some_varsxxx等来审查它们...
  2. Gamma是模型中的变量,也是最小化的目标。因此,在不可行的模型上没有任何价值是正常的吗?
  3. 如何修复log_infeasible_constraints函数以显示给我; “由于该变量值,此约束使您的模型不可行” 或类似的东西?

错误:

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

0 个答案:

没有答案