Skip to content

Commit

Permalink
Format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Aug 30, 2022
1 parent faa1d8b commit cc29810
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions services/tests/test_optimizer_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def create_optimizer(
self._thrift_client.create_optimizer(
optimizer_id, optimizer_kind, xlimits, cstr_spec, options
)

def create_mixint_optimizer(
self, optimizer_id, optimizer_kind, xtypes, n_obj, cstr_spec, options={}
):
Expand All @@ -60,9 +61,6 @@ def close(self):


# Test function for SEGOMOOMOE
import numpy as np
from smt.applications.mixed_integer import FLOAT, INT

def fun(x): # function with 2 objectives
x = np.atleast_2d(x)
f1 = x[:, 0] - x[:, 1] * x[:, 2]
Expand All @@ -88,12 +86,15 @@ def f_grouped(x):
res = np.hstack((resfun, resg1, resg2))
return res


class TestOptimizerService(unittest.TestCase):
def setUp(self):
cmd = os.path.join(
os.path.dirname(__file__), os.path.pardir, "whatsopt_server", "__main__.py"
)
self.server = subprocess.Popen(["python", cmd, "--logdir", ".", "--outdir", "."])
self.server = subprocess.Popen(
["python", cmd, "--logdir", ".", "--outdir", "."]
)
for _ in range(10):
try:
self.store = OptimizerStoreProxy() # server has to start
Expand Down Expand Up @@ -229,19 +230,21 @@ def test_segmoomoe_cstrs(self):
)
)

xdoe = np.array([
[0.36691555, 0., 1. ],
[0.58432706, 1., 1. ],
[0.09227899, 1., 2. ],
[0.95274182, 1., 2. ],
[0.72873502, 1., 3. ],
[0.87115983, 2., 1. ],
[0.24346361, 2., 3. ],
[0.4221473 , 2., 0. ],
[0.10886813, 2., 1. ],
[0.65557784, 3., 2. ],
[0.39532629, 2., 0. ]
])
xdoe = np.array(
[
[0.36691555, 0.0, 1.0],
[0.58432706, 1.0, 1.0],
[0.09227899, 1.0, 2.0],
[0.95274182, 1.0, 2.0],
[0.72873502, 1.0, 3.0],
[0.87115983, 2.0, 1.0],
[0.24346361, 2.0, 3.0],
[0.4221473, 2.0, 0.0],
[0.10886813, 2.0, 1.0],
[0.65557784, 3.0, 2.0],
[0.39532629, 2.0, 0.0],
]
)
ydoe = f_grouped(xdoe)
print(ydoe)
self.store.create_mixint_optimizer(
Expand Down

0 comments on commit cc29810

Please sign in to comment.