We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fd3f317 + 17f46ba commit e5df38eCopy full SHA for e5df38e
pyomo/contrib/sensitivity_toolbox/pynumero.py
@@ -80,14 +80,10 @@ def get_dsdp_dfdp(model, theta):
80
col_remap = {mv_map[id(v)]: i for i, v in enumerate(s_list + theta)}
81
_coo_reorder_cols(J, remap=col_remap)
82
J = J.tocsc()
83
- dB = -(
84
- J
85
- @ scipy.sparse.vstack(
86
- (scipy.sparse.coo_matrix((ns, np)), scipy.sparse.identity(np))
87
- ).tocsc()
88
- )
89
# Calculate sensitivity matrix
90
- dsdp = scipy.sparse.linalg.spsolve(J[:, range(ns)], dB)
+ dsdp = -scipy.sparse.linalg.spsolve(
+ J[:, :ns], J[:, ns:] @ scipy.sparse.identity(np)
+ )
91
# Get a map of state vars to columns
92
s_map = {id(v): i for i, v in enumerate(s_list)}
93
# Get the outputs we are interested in from the list of output vars
0 commit comments