get_dsdp_dfdp

(function from pyomo.contrib.sensitivity_toolbox.pynumero)

pyomo.contrib.sensitivity_toolbox.pynumero.get_dsdp_dfdp(model, theta)[source]

Calculate the derivatives of the state variables (s) with respect to parameters (p) (ds/dp), and the derivative of the objective function (f) with respect to p (df/dp). The number of parameters in theta should be the same as the number of degrees of freedom.

Parameters:
  • model (pyomo.environ.Block | pyomo.contrib.pynumero.interfaces.PyomoNLP) – Model to calculate sensitivity on. To retain the cached objects in the pynumero interface, create a PyomoNLP first and pass it to this function.

  • theta (list) – A list of parameters as pyomo.environ.VarData, the number of parameters should be equal to the degrees of freedom.

Returns:

ds/dp (ns + np by np), df/dp (1 by np), row map, column map. The column map maps Pyomo variables p to columns and the row map maps Pyomo variables s to rows.

Return type:

scipy.sparse.csc_matrix, csc_matrix, ComponentMap, ComponentMap