The IDAES toolset contains a number of utility functions which are useful for quantifying model statistics such as the number of variable and constraints, and calculating the available degrees of freedom in a model. These methods can be found in idaes.core.util.model_statistics
.
The most commonly used methods are degrees_of_freedom
and report_statistics
, which are described below.
The degrees_of_freedom
method calculates the number of degrees of freedom available in a given model. The calcuation is based on the number of unfixed variables which appear in active constraints, minus the number of active equality constraints in the model. Users should note that this method does not consider inequality or deactived constraints, or variables which do not appear in active equality constraints.
idaes.core.util.model_statistics.degrees_of_freedom
The report_statistics
method provides the user with a summary of the contents of their model, including the degrees of freedom and a break down of the different Variables
, Constraints
, Objectives
, Blocks
and Expressions
. This method also includes numbers of deactivated components for the user to use in debugging complex models.
Note
This method only considers Pyomo components in activated Blocks
. The number of deactivated Blocks
is reported, but any components within these Blocks
are not included.
Example Output
Model Statistics
Degrees of Freedom: 0
Total No. Variables: 52
No. Fixed Variables: 12
No. Unused Variables: 0 (Fixed: 0)
No. Variables only in Inequalities: 0 (Fixed: 0)
Total No. Constraints: 40
No. Equality Constraints: 40 (Deactivated: 0)
No. Inequality Constraints: 0 (Deactivated: 0)
No. Objectives: 0 (Deactivated: 0)
No. Blocks: 14 (Deactivated: 0)
No. Expressions: 2
idaes.core.util.model_statistics.report_statistics
In addition to the methods discussed above, the model_statistics
module also contains a number of methods for quantifying model statistics which may be of use to the user in debugging models. These methods come in three types:
- Number methods (start with
number_
) return the number of components which meet a given criteria, and are useful for quickly quantifying differnt types of components within a model for determining where problems may exist. - Set methods (end with
_set
) return a PyomoComponentSet
containing all components which meet a given criteria. These methods are useful for determining where a problem may exist, as theComponentSet
indicates which components may be causing a problem. - Generator methods (end with
_generator
) contain Pythongenerators
which return all components which meet a given criteria.
idaes.core.util.model_statistics