get_dsdp

(function from pyomo.contrib.sensitivity_toolbox.sens)

pyomo.contrib.sensitivity_toolbox.sens.get_dsdp(model, theta_names, theta, tee=False)[source]

This function calculates gradient vector of the variables with respect to the parameters (theta_names).

For example, given:

\[\begin{split}\min f:\ & p1*x1 + p2*(x2^2) + p1*p2 \\ s.t.\ & c1: x1 + x2 = p1 \\ & c2: x2 + x3 = p2 \\ & 0 <= x1, x2, x3 <= 10 \\ & p1 = 10 \\ & p2 = 5\end{split}\]

the function returns dx/dp and dp/dp, and column orders.

The following terms are used to define the output dimensions: - Ncon = number of constraints - Nvar = number of variables (Nx + Ntheta) - Nx = number of decision (primal) variables - Ntheta = number of uncertain parameters.

Parameters:
  • model (Pyomo ConcreteModel) – model should include an objective function

  • theta_names (list of strings) – List of Var names

  • theta (dict) – Estimated parameters e.g) from parmest

  • tee (bool, optional) – Indicates that ef solver output should be teed

Returns:

  • dsdp (scipy.sparse.csr.csr_matrix) – Ntheta by Nvar size sparse matrix. A Jacobian matrix of the (decision variables, parameters) with respect to parameters (theta_names). number of rows = len(theta_name), number of columns = len(col)

  • col (list) – List of variable names