Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyomo.DoE: Corrected initialization when using only lower diagonal of FIM #3532

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion pyomo/contrib/doe/doe.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,23 @@
(len(model.parameter_names), len(model.parameter_names))
)

L_vals_sq = np.linalg.cholesky(fim_np)
# Need to compute the full FIM before initializing the Cholesky factorization
if self.only_compute_fim_lower:
fim_np = fim_np + fim_np.T - np.diag(np.diag(fim_np))

# Check if the FIM is positive definite
# If not, add jitter to the diagonal
# to ensure positive definiteness
min_eig = np.min(np.linalg.eigvals(fim_np))
if min_eig < 1e-6:
jitter = np.abs(min_eig) + 1e-6

Check warning on line 321 in pyomo/contrib/doe/doe.py

View check run for this annotation

Codecov / codecov/patch

pyomo/contrib/doe/doe.py#L321

Added line #L321 was not covered by tests
else:
jitter = 0

# Add jitter to the diagonal to ensure positive definiteness
L_vals_sq = np.linalg.cholesky(
fim_np + jitter * np.eye(len(model.parameter_names))
)
for i, c in enumerate(model.parameter_names):
for j, d in enumerate(model.parameter_names):
model.L[c, d].value = L_vals_sq[i, j]
Expand Down
Loading