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.
Files changed (68) hide show
  1. {physbo-2.1.0 → physbo-2.2.0}/PKG-INFO +2 -2
  2. {physbo-2.1.0 → physbo-2.2.0}/physbo/__init__.py +1 -1
  3. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/__init__.py +1 -0
  4. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/__init__.py +1 -0
  5. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/model.py +80 -2
  6. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/pareto.py +40 -19
  7. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/PKG-INFO +2 -2
  8. {physbo-2.1.0 → physbo-2.2.0}/setup.cfg +1 -1
  9. {physbo-2.1.0 → physbo-2.2.0}/README.md +0 -0
  10. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/__init__.py +0 -0
  11. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/basis/__init__.py +0 -0
  12. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/basis/fourier.py +0 -0
  13. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/core/__init__.py +0 -0
  14. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/core/model.py +0 -0
  15. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/inf/__init__.py +0 -0
  16. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/inf/exact.py +0 -0
  17. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/__init__.py +0 -0
  18. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/_src/__init__.py +0 -0
  19. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/_src/cov.py +0 -0
  20. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/gauss.py +0 -0
  21. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/lik/linear.py +0 -0
  22. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/predictor.py +0 -0
  23. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/prior/__init__.py +0 -0
  24. {physbo-2.1.0 → physbo-2.2.0}/physbo/blm/prior/gauss.py +0 -0
  25. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/learning.py +0 -0
  26. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/core/prior.py +0 -0
  27. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/__init__.py +0 -0
  28. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/_src/__init__.py +0 -0
  29. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/_src/enhance_gauss.pyx +0 -0
  30. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/cov/gauss.py +0 -0
  31. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/inf/__init__.py +0 -0
  32. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/inf/exact.py +0 -0
  33. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/lik/__init__.py +0 -0
  34. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/lik/gauss.py +0 -0
  35. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/__init__.py +0 -0
  36. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/const.py +0 -0
  37. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/mean/zero.py +0 -0
  38. {physbo-2.1.0 → physbo-2.2.0}/physbo/gp/predictor.py +0 -0
  39. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/__init__.py +0 -0
  40. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/__init__.py +0 -0
  41. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/cholupdate.pyx +0 -0
  42. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/diagAB.pyx +0 -0
  43. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/logsumexp.pyx +0 -0
  44. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/_src/traceAB.pyx +0 -0
  45. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/centering.py +0 -0
  46. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/gauss_elim.py +0 -0
  47. {physbo-2.1.0 → physbo-2.2.0}/physbo/misc/set_config.py +0 -0
  48. {physbo-2.1.0 → physbo-2.2.0}/physbo/opt/__init__.py +0 -0
  49. {physbo-2.1.0 → physbo-2.2.0}/physbo/opt/adam.py +0 -0
  50. {physbo-2.1.0 → physbo-2.2.0}/physbo/predictor.py +0 -0
  51. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/__init__.py +0 -0
  52. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/__init__.py +0 -0
  53. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/policy.py +0 -0
  54. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete/results.py +0 -0
  55. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/__init__.py +0 -0
  56. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/policy.py +0 -0
  57. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/discrete_multi/results.py +0 -0
  58. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/score.py +0 -0
  59. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/score_multi.py +0 -0
  60. {physbo-2.1.0 → physbo-2.2.0}/physbo/search/utility.py +0 -0
  61. {physbo-2.1.0 → physbo-2.2.0}/physbo/variable.py +0 -0
  62. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/SOURCES.txt +0 -0
  63. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/dependency_links.txt +0 -0
  64. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/not-zip-safe +0 -0
  65. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/requires.txt +0 -0
  66. {physbo-2.1.0 → physbo-2.2.0}/physbo.egg-info/top_level.txt +0 -0
  67. {physbo-2.1.0 → physbo-2.2.0}/pyproject.toml +0 -0
  68. {physbo-2.1.0 → physbo-2.2.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: physbo
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: optimization tool for PHYSics based on Bayesian Optimization
5
5
  Home-page: https://github.com/issp-center-dev/PHYSBO
6
6
  Author: PHYSBO developers
@@ -14,4 +14,4 @@ from . import predictor
14
14
  from .predictor import base_predictor
15
15
  from .variable import variable
16
16
 
17
- __version__ = "2.1.0"
17
+ __version__ = "2.2.0"
@@ -11,5 +11,6 @@ from . import lik
11
11
 
12
12
  from .core import prior
13
13
  from .core import model
14
+ from .core import sfs
14
15
  from .core import learning
15
16
  from .predictor import predictor
@@ -7,5 +7,6 @@
7
7
 
8
8
  from .prior import prior
9
9
  from .model import model
10
+ from .model import sfs
10
11
 
11
12
  # from predictor import predictor
@@ -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([np.any(pf <= p) for pf in self.front])
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 when sorted on each dimension's front value in ascending order.
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
- elif self.__included_in_non_dom_region(ub):
191
- rect_sizes = rect[1] - rect[0]
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
- # divide rectangle by the dimension with largest size
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
- # add divided left rectangle
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
- # add divided right rectangle
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)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: physbo
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: optimization tool for PHYSics based on Bayesian Optimization
5
5
  Home-page: https://github.com/issp-center-dev/PHYSBO
6
6
  Author: PHYSBO developers
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = physbo
3
- version = 2.1.0
3
+ version = 2.2.0
4
4
  description = optimization tool for PHYSics based on Bayesian Optimization
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
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