Degeneracy Hunter (Legacy)

Degeneracy Hunter (Legacy)#

Note

v2.2: The original Degeneracy Hunter tool is being deprecated in favor of the newer Diagnostics Toolbox.

Over the next few releases the functionality of Degeneracy Hunter will be moved over to the new Diagnostics Toolbox which will also contain a number of other tools for diagnosing model issues.

class idaes.core.util.model_diagnostics.DegeneracyHunter(block_or_jac, solver=None)[source]#

Degeneracy Hunter is a collection of utility functions to assist in mathematical modeling in Pyomo.

check_rank_equality_constraints(tol=1e-06, dense=False)[source]#

Method to check the rank of the Jacobian of the equality constraints

Parameters:
  • tol – Tolerance for smallest singular value (default=1E-6)

  • dense – If True, use a dense svd to perform singular value analysis, which tends to be slower but more reliable than svds

Returns:

Number of singular values less than tolerance (-1 means error)

check_residuals(tol=1e-05, print_level=1, sort=True)[source]#

Method to return a ComponentSet of all Constraint components with a residual greater than a given threshold which appear in a model.

Parameters:
  • block – model to be studied

  • tol – residual threshold for inclusion in ComponentSet

  • print_level

    controls to extend of output to the screen:

    • 0 - nothing printed

    • 1 - only name of constraint printed

    • 2 - each constraint is pretty printed

    • 3 - pretty print each constraint, then print value for included variable

  • sort – sort residuals in descending order for printing

Returns:

A ComponentSet including all Constraint components with a residual greater than tol which appear in block

check_variable_bounds(tol=1e-05, relative=False, skip_lb=False, skip_ub=False, verbose=True)[source]#

Return a ComponentSet of all variables within a tolerance of their bounds.

Parameters:
  • block – model to be studied

  • tol – residual threshold for inclusion in ComponentSet (default = 1e-5)

  • relative – Boolean, use relative tolerance (default = False)

  • skip_lb – Boolean to skip lower bound (default = False)

  • skip_ub – Boolean to skip upper bound (default = False)

  • verbose – Boolean to toggle on printing to screen (default = True)

Returns:

A ComponentSet including all Constraint components with a residual greater than tol which appear in block

find_candidate_equations(verbose=True, tee=False)[source]#

Solve MILP to find a degenerate set and candidate equations

Parameters:
  • verbose – Print information to the screen (default=True)

  • tee – Print solver output to screen (default=True)

Returns:

either None or dictionary of candidate equations

Return type:

ds

find_irreducible_degenerate_sets(verbose=True, tee=False)[source]#

Compute irreducible degenerate sets

Parameters:
  • verbose – Print information to the screen (default=True)

  • tee – Print solver output to screen (default=True)

Returns:

list of irreducible degenerate sets

Return type:

irreducible_degenerate_sets

static print_variable_bounds(v)[source]#

Print variable, bounds, and value

Parameters:

v – variable

Returns:

None

svd_analysis(n_sv=None, dense=False)[source]#

Perform SVD analysis of the constraint Jacobian

Parameters:
  • n_sv – number of smallest singular values to compute

  • dense – If True, use a dense svd to perform singular value analysis, which tends to be slower but more reliable than svds

Returns:

None

Actions:

Stores SVD results in object

underdetermined_variables_and_constraints(n_calc=1, tol=0.1, dense=False)[source]#

Determines constraints and variables associated with the smallest singular values by having large components in the left and right singular vectors, respectively, associated with those singular values.

Parameters:
  • n_calc – The singular value, as ordered from least to greatest starting from 1, to calculate associated constraints and variables

  • tol – Size below which to ignore constraints and variables in the singular vector

  • dense – If True, use a dense svd to perform singular value analysis, which tends to be slower but more reliable than svds

Returns:

None