get_dsdp
(函数来自 pyomo.contrib.sensitivity_toolbox.sens)
- pyomo.contrib.sensitivity_toolbox.sens.get_dsdp(model, theta_names, theta, tee=False)[source]
此函数计算变量相对于参数(theta_names)的梯度向量。
例如,给定:
\[\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}\]函数返回 dx/dp 和 dp/dp,以及列顺序。
以下术语用于定义输出维度: - Ncon = 约束数量 - Nvar = 变量数量 (Nx + Ntheta) - Nx = 决策(原始)变量数量 - Ntheta = 不确定参数数量。
- Parameters:
- Returns:
dsdp (scipy.sparse.csr.csr_matrix) – Ntheta 乘以 Nvar 大小的稀疏矩阵。关于参数 (theta_names) 的 (决策变量, 参数) 的雅可比矩阵。行数 = len(theta_name),列数 = len(col)
col (list) – 变量名称列表