Skip to content

Commit 62d8742

Browse files
committed
addressing some of Cosmins concerns and cleaning up BODriver
1 parent 53329a9 commit 62d8742

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
11
"""
22
Code description:
3-
for a 1-D example problem
4-
randomly sample training points
5-
define a Kriging-based Gaussian-process (smt backend)
6-
trained on said data
7-
define an LCB acquisition function (not smt backend)
8-
plot the acquisition function and determine
9-
the minimizer so as to test some of the infastructure
10-
from BOAlgorithm
11-
3+
for a 2D example LpNormProblem
4+
1) randomly sample training points
5+
2) define a Kriging-based Gaussian-process (smt backend)
6+
trained on said data
7+
3) determine the minimizer via BOAlgorithm
128
"""
139

1410
import numpy as np
1511
import matplotlib.pyplot as plt
1612
import warnings
1713
warnings.filterwarnings("ignore")
18-
from lp_problem import LpProblem
14+
from LpNormProblem import LpNormProblem
1915
from hiopbbpy.surrogate_modeling import smtKRG
20-
from hiopbbpy.opt import LCBacquisition
2116
from hiopbbpy.opt import BOAlgorithm
2217

2318

2419
### parameters
25-
n_samples = 5 # number of the samples
20+
n_samples = 5 # number of the initial samples to train GP
2621
theta = 1.e-2 # hyperparameter for GP kernel
2722

28-
nx = 1 # dimension of the problem
29-
xlimits = np.array([[-1. ,1.]])
30-
nx = 2
31-
xlimits = np.array([[-5, 5], [-5, 5]])
23+
nx = 2 # dimension of the problem
24+
xlimits = np.array([[-5, 5], [-5, 5]]) # bounds on optimization variable
3225

33-
problem = LpProblem(nx, xlimits)
26+
problem = LpNormProblem(nx, xlimits)
3427
print(problem.name, " problem")
3528

3629
### initial training set
@@ -47,4 +40,3 @@
4740

4841
# Retrieve optimal point
4942
x_opt, y_opt = bo.getOptimalPoint()
50-
print(f"Optimal x: {x_opt}, Optimal y: {y_opt}")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""
2-
Implementation of the LP problem class
2+
Implementation of the LPNorm problem class f(x) = || x ||_p
33
44
Authors: Tucker Hartland <hartland1@llnl.gov>
55
Nai-Yuan Chiang <chiang7@llnl.gov>
66
"""
77
import numpy as np
88
from hiopbbpy.problems.problem import Problem
99

10-
class LpProblem(Problem):
10+
class LpNormProblem(Problem):
1111
def __init__(self, ndim, xlimits, p=2.0):
12-
name = "LpProblem"
12+
name = "LpNormProblem"
1313
super().__init__(ndim, xlimits, name=name)
1414
self.p = p
1515

0 commit comments

Comments
 (0)