Skip to content

Commit a2d4318

Browse files
committed
Updated parmest.py file
1 parent d9fdd83 commit a2d4318

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

pyomo/contrib/parmest/parmest.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,12 @@ def _compute_jacobian(experiment, theta_vals, step, solver, tee):
416416
results = solver.solve(model, tee=tee)
417417
assert_optimal_termination(results)
418418

419-
# get the measured variables
420-
y_hat_list = [y_hat for y_hat, y in model.experiment_outputs.items()]
421-
422419
# get the estimated parameter values
423420
param_values = [p.value for p in params]
424421

425422
# get the number of parameters and measured variables
426423
n_params = len(param_values)
427-
n_outputs = len(y_hat_list)
424+
n_outputs = len(model.experiment_outputs)
428425

429426
# compute the sensitivity of the measured variables w.r.t the parameters
430427
J = np.zeros((n_outputs, n_params))
@@ -769,9 +766,6 @@ class Estimator(object):
769766
Default is None.
770767
tee: bool, optional
771768
If True, print the solver output to the screen. Default is False.
772-
logging_level : int, optional
773-
Logging level specified by the user,
774-
e.g., logging.INFO. Default is logging.ERROR.
775769
diagnostic_mode: bool, optional
776770
If True, print diagnostics from the solver. Default is False.
777771
solver_options: dict, optional
@@ -953,9 +947,11 @@ def _create_parmest_model(self, experiment_number):
953947
# TODO, this needs to be turned into an enum class of options that still support
954948
# custom functions
955949
if self.obj_function is ObjectiveType.SSE:
956-
second_stage_rule = SSE_weighted
950+
second_stage_rule = SSE
951+
self.covariance_objective = second_stage_rule
957952
elif self.obj_function is ObjectiveType.SSE_weighted:
958953
second_stage_rule = SSE_weighted
954+
self.covariance_objective = second_stage_rule
959955
else:
960956
# A custom function uses model.experiment_outputs as data
961957
second_stage_rule = self.obj_function
@@ -1223,8 +1219,7 @@ def _cov_at_theta(self, method, solver, step):
12231219
model = _get_labeled_model(experiment)
12241220

12251221
# fix the value of the unknown parameters to the estimated values
1226-
params = [k for k, v in model.unknown_parameters.items()]
1227-
for param in params:
1222+
for param in model.unknown_parameters:
12281223
param.fix(self.estimated_theta[param.name])
12291224

12301225
# re-solve the model with the estimated parameters
@@ -1392,11 +1387,6 @@ def _cov_at_theta(self, method, solver, step):
13921387
raise AttributeError(
13931388
'Experiment model does not have suffix "measurement_error".'
13941389
)
1395-
else:
1396-
raise NotImplementedError(
1397-
'Covariance calculation is only supported for "SSE" and '
1398-
'"SSE_weighted" objectives.'
1399-
)
14001390

14011391
return cov
14021392

0 commit comments

Comments
 (0)