physbo 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {physbo-2.1.0 → physbo-2.2.0}/PKG-INFO +2 -2
- {physbo-2.1.0 → physbo-2.2.0}/physbo/__init__.py +1 -1
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/__init__.py +1 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/__init__.py +1 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/model.py +80 -2
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/pareto.py +40 -19
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/PKG-INFO +2 -2
- {physbo-2.1.0 → physbo-2.2.0}/setup.cfg +1 -1
- {physbo-2.1.0 → physbo-2.2.0}/README.md +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/basis/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/basis/fourier.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/core/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/core/model.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/inf/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/inf/exact.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/_src/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/_src/cov.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/gauss.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/linear.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/predictor.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/prior/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/prior/gauss.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/learning.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/prior.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/_src/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/_src/enhance_gauss.pyx +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/gauss.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/inf/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/inf/exact.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/lik/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/lik/gauss.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/const.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/zero.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/predictor.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/cholupdate.pyx +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/diagAB.pyx +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/logsumexp.pyx +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/traceAB.pyx +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/centering.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/gauss_elim.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/set_config.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/opt/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/opt/adam.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/predictor.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/policy.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/results.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/__init__.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/policy.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/results.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/score.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/score_multi.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/search/utility.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo/variable.py +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/SOURCES.txt +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/dependency_links.txt +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/not-zip-safe +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/requires.txt +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/top_level.txt +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/pyproject.toml +0 -0
- {physbo-2.1.0 → physbo-2.2.0}/setup.py +0 -0
|
@@ -11,7 +11,7 @@ from physbo import blm
|
|
|
11
11
|
from physbo.gp import inf
|
|
12
12
|
from physbo.gp.core import learning
|
|
13
13
|
from physbo.gp.core.prior import prior
|
|
14
|
-
|
|
14
|
+
from physbo.misc import set_config
|
|
15
15
|
|
|
16
16
|
class model:
|
|
17
17
|
def __init__(self, lik, mean, cov, inf="exact"):
|
|
@@ -310,7 +310,7 @@ class model:
|
|
|
310
310
|
|
|
311
311
|
fmean = self.get_post_fmean(X, Z, params=None)
|
|
312
312
|
fcov = self.get_post_fcov(X, Z, params=None, diag=False)
|
|
313
|
-
return np.random.multivariate_normal(fmean, fcov * alpha**2, N)
|
|
313
|
+
return np.random.multivariate_normal(fmean, fcov * alpha ** 2, N)
|
|
314
314
|
|
|
315
315
|
def predict_sampling(self, X, Z, params=None, N=1):
|
|
316
316
|
"""
|
|
@@ -420,3 +420,81 @@ class model:
|
|
|
420
420
|
params = bfgs.run(X, t)
|
|
421
421
|
|
|
422
422
|
self.set_params(params)
|
|
423
|
+
|
|
424
|
+
class sfs(model):
|
|
425
|
+
|
|
426
|
+
def __init__(self, lik, mean, cov, inf="exact",config=None):
|
|
427
|
+
super().__init__(lik, mean, cov, inf)
|
|
428
|
+
|
|
429
|
+
self.config = config
|
|
430
|
+
|
|
431
|
+
def prepare(self, X, t, params=None):
|
|
432
|
+
return super().prepare(X, t, params)
|
|
433
|
+
|
|
434
|
+
def fit(self, X, t):
|
|
435
|
+
"""
|
|
436
|
+
Fitting function (update parameters)
|
|
437
|
+
|
|
438
|
+
Parameters
|
|
439
|
+
----------
|
|
440
|
+
X: numpy.ndarray
|
|
441
|
+
N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.
|
|
442
|
+
|
|
443
|
+
t: numpy.ndarray
|
|
444
|
+
N dimensional array.
|
|
445
|
+
The negative energy of each search candidate (value of the objective function to be optimized).
|
|
446
|
+
config: physbo.misc.set_config object
|
|
447
|
+
|
|
448
|
+
"""
|
|
449
|
+
#config = set_config()
|
|
450
|
+
method = self.config.learning.method
|
|
451
|
+
|
|
452
|
+
if method == "adam":
|
|
453
|
+
adam = learning.adam(self, self.config)
|
|
454
|
+
params = adam.run(X, t)
|
|
455
|
+
|
|
456
|
+
if method in ("bfgs", "batch"):
|
|
457
|
+
bfgs = learning.batch(self, self.config)
|
|
458
|
+
params = bfgs.run(X, t)
|
|
459
|
+
|
|
460
|
+
self.set_params(params)
|
|
461
|
+
|
|
462
|
+
self.prepare(X, t, params=None)
|
|
463
|
+
|
|
464
|
+
self.xtrain = X
|
|
465
|
+
|
|
466
|
+
def get_post_fmean(self, X, Z, params=None):
|
|
467
|
+
return super().get_post_fmean(X, Z, params)
|
|
468
|
+
|
|
469
|
+
def predict(self, Z, params=None):
|
|
470
|
+
"""
|
|
471
|
+
Calculating posterior mean of model (function)
|
|
472
|
+
|
|
473
|
+
Parameters
|
|
474
|
+
==========
|
|
475
|
+
X: numpy.ndarray
|
|
476
|
+
inputs
|
|
477
|
+
Z: numpy.ndarray
|
|
478
|
+
feature maps
|
|
479
|
+
params: numpy.ndarray
|
|
480
|
+
Parameters
|
|
481
|
+
See also
|
|
482
|
+
========
|
|
483
|
+
physbo.gp.inf.exact.get_post_fmean
|
|
484
|
+
"""
|
|
485
|
+
|
|
486
|
+
if params is None:
|
|
487
|
+
params = np.copy(self.params)
|
|
488
|
+
|
|
489
|
+
if self.inf == "exact":
|
|
490
|
+
post_fmu = inf.exact.get_post_fmean(self, self.xtrain, Z, params)
|
|
491
|
+
|
|
492
|
+
return post_fmu
|
|
493
|
+
|
|
494
|
+
def get_params(self,deep=True):
|
|
495
|
+
|
|
496
|
+
mean = self.prior.mean
|
|
497
|
+
cov = self.prior.cov
|
|
498
|
+
config = self.config
|
|
499
|
+
|
|
500
|
+
return {"lik":self.lik,"mean":mean,"cov":cov,"config":config}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
|
-
|
|
9
|
+
import time
|
|
10
10
|
|
|
11
11
|
class Rectangles(object):
|
|
12
12
|
def __init__(self, n_dim, dtype):
|
|
@@ -156,7 +156,7 @@ class Pareto(object):
|
|
|
156
156
|
self.cells.add(lb_idx, ub_idx)
|
|
157
157
|
|
|
158
158
|
def __included_in_non_dom_region(self, p):
|
|
159
|
-
return np.all(
|
|
159
|
+
return np.all(np.any(self.front <= p, axis=1)) # revised on 2025/03/25, vectorized with np.any
|
|
160
160
|
|
|
161
161
|
def __divide_using_binary_search(self):
|
|
162
162
|
front = np.r_[
|
|
@@ -165,17 +165,23 @@ class Pareto(object):
|
|
|
165
165
|
np.full((1, self.num_objectives), np.inf),
|
|
166
166
|
]
|
|
167
167
|
|
|
168
|
-
# Pareto front indices
|
|
169
|
-
# (indices start from 1)
|
|
170
|
-
# Index 0 means anti-ideal value, index `self.front.shape[0] + 1` means ideal point.
|
|
168
|
+
# Pareto front indices sorted in each dimension
|
|
171
169
|
front_idx = np.r_[
|
|
172
170
|
np.zeros((1, self.num_objectives), dtype=int),
|
|
173
171
|
np.argsort(self.front, axis=0) + 1,
|
|
174
172
|
np.full((1, self.num_objectives), self.front.shape[0] + 1, dtype=int),
|
|
175
173
|
]
|
|
176
174
|
|
|
175
|
+
print("front_idx shape", front_idx.shape)
|
|
176
|
+
|
|
177
177
|
rect_candidates = [[np.copy(front_idx[0]), np.copy(front_idx[-1])]]
|
|
178
178
|
|
|
179
|
+
call_time = 0
|
|
180
|
+
|
|
181
|
+
start_time = time.time()
|
|
182
|
+
|
|
183
|
+
# modified on 2025/03/25, optimized checking of non-dominated region
|
|
184
|
+
|
|
179
185
|
while rect_candidates:
|
|
180
186
|
rect = rect_candidates.pop()
|
|
181
187
|
|
|
@@ -184,23 +190,38 @@ class Pareto(object):
|
|
|
184
190
|
lb = [front[lb_idx[d], d] for d in range(self.num_objectives)]
|
|
185
191
|
ub = [front[ub_idx[d], d] for d in range(self.num_objectives)]
|
|
186
192
|
|
|
193
|
+
# first check if lb is in the non-dominated region, if so, add it to the cells
|
|
187
194
|
if self.__included_in_non_dom_region(lb):
|
|
188
195
|
self.cells.add([lb_idx], [ub_idx])
|
|
196
|
+
call_time += 1
|
|
197
|
+
continue
|
|
198
|
+
|
|
199
|
+
# when lb is not in the non-dominated region, check if ub is in the non-dominated region
|
|
200
|
+
# if ub is in the non-dominated region, it means that the whole rectangle is in the dominated region
|
|
201
|
+
if not self.__included_in_non_dom_region(ub):
|
|
202
|
+
call_time += 1
|
|
203
|
+
continue
|
|
204
|
+
|
|
205
|
+
# only when lb is not in the non-dominated region and ub is in the non-dominated region,
|
|
206
|
+
# we need to divide the rectangle into two sub-rectangles
|
|
207
|
+
|
|
208
|
+
rect_sizes = rect[1] - rect[0]
|
|
209
|
+
if np.any(rect_sizes > 1):
|
|
210
|
+
div_dim = np.argmax(rect_sizes)
|
|
211
|
+
div_point = rect[0][div_dim] + int(round(rect_sizes[div_dim] / 2.0))
|
|
212
|
+
|
|
213
|
+
# Left sub-rectangle
|
|
214
|
+
left_ub_idx = np.copy(rect[1])
|
|
215
|
+
left_ub_idx[div_dim] = div_point
|
|
216
|
+
rect_candidates.append([np.copy(rect[0]), left_ub_idx])
|
|
189
217
|
|
|
190
|
-
|
|
191
|
-
|
|
218
|
+
# Right sub-rectangle
|
|
219
|
+
right_lb_idx = np.copy(rect[0])
|
|
220
|
+
right_lb_idx[div_dim] = div_point
|
|
221
|
+
rect_candidates.append([right_lb_idx, np.copy(rect[1])])
|
|
192
222
|
|
|
193
|
-
|
|
194
|
-
if np.any(rect_sizes > 1):
|
|
195
|
-
div_dim = np.argmax(rect_sizes)
|
|
196
|
-
div_point = rect[0][div_dim] + int(round(rect_sizes[div_dim] / 2.0))
|
|
223
|
+
end_time = time.time()
|
|
197
224
|
|
|
198
|
-
|
|
199
|
-
left_ub_idx = np.copy(rect[1])
|
|
200
|
-
left_ub_idx[div_dim] = div_point
|
|
201
|
-
rect_candidates.append([np.copy(rect[0]), left_ub_idx])
|
|
225
|
+
print("Execution time:", end_time - start_time)
|
|
202
226
|
|
|
203
|
-
|
|
204
|
-
right_lb_idx = np.copy(rect[0])
|
|
205
|
-
right_lb_idx[div_dim] = div_point
|
|
206
|
-
rect_candidates.append([right_lb_idx, np.copy(rect[1])])
|
|
227
|
+
print("call_time", call_time)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|