Skip to content

Commit

Permalink
add tests mi
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Saves committed Feb 17, 2024
1 parent f86191e commit 9209049
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions smt/applications/tests/test_mixed_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,24 @@ def f_obj(X):

y_doe = [f_obj(xdoe[i])[0] for i in range(len(xdoe))]
# Surrogate
sm = MixedIntegerKrigingModel(
surrogate=KRG(
design_space=design_space,
categorical_kernel=MixIntKernelType.GOWER,
hyper_opt="Cobyla",
theta0=[0.01],
corr="squar_sin_exp",
n_start=100,
),
)
for m in MixIntKernelType:
sm = MixedIntegerKrigingModel(
surrogate=KRG(
design_space=design_space,
categorical_kernel=m,
hyper_opt="Cobyla",
theta0=[0.01],
corr="squar_sin_exp",
n_start=5,
),
)

sm.set_training_values(xdoe, np.array(y_doe))
sm.train()
self.assertTrue(np.shape(sm._surrogate.optimal_theta)[0] == 4)
sm.set_training_values(xdoe, np.array(y_doe))
if m in [MixIntKernelType.EXP_HOMO_HSPHERE, MixIntKernelType.CONT_RELAX]:
with self.assertRaises(ValueError):
sm.train()
else:
sm.train()

def test_krg_mixed_3D(self):
design_space = DesignSpace(
Expand Down

0 comments on commit 9209049

Please sign in to comment.