Skip to content

Commit

Permalink
Update in example of the documentation for non-nested DoE
Browse files Browse the repository at this point in the history
  • Loading branch information
mcastanoUQ committed Feb 10, 2025
1 parent 68de940 commit 9ad2647
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 25 deletions.
35 changes: 23 additions & 12 deletions doc/_src_docs/applications/mfck.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions doc/_src_docs/applications/mfck.rstx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _mfk-ref-label:
.. _mfck-ref-label:

Multi-Fidelity Co-Kriging (MFCK)
================================
Expand All @@ -13,7 +13,7 @@ where :math:`\rho(x)`
is a scaling/correlation factor (constant for MFCK) and :math:`\delta(\cdot)` is a discrepancy function.

The additive AR1 formulation was first introduced by Kennedy and O'Hagan [1]_.
While MFK follows the recursive formulation of Le Gratiet [2]_. MFCK uses a block-wise matrix construction for :math:`n` levels of fidelity offering freedom in terms of data input assumptions.
While MFK follows the recursive formulation of Le Gratiet [2]_. MFCK uses ab block-wise matrix construction for :math:`n` levels of fidelity offering freedom in terms of data input assumptions.

References
----------
Expand Down
Binary file modified doc/_src_docs/applications/mfck_TestMFCK_run_mfck_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions smt/applications/tests/test_mfck.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

print_output = False


class TestMFCK(SMTestCase):
def setUp(self):
self.nt = 100
Expand Down Expand Up @@ -98,32 +97,44 @@ def hf_function(x):
# Problem set up
xlimits = np.array([[0.0, 1.0]])
xdoes = NestedLHS(nlevel=2, xlimits=xlimits, random_state=0)
xt_c, xt_e = xdoes(7)
xt_c, xt_e = xdoes(5)

# Delta value for the non-nested difference applied in the LF
delta= 0.05
rnd_state = 1

np.random.seed(rnd_state)
deltas = np.random.uniform(-delta, delta,np.shape(xt_c))
x_LF = xt_c + deltas
x_LF = np.clip(x_LF, xlimits[0][0], xlimits[0][1])


# Evaluate the HF and LF functions
yt_e = hf_function(xt_e)
yt_c = lf_function(xt_c)
yt_c = lf_function(x_LF)


sm = MFCK(theta0=xt_e.shape[1] * [1.0], corr="squar_exp")
sm_non_nested = MFCK(theta0=xt_e.shape[1] * [0.5], corr="squar_exp")

# low-fidelity dataset names being integers from 0 to level-1
sm.set_training_values(xt_c, yt_c, name=0)
sm_non_nested.set_training_values(x_LF, yt_c, name=0)
# high-fidelity dataset without name
sm.set_training_values(xt_e, yt_e)
sm_non_nested.set_training_values(xt_e, yt_e)

# train the model
sm.train()
sm_non_nested.train()

x = np.linspace(0, 1, 101, endpoint=True).reshape(-1, 1)

m, c = sm.predict_all_levels(x)
m_non_nested, c_non_nested = sm_non_nested.predict_all_levels(x)

plt.figure()

plt.plot(x, hf_function(x), label="reference")
plt.plot(x, m[1], linestyle="-.", label="mean_gp")
plt.plot(x, hf_function(x), label="reference HF")
plt.plot(x, lf_function(x), label="reference LF")
plt.plot(x, m_non_nested[1], linestyle="-.", label="mean_gp_non_nested")
plt.scatter(xt_e, yt_e, marker="o", color="k", label="HF doe")
plt.scatter(xt_c, yt_c, marker="*", color="g", label="LF doe")
plt.scatter(x_LF, yt_c, marker="*", color="c", label="LF non-nested doe")

plt.legend(loc=0)
plt.ylim(-10, 17)
Expand Down

0 comments on commit 9ad2647

Please sign in to comment.