Skip to content

Commit

Permalink
Merge branch 'master' into master-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Saves authored Dec 3, 2024
2 parents 3cdb649 + 8cbd4b3 commit 41d3fc1
Show file tree
Hide file tree
Showing 9 changed files with 2,686 additions and 2,528 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
ruff --version
ruff check .
ruff format --check
- name: Test with pytest and coverage
run: |
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SMT has been developed thanks to contributions from:
* Maël Tremouille
* Mauricio Castano Aguirre
* Mostafa Meliani
* Neal Kesterton
* Nick Thompson
* Nicolas Gonel
* Nina Moëllo
Expand Down
2 changes: 0 additions & 2 deletions smt/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from .vfm import VFM
from .podi import PODI, SubspacesInterpolation
from .cckrg import CoopCompKRG
from .tests.test_mixed_integer import TestMixedInteger

__all__ = [
"VFM",
Expand All @@ -23,5 +22,4 @@
"PODI",
"SubspacesInterpolation",
"CoopCompKRG",
"TestMixedInteger",
]
206 changes: 129 additions & 77 deletions smt/applications/mfck.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions smt/applications/tests/test_ego.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ def f_obj(X):
LHS, design_space, criterion="ese", random_state=random_state
)
Xt = sampling(n_doe)
self.assertAlmostEqual(np.sum(Xt), 28.568852027679586, delta=1e-4)
self.assertAlmostEqual(np.sum(Xt), 33.56885202767958, delta=1e-4)
Xt = np.array(
[
[0.37454012, 1.0],
Expand Down Expand Up @@ -1151,8 +1151,8 @@ def f_obj(X):
n_start=25,
)
x_opt, y_opt, dnk, x_data, y_data = ego.optimize(fun=f_obj)
self.assertAlmostEqual(np.sum(y_data), 7.8471910288712, delta=1e-4)
self.assertAlmostEqual(np.sum(x_data), 34.81192549, delta=1e-4)
self.assertAlmostEqual(np.sum(y_data), 8.846225742003778, delta=1e-4)
self.assertAlmostEqual(np.sum(x_data), 41.81192549000013, delta=1e-4)

def test_ego_gek(self):
ego, fun = self.initialize_ego_gek()
Expand Down
13 changes: 6 additions & 7 deletions smt/applications/tests/test_mfck.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: mcastano
"""

import unittest

import numpy as np
Expand Down Expand Up @@ -50,7 +51,7 @@ def test_mfck(self):
x_lf = deepcopy(xt)
np.random.seed(1)

sm = MFCK(hyper_opt='Cobyla')
sm = MFCK(hyper_opt="Cobyla")
if sm.options.is_declared("xlimits"):
sm.options["xlimits"] = prob.xlimits
sm.options["print_global"] = False
Expand All @@ -63,14 +64,12 @@ def test_mfck(self):

m, c = sm._predict(xt)


num = np.linalg.norm( m[:,0] - yt[:,0])
den = np.linalg.norm(yt[:,0])
num = np.linalg.norm(m[:, 0] - yt[:, 0])
den = np.linalg.norm(yt[:, 0])

t_error = num / den

self.assert_error(t_error, 0.0, 1e-6,1e-6)

self.assert_error(t_error, 0.0, 1e-6, 1e-6)

@staticmethod
def run_mfck_example():
Expand Down Expand Up @@ -117,7 +116,7 @@ def hf_function(x):

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

m,c = sm.predict_all_levels(x)
m, c = sm.predict_all_levels(x)

plt.figure()

Expand Down
21 changes: 11 additions & 10 deletions smt/applications/tests/test_mfck_1fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

from smt.problems import TensorProduct
from smt.sampling_methods import LHS
#from smt.utils.misc import compute_rms_error
#from smt.utils.silence import Silence

# from smt.utils.misc import compute_rms_error
# from smt.utils.silence import Silence
from smt.utils.sm_test_case import SMTestCase
from smt.applications.mfck import MFCK

Expand Down Expand Up @@ -41,19 +42,19 @@ def test_mfk_1fidelity(self):

sampling = LHS(xlimits=prob.xlimits, random_state=0)

sm1 = MFCK(hyper_opt='Cobyla')
sm1 = MFCK(hyper_opt="Cobyla")

sm1.set_training_values(xt, yt[:,0])
sm1.set_training_values(xt, yt[:, 0])
sm1.train()

mean, cov = sm1._predict(xt)

num = np.linalg.norm( mean[:,0] - yt[:,0])
den = np.linalg.norm(yt[:,0])
num = np.linalg.norm(mean[:, 0] - yt[:, 0])
den = np.linalg.norm(yt[:, 0])

t_error = num / den

self.assert_error(t_error, 0.0, 1e-4,1e-4)
self.assert_error(t_error, 0.0, 1e-4, 1e-4)

@staticmethod
def run_mfck_example_1fidelity():
Expand All @@ -78,7 +79,7 @@ def hf_function(x):
# Evaluate the HF function
yt_e = hf_function(xt_e)

sm1 = MFCK(theta0=[1.0], hyper_opt='Cobyla')
sm1 = MFCK(theta0=[1.0], hyper_opt="Cobyla")

# High-fidelity dataset without name
sm1.set_training_values(xt_e, yt_e)
Expand All @@ -90,8 +91,8 @@ def hf_function(x):

# Query the outputs
y, cov = sm1._predict(x)
#_mse = sm.predict_variances(x)
#_derivs = sm.predict_derivatives(x, kx=0)
# _mse = sm.predict_variances(x)
# _derivs = sm.predict_derivatives(x, kx=0)

plt.figure()

Expand Down
2 changes: 1 addition & 1 deletion smt/sampling_methods/lhs.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _maximinESE(
hist_T.extend(inner_loop * [T])
hist_proba.extend(inner_loop * [p_accpt])

if PhiP_best - PhiP_oldbest < tol:
if PhiP_oldbest - PhiP_best > tol:
# flag_imp = 1
if p_accpt >= 0.1 and p_imp < p_accpt:
T = 0.8 * T
Expand Down
Loading

0 comments on commit 41d3fc1

Please sign in to comment.