watertap.core.util.model_diagnostics package
Submodules
watertap.core.util.model_diagnostics.infeasible module
This module contains utility functions for infeasibility diagnostics of WaterTAP models.
- watertap.core.util.model_diagnostics.infeasible.print_close_to_bounds(m, rel_tol=0.0001, abs_tol=1e-12)[source]
Print variables and constraints which are near their bounds
- Parameters:
m – A Pyomo Block or ConcreteModel
rel_tol – (optional) relative tolerance for comparing the value to the bound, default 1e-04
abs_tol – (optional) absolute tolerance for comparing the value to the bound, default 1e-12
- Returns:
None
- watertap.core.util.model_diagnostics.infeasible.print_constraints_close_to_bounds(m, rel_tol=0.0001, abs_tol=1e-05)[source]
print constraints close to their bounds
- Parameters:
m – A Pyomo Block or ConcreteModel
rel_tol – (optional) relative tolerance for comparing the value to the bound, default 1e-04
abs_tol – (optional) absolute tolerance for comparing the value to the bound, default 1e-05
- Returns:
None
- watertap.core.util.model_diagnostics.infeasible.print_infeasible_bounds(m, tol=1e-06, output_file=None)[source]
print the infeasible variable bounds in the model
- Parameters:
m – A Pyomo Block or ConcreteModel
tol – (optional) absolute feasibility tolerance, default 1e-06
output_file – (optional) file to write results to. If None (default) print infeasible variable bounds to the screen.
- Returns:
None
- watertap.core.util.model_diagnostics.infeasible.print_infeasible_constraints(m, tol=1e-06, print_expression=False, print_variables=False, output_file=None)[source]
print the infeasble constraints in the model
- Parameters:
m – A Pyomo Block or ConcreteModel
tol – (optional) absolute feasibility tolerance, default 1e-06
print_expressions – (optional) If True, prints the constraint expression (default: False)
print_variables – (optional) If True, prints the constraint variable names and values (default: False)
output_file – (optional) file to write results to. If None (default) print infeasible variable bounds to the screen.
- Returns:
None
- watertap.core.util.model_diagnostics.infeasible.print_variables_close_to_bounds(m, rel_tol=0.0001, abs_tol=1e-12)[source]
print variables close to their bounds
- Parameters:
m – A Pyomo Block or ConcreteModel
rel_tol – (optional) relative tolerance for comparing the value to the bound, default 1e-04
abs_tol – (optional) absolute tolerance for comparing the value to the bound, default 1e-12
- Returns:
None
watertap.core.util.model_diagnostics.ipopt_initialization module
- watertap.core.util.model_diagnostics.ipopt_initialization.assert_no_initialization_perturbation(blk, optarg=None, solver=None)[source]
Assert that IPOPT will not move the initialization
- Parameters:
blk – Pyomo block
optarg – IPOPT options (default=None) (Should be None if solver is specified)
solver – Pyomo IPOPT solver instance (default=None) (Should be None if optarg is specified).
- Returns:
None
- watertap.core.util.model_diagnostics.ipopt_initialization.generate_initialization_perturbation(blk, bound_push=0.01, bound_frac=0.01, bound_relax_factor=1e-08, user_scaling=False)[source]
Generate the initialization perturbations performed by IPOPT for a given Block
- Parameters:
blk – Pyomo block
bound_push – bound_push to evaluate (same as IPOPT option) (default=1e-2)
bound_frac – bound_frac to evaluate (same as IPOPT option) (default=1e-2)
bound_relax_factor – bound_relax_factor to evaluate (same as IPOPT option) (default=1e-8)
user_scaling – If True, the variables are scaled as if nlp_scaling_method = user-scaling is used. (default=False)
- Yields:
tuple – (pyo.Var object, current_value, perturbed_value)
- watertap.core.util.model_diagnostics.ipopt_initialization.print_initialization_perturbation(blk, bound_push=0.01, bound_frac=0.01, bound_relax_factor=1e-08, user_scaling=False)[source]
Print the initialization perturbations performed by IPOPT for a given Block
- Parameters:
blk – Pyomo block
bound_push – bound_push to evaluate (same as IPOPT option) (default=1e-2)
bound_frac – bound_frac to evaluate (same as IPOPT option) (default=1e-2)
bound_relax_factor – bound_relax_factor to evaluate (same as IPOPT option) (default=1e-8)
user_scaling – If True, the variables are scaled as if nlp_scaling_method = user-scaling is used. (default=False)
- Returns:
None