Skip to content

Commit 055f14c

Browse files
committed
Update parmest.py
1 parent 50d6417 commit 055f14c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pyomo/contrib/parmest/parmest.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ def SSE(model):
234234
expr = sum((y - y_hat) ** 2 for y, y_hat in model.experiment_outputs.items())
235235
return expr
236236

237-
def regularize_term(model, FIM, theta_ref):
237+
def regularize_term(model, prior_FIM, theta_ref):
238238
"""
239239
Regularization term for the objective function, which is used to penalize deviation from a
240240
reference theta
241-
(theta - theta_ref).transpose() * FIM * (theta - theta_ref)
241+
(theta - theta_ref).transpose() * prior_FIM * (theta - theta_ref)
242242
243243
theta_ref: Reference parameter value, element of matrix
244244
FIM: Fisher Information Matrix, matrix
245245
theta: Parameter value, matrix
246246
247247
Added to SSE objective function
248248
"""
249-
expr = ((theta - theta_ref).transpose() * FIM * (theta - theta_ref) for theta in model.unknown_parameters.items())
249+
expr = ((theta - theta_ref).transpose() * prior_FIM * (theta - theta_ref) for theta in model.unknown_parameters.items())
250250
return expr
251251

252252

@@ -285,7 +285,7 @@ def __init__(
285285
self,
286286
experiment_list,
287287
obj_function=None,
288-
FIM=None,
288+
prior_FIM=None,
289289
theta_ref=None,
290290
tee=False,
291291
diagnostic_mode=False,
@@ -444,10 +444,18 @@ def _create_parmest_model(self, experiment_number):
444444
# TODO, this needs to be turned into an enum class of options that still support
445445
# custom functions
446446
if self.obj_function == 'SSE':
447-
second_stage_rule = SSE
447+
448448
if self.FIM and self.theta_ref is not None:
449449
# Regularize the objective function
450-
second_stage_rule = SSE + regularize_term
450+
second_stage_rule = SSE + regularize_term(prior_FIM = self.prior_FIM, theta_ref = self.theta_ref)
451+
elif self.FIM:
452+
theta_ref = model.unknown_parameters.values()
453+
second_stage_rule = SSE + regularize_term(prior_FIM = self.prior_FIM, theta_ref = self.theta_ref)
454+
455+
else:
456+
# Sum of squared errors
457+
second_stage_rule = SSE
458+
451459

452460

453461
else:

0 commit comments

Comments
 (0)