Skip to content

Commit 5b97801

Browse files
committed
updates -- better usage of default arguments, removing in BODriverEX where we pass default arguments, we can just omit arguments here
1 parent 3244e40 commit 5b97801

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

src/Drivers/hiopbbpy/BODriverCI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
max_obj[prob_type][acq_type] = max(max_obj[prob_type][acq_type], y_opt[prob_type][acq_type][n_repeat])
104104
min_obj[prob_type][acq_type] = min(min_obj[prob_type][acq_type], y_opt[prob_type][acq_type][n_repeat])
105105

106-
#if(num_repeat >= 1000 ):
106+
#if(num_repeat == 1000 ):
107107
# np.save("yopt_20iter_1000run.npy", y_opt)
108108

109109
# Define percentiles

src/Drivers/hiopbbpy/BODriverEX.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def con_jac_ineq(x):
5757
for prob_type in prob_type_l:
5858
print()
5959
if prob_type == "LpNorm":
60-
problem = LpNormProblem(nx, xlimits, constraints=None)
60+
problem = LpNormProblem(nx, xlimits)
6161
else:
62-
problem = BraninProblem(constraints=None)
62+
problem = BraninProblem()
6363
problem.set_constraints(user_constraint)
6464

6565
for acq_type in acq_type_l:
@@ -78,6 +78,7 @@ def con_jac_ineq(x):
7878
'acquisition_type': acq_type,
7979
'bo_maxiter': 10,
8080
'opt_solver': 'IPOPT', #"SLSQP" "IPOPT"
81+
'batch_size': 1,
8182
'solver_options': {
8283
'max_iter': 200,
8384
'print_level': 1

src/Drivers/hiopbbpy/LpNormProblem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from hiopbbpy.problems.problem import Problem
99

1010
class LpNormProblem(Problem):
11-
def __init__(self, ndim, xlimits, p=2.0, constraints=None):
11+
def __init__(self, ndim, xlimits, p=2.0, constraints=[]):
1212
name = "LpNormProblem"
1313
super().__init__(ndim, xlimits, name=name, constraints=constraints)
1414
self.p = p

src/hiopbbpy/opt/boalgorithm.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ def optimize(self):
199199
# Update training set with the virtual point
200200
x_train = np.vstack([x_train, x_new ])
201201
y_train_virtual = np.vstack([y_train_virtual, y_virtual])
202-
203-
# TODO: include a parallel evaluator
204202
y_new = self.evaluator.run(self.prob.evaluate, x_train[-self.batch_size:])
205-
#y_new = self.prob.evaluate(np.atleast_2d(x_train[-self.batch_size:]))
206203

207204

208205
y_train = np.vstack([y_train, y_new])

src/hiopbbpy/problems/BraninProblem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# define the Branin problem class
2121
class BraninProblem(Problem):
22-
def __init__(self, constraints=None):
22+
def __init__(self, constraints=[]):
2323
ndim = 2
2424
xlimits = np.array([[-5.0, 10], [0.0, 15]])
2525
name = 'Branin'

src/hiopbbpy/problems/problem.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
Nai-Yuan Chiang <chiang7@llnl.gov>
66
"""
77
import numpy as np
8+
import collections.abc
89
from numpy.random import uniform
910
from scipy.stats import qmc
1011

1112
# define the general optimization problem class
1213
class Problem:
13-
def __init__(self, ndim, xlimits, name=None, constraints=None):
14+
def __init__(self, ndim, xlimits, name=" ", constraints=[]):
1415
self.ndim = ndim
1516
self.xlimits = xlimits
1617
assert self.xlimits.shape[0] == ndim
17-
if name is None:
18-
self.name = " "
19-
else:
20-
self.name = name
18+
assert isinstance(name, str)
19+
assert isinstance(constraints, collections.abc.Sequence)
20+
self.name = name
2121
self.sampler = qmc.LatinHypercube(ndim)
2222
self.constraints = constraints
2323

0 commit comments

Comments
 (0)