Skip to content

Commit 4773e93

Browse files
committed
more brief changes
Need to try some other numerical things to encourage convergence before attacking Hessian problem...
1 parent 1d53b5a commit 4773e93

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Diff for: pyomo/contrib/doe/doe.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def __init__(
211211
grey_box_solver.config.options['hessian_approximation'] = 'limited-memory'
212212
#grey_box_solver.config.options["linear_solver"] = "ma57"
213213
grey_box_solver.config.options['max_iter'] = 3000
214-
grey_box_solver.config.options['tol'] = 1e-4
214+
grey_box_solver.config.options['tol'] = 2e-3
215215
#grey_box_solver.config.options['mu_strategy'] = "monotone"
216216

217217
self.grey_box_solver = grey_box_solver
@@ -342,6 +342,9 @@ def FIM_egb_cons(m, p1, p2):
342342
# # The solver was unsuccessful, might want to warn the user or terminate gracefully, etc.
343343
model.dummy_obj = pyo.Objective(expr=0, sense=pyo.minimize)
344344
self.solver.solve(model, tee=self.tee)
345+
from idaes.core.util import DiagnosticsToolbox
346+
dt = DiagnosticsToolbox(model)
347+
dt.display_extreme_jacobian_entries()
345348

346349
# Track time to initialize the DoE model
347350
initialization_time = sp_timer.toc(msg=None)
@@ -387,6 +390,9 @@ def FIM_egb_cons(m, p1, p2):
387390
# Solve the full model, which has now been initialized with the square solve
388391
if self.use_grey_box:
389392
res = self.grey_box_solver.solve(model, tee=self.tee)
393+
# from idaes.core.util import DiagnosticsToolbox
394+
# dt = DiagnosticsToolbox(model)
395+
# dt.report_numerical_issues()
390396
else:
391397
res = self.solver.solve(model, tee=self.tee)
392398

Diff for: pyomo/contrib/doe/grey_box_utilities.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,12 @@
3838

3939
import pyomo.environ as pyo
4040

41-
# Remove this and utilize pyomo.contrib.doe
42-
# but resolve the circular import issue.
43-
class ObjectiveLib(Enum):
44-
determinant = "determinant"
45-
trace = "trace"
46-
minimum_eigenvalue = "minimum_eigenvalue"
47-
zero = "zero"
48-
4941

5042
class FIMExternalGreyBox(ExternalGreyBoxModel):
5143
def __init__(
5244
self,
5345
doe_object,
54-
objective_option=ObjectiveLib.determinant,
46+
objective_option="determinant",
5547
logger_level=None,
5648
):
5749
"""
@@ -99,11 +91,13 @@ def __init__(
9991

10092
# Set initial values for inputs
10193
self._input_values = np.asarray(self.doe_object.fim_initial.flatten(), dtype=np.float64)
102-
print(self._input_values)
94+
#print(self._input_values)
10395

10496

10597
def input_names(self):
10698
# Cartesian product gives us matrix indicies flattened in row-first format
99+
# Can use itertools.combinations(self._param_names, 2) with added
100+
# diagonal elements, or do double for loops if we switch to upper triangular
107101
input_names_list = list(itertools.product(self._param_names, self._param_names))
108102
return input_names_list
109103

@@ -186,6 +180,8 @@ def evaluate_jacobian_outputs(self):
186180
# within the eigenvalue-dependent
187181
# objective options...
188182
eig_vals, eig_vecs = np.linalg.eig(M)
183+
#print("Conditon number:")
184+
#print(np.linalg.cond(M))
189185
if min(eig_vals) <= 1:
190186
pass
191187
print("Warning: {:0.6f}".format(min(eig_vals)))

0 commit comments

Comments
 (0)