(class from pyomo.contrib.solver.solvers.knitro.utils)
pyomo.contrib.solver.solvers.knitro.utils
Bases: Function
Function
Holds the data required to evaluate a non-linear expression.
This class stores a Pyomo expression along with its variables and can compute gradient and Hessian information for use with optimization solvers.
list of variables referenced in the expression.
list[VarData]
The Pyomo expression representing the non-linear function.
Expression
Gradient expressions mapped by variable.
Mapping[VarData, Expression]
Hessian expressions mapped by variable pairs.
Mapping[tuple[VarData, VarData], Expression]
Level of differentiation to compute: - 0: function evaluation only - 1: function + gradient - 2: function + gradient + hessian
int
Initialize NonlinearExpressionData.
expr (Expression) – The Pyomo expression to evaluate.
variables (Iterable[VarData]) – Variables referenced in the expression.
diff_order (int) – Level of differentiation to compute: - 0: function evaluation only - 1: function + gradient - 2: function + gradient + hessian
Methods
__init__(expr, variables, var_map[, diff_order])
__init__
compute_gradient()
compute_gradient
Compute gradient expressions for the nonlinear expression.
compute_hessian()
compute_hessian
Compute Hessian expressions for the nonlinear expression.
evaluate(x)
evaluate
gradient(x)
gradient
hessian(x, mu)
hessian
Attributes
grad_vars
Get the list of variables for which gradients are available.
hess_vars
Get the list of variable pairs for which Hessian entries are available.
variables
func_expr
grad_map
hess_map
diff_order
Member Documentation
This method computes the gradient of the expression with respect to all variables and stores the results in the grad attribute.
This method computes the Hessian matrix of the expression with respect to all variables and stores the results in the hess attribute. Only the upper triangle of the Hessian is stored to avoid redundancy.
Note
This method requires that compute_gradient() has been called first.
Variables with gradient information.
Variable pairs with Hessian information.
list[tuple[VarData, VarData]]