Other Diagnostics Tools#

This module contains utility functions used for computing model diagnostics.

idaes.core.util.diagnostics_tools.utils.check_parallel_jacobian(model, tolerance=0.0001, direction='row', jac=None, nlp=None)[source]#

Check for near-parallel rows or columns in the Jacobian.

Near-parallel rows or columns indicate a potential degeneracy in the model, as this means that the associated constraints or variables are (near) duplicates of each other.

For efficiency, the jac and nlp arguments may be provided if they are already available. If these are provided, the provided model is not used. If either jac or nlp is not provided, a Jacobian and PyomoNLP are computed using the model.

This method is based on work published in:

Klotz, E., Identification, Assessment, and Correction of Ill-Conditioning and Numerical Instability in Linear and Integer Programs, Informs 2014, pgs. 54-108 https://pubsonline.informs.org/doi/epdf/10.1287/educ.2014.0130

Parameters:
  • model – model to be analysed

  • tolerance (float) – tolerance to use to determine if constraints/variables are parallel

  • direction (str) – ‘row’ (default, constraints) or ‘column’ (variables)

  • jac – model Jacobian as a scipy.sparse.coo_matrix, optional

  • nlpPyomoNLP of model, optional

Returns:

list of 2-tuples containing parallel Pyomo components

idaes.core.util.diagnostics_tools.utils.extreme_jacobian_columns(jac, nlp, large=10000.0, small=0.0001)[source]#

Show very large and very small Jacobian columns. A more reliable indicator of a badly-scaled variable than badly_scaled_var_generator.

Parameters:
  • jac – already-existing Jacobian matrix

  • nlp – already-existing Pynumero NLP object from get_jacobian (and thus having vlist and clist attributes)

  • large – >= to this value is considered large

  • small – <= to this is considered small

Returns:

(list of tuples), Column norm, Variable

idaes.core.util.diagnostics_tools.utils.extreme_jacobian_entries(jac, nlp, large=10000.0, small=0.0001, zero=1e-10)[source]#

Show very large and very small Jacobian entries.

Parameters:
  • jac – already-existing Jacobian matrix

  • nlp – already-existing Pynumero NLP object from get_jacobian (and thus having vlist and clist attributes)

  • large – >= to this value is considered large

  • small – <= to this and >= zero is considered small

  • zero – <= to this value is ignored

Returns:

(list of tuples), Jacobian entry, Constraint, Variable

idaes.core.util.diagnostics_tools.utils.extreme_jacobian_rows(jac, nlp, large=10000.0, small=0.0001)[source]#

Show very large and very small Jacobian rows. Typically indicates a badly- scaled constraint.

Parameters:
  • jac – already-existing Jacobian matrix

  • nlp – already-existing Pynumero NLP object from get_jacobian (and thus having vlist and clist attributes)

  • large – >= to this value is considered large

  • small – <= to this is considered small

Returns:

(list of tuples), Row norm, Constraint

idaes.core.util.diagnostics_tools.utils.var_in_block(var, block)[source]#

Check if a variable is within a specific block.

Parameters:
  • var – The variable to check.

  • block – The block to check against.

Returns:

True if the variable is within the block, False otherwise.

idaes.core.util.diagnostics_tools.utils.vars_fixed_to_zero(model)[source]#

Set of variables fixed to 0.

Parameters:

model – The model to check.

Returns:

A set of variables fixed to 0.

idaes.core.util.diagnostics_tools.utils.vars_near_zero(model, variable_zero_value_tolerance)[source]#

Set of variables with value near 0, as determined by the provided tolerance.

Parameters:
  • model – The model to check.

  • variable_zero_value_tolerance – The tolerance to use when determining if a variable is near zero.

  • variable (This is applied to the scaled value of the)

  • mind. (so should be chosen with scaling in)

Returns:

A set of variables with value near 0.

idaes.core.util.diagnostics_tools.utils.vars_violating_bounds(model, tolerance)[source]#

Set of variables with values violating their bounds by more than the provided tolerance.

Parameters:
  • model – The model to check.

  • tolerance – The tolerance to use when determining if a variable is violating its bounds.

  • variable (This is applied to the scaled value of the)

  • mind. (so should be chosen with scaling in)

Returns:

A set of variables with values violating their bounds by more than the provided tolerance.

idaes.core.util.diagnostics_tools.utils.vars_with_extreme_values(model, large, small, zero)[source]#

Set of variables with very large or very small values, as determined by the provided tolerances.

Tolerances are applied to the scaled value of the variable, so should be chosen with scaling in mind.

Parameters:
  • model – The model to check.

  • large – The threshold above which a variable is considered to have a very large value.

  • small – The threshold below which a variable is considered to have a very small value.

  • zero – The threshold below which a variable is considered to have a zero value and thus ignored.

Returns:

A set of variables with very large or very small values.

idaes.core.util.diagnostics_tools.utils.vars_with_none_value(model)[source]#

Set of variables with value None.

Parameters:

model – The model to check.

Returns:

A set of variables with value None.