physbo 2.0.2__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.0.2 → physbo-2.2.0}/PKG-INFO +2 -2
  2. {physbo-2.0.2 → physbo-2.2.0}/physbo/__init__.py +1 -1
  3. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/core/model.py +3 -1
  4. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/inf/exact.py +2 -0
  5. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/predictor.py +8 -3
  6. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/__init__.py +1 -0
  7. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/core/__init__.py +1 -0
  8. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/core/model.py +84 -4
  9. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/core/prior.py +5 -2
  10. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/cov/gauss.py +3 -1
  11. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/inf/exact.py +4 -1
  12. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/predictor.py +4 -1
  13. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete/policy.py +35 -5
  14. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete_multi/policy.py +41 -3
  15. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/pareto.py +40 -19
  16. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/PKG-INFO +2 -2
  17. {physbo-2.0.2 → physbo-2.2.0}/setup.cfg +1 -1
  18. {physbo-2.0.2 → physbo-2.2.0}/README.md +0 -0
  19. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/__init__.py +0 -0
  20. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/basis/__init__.py +0 -0
  21. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/basis/fourier.py +0 -0
  22. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/core/__init__.py +0 -0
  23. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/inf/__init__.py +0 -0
  24. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/lik/__init__.py +0 -0
  25. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/lik/_src/__init__.py +0 -0
  26. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/lik/_src/cov.py +0 -0
  27. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/lik/gauss.py +0 -0
  28. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/lik/linear.py +0 -0
  29. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/prior/__init__.py +0 -0
  30. {physbo-2.0.2 → physbo-2.2.0}/physbo/blm/prior/gauss.py +0 -0
  31. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/core/learning.py +0 -0
  32. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/cov/__init__.py +0 -0
  33. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/cov/_src/__init__.py +0 -0
  34. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/cov/_src/enhance_gauss.pyx +0 -0
  35. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/inf/__init__.py +0 -0
  36. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/lik/__init__.py +0 -0
  37. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/lik/gauss.py +0 -0
  38. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/mean/__init__.py +0 -0
  39. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/mean/const.py +0 -0
  40. {physbo-2.0.2 → physbo-2.2.0}/physbo/gp/mean/zero.py +0 -0
  41. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/__init__.py +0 -0
  42. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/_src/__init__.py +0 -0
  43. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/_src/cholupdate.pyx +0 -0
  44. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/_src/diagAB.pyx +0 -0
  45. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/_src/logsumexp.pyx +0 -0
  46. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/_src/traceAB.pyx +0 -0
  47. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/centering.py +0 -0
  48. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/gauss_elim.py +0 -0
  49. {physbo-2.0.2 → physbo-2.2.0}/physbo/misc/set_config.py +0 -0
  50. {physbo-2.0.2 → physbo-2.2.0}/physbo/opt/__init__.py +0 -0
  51. {physbo-2.0.2 → physbo-2.2.0}/physbo/opt/adam.py +0 -0
  52. {physbo-2.0.2 → physbo-2.2.0}/physbo/predictor.py +0 -0
  53. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/__init__.py +0 -0
  54. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete/__init__.py +0 -0
  55. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete/results.py +0 -0
  56. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete_multi/__init__.py +0 -0
  57. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/discrete_multi/results.py +0 -0
  58. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/score.py +0 -0
  59. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/score_multi.py +0 -0
  60. {physbo-2.0.2 → physbo-2.2.0}/physbo/search/utility.py +0 -0
  61. {physbo-2.0.2 → physbo-2.2.0}/physbo/variable.py +0 -0
  62. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/SOURCES.txt +0 -0
  63. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/dependency_links.txt +0 -0
  64. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/not-zip-safe +0 -0
  65. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/requires.txt +0 -0
  66. {physbo-2.0.2 → physbo-2.2.0}/physbo.egg-info/top_level.txt +0 -0
  67. {physbo-2.0.2 → physbo-2.2.0}/pyproject.toml +0 -0
  68. {physbo-2.0.2 → physbo-2.2.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: physbo
3
- Version: 2.0.2
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.0.2"
17
+ __version__ = "2.2.0"
@@ -218,13 +218,15 @@ class model:
218
218
  Returns
219
219
  =======
220
220
  numpy.ndarray
221
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
222
+ where num_points is the number of points in X.
221
223
 
222
224
  See also
223
225
  ========
224
226
  physbo.blm.inf.exact.get_post_fcov
225
227
  """
226
228
  if self.method == "exact":
227
- fcov = inf.exact.get_post_fcov(self, X, Psi, diag=True)
229
+ fcov = inf.exact.get_post_fcov(self, X, Psi, diag=diag)
228
230
  else:
229
231
  pass
230
232
  return fcov
@@ -170,6 +170,8 @@ def get_post_fcov(blm, X, Psi=None, diag=True):
170
170
  Returns
171
171
  =======
172
172
  numpy.ndarray
173
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
174
+ where num_points is the number of points in X.
173
175
  """
174
176
  if Psi is None:
175
177
  Psi = blm.lik.linear.basis.get_basis(X)
@@ -101,12 +101,14 @@ class predictor(physbo.predictor.base_predictor):
101
101
  Returns
102
102
  =======
103
103
  numpy.ndarray
104
+ Returned shape is (num_points),
105
+ where num_points is the number of points in test.
104
106
  """
105
107
  if self.blm.stats is None:
106
108
  self.prepare(training)
107
109
  return self.blm.get_post_fmean(test.X, test.Z)
108
110
 
109
- def get_post_fcov(self, training, test):
111
+ def get_post_fcov(self, training, test, diag=True):
110
112
  """
111
113
  calculates posterior variance-covariance matrix of model
112
114
 
@@ -116,14 +118,17 @@ class predictor(physbo.predictor.base_predictor):
116
118
  training dataset. If already trained, the model does not use this.
117
119
  test: physbo.variable
118
120
  inputs
119
-
121
+ diag: bool
122
+ If true, only variances (diagonal elements) are returned.
120
123
  Returns
121
124
  =======
122
125
  numpy.ndarray
126
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
127
+ where num_points is the number of points in test.
123
128
  """
124
129
  if self.blm.stats is None:
125
130
  self.prepare(training)
126
- return self.blm.get_post_fcov(test.X, test.Z)
131
+ return self.blm.get_post_fcov(test.X, test.Z, diag)
127
132
 
128
133
  def get_post_params(self, training, test):
129
134
  """
@@ -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"):
@@ -269,11 +269,13 @@ class model:
269
269
  params: numpy.ndarray
270
270
  Parameters
271
271
  diag: bool
272
- If X is the diagonalization matrix, true.
272
+ If true, only variances (diagonal elements) are returned.
273
273
 
274
274
  Returns
275
275
  -------
276
- physbo.gp.inf.exact.get_post_fcov
276
+ numpy.ndarray
277
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
278
+ where num_points is the number of points in X.
277
279
 
278
280
  """
279
281
  if params is None:
@@ -308,7 +310,7 @@ class model:
308
310
 
309
311
  fmean = self.get_post_fmean(X, Z, params=None)
310
312
  fcov = self.get_post_fcov(X, Z, params=None, diag=False)
311
- return np.random.multivariate_normal(fmean, fcov * alpha**2, N)
313
+ return np.random.multivariate_normal(fmean, fcov * alpha ** 2, N)
312
314
 
313
315
  def predict_sampling(self, X, Z, params=None, N=1):
314
316
  """
@@ -418,3 +420,81 @@ class model:
418
420
  params = bfgs.run(X, t)
419
421
 
420
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}
@@ -19,7 +19,7 @@ class prior:
19
19
  ----------
20
20
  mean: numpy.ndarray
21
21
  mean values of prior
22
- cov: numpy.ndarray
22
+ cov: physbo.gp.cov.gauss
23
23
  covariance matrix of priors
24
24
  """
25
25
  self.mean = mean
@@ -94,10 +94,13 @@ class prior:
94
94
  params: numpy.ndarray
95
95
  Parameters.
96
96
  diag: bool
97
- If X is the diagonalization matrix, true.
97
+ If true, only variances (diagonal elements) are returned.
98
+
98
99
  Returns
99
100
  -------
100
101
  numpy.ndarray
102
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
103
+ where num_points is the number of points in X.
101
104
  """
102
105
  if params is None:
103
106
  params = np.copy(self.params)
@@ -149,12 +149,14 @@ class gauss:
149
149
  Parameters
150
150
 
151
151
  diag: bool
152
- If X is the diagonalization matrix, true.
152
+ If true, only variances (diagonal elements) are returned.
153
153
 
154
154
  Returns
155
155
  -------
156
156
  G: numpy.ndarray
157
157
  covariant matrix
158
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
159
+ where num_points is the number of points in X.
158
160
  """
159
161
  params, width, scale = self.prepare(params)
160
162
  scale2 = scale**2
@@ -203,10 +203,13 @@ def get_post_fcov(gp, X, Z, params=None, diag=True):
203
203
  params: numpy.ndarray
204
204
  Parameters.
205
205
  diag: bool
206
- If X is the diagonalization matrix, true.
206
+ If true, only variances (diagonal elements) are returned.
207
+
207
208
  Returns
208
209
  -------
209
210
  numpy.ndarray
211
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
212
+ where num_points is the number of points in X.
210
213
  """
211
214
 
212
215
  lik_params, prior_params = gp.decomp_params(params)
@@ -115,10 +115,13 @@ class predictor(physbo.predictor.base_predictor):
115
115
  test: physbo.variable
116
116
  inputs
117
117
  diag: bool
118
- Diagonlization flag in physbo.exact.get_post_fcov function.
118
+ If true, only variances (diagonal elements) are returned.
119
+
119
120
  Returns
120
121
  -------
121
122
  numpy.ndarray
123
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
124
+ where num_points is the number of points in test.
122
125
 
123
126
  """
124
127
  if self.model.stats is None:
@@ -348,7 +348,21 @@ class policy:
348
348
  print(" before calling {}.".format(method_name))
349
349
 
350
350
  def get_post_fmean(self, xs):
351
- """Calculate mean value of predictor (post distribution)"""
351
+ """
352
+ Calculate mean value of predictor (post distribution)
353
+
354
+ Parameters
355
+ ----------
356
+ xs: physbo.variable or np.ndarray
357
+ input parameters to calculate mean value
358
+ shape is (num_points, num_parameters)
359
+
360
+ Returns
361
+ -------
362
+ fmean: numpy.ndarray
363
+ Mean value of the post distribution.
364
+ Returned shape is (num_points).
365
+ """
352
366
  X = self._make_variable_X(xs)
353
367
  if self.predictor is None:
354
368
  self._warn_no_predictor("get_post_fmean()")
@@ -360,18 +374,34 @@ class policy:
360
374
  self._update_predictor()
361
375
  return self.predictor.get_post_fmean(self.training, X)
362
376
 
363
- def get_post_fcov(self, xs):
364
- """Calculate covariance of predictor (post distribution)"""
377
+ def get_post_fcov(self, xs, diag=True):
378
+ """
379
+ Calculate covariance of predictor (post distribution)
380
+
381
+ Parameters
382
+ ----------
383
+ xs: physbo.variable or np.ndarray
384
+ input parameters to calculate covariance
385
+ shape is (num_points, num_parameters)
386
+ diag: bool
387
+ If true, only variances (diagonal elements) are returned.
388
+
389
+ Returns
390
+ -------
391
+ fcov: numpy.ndarray
392
+ Covariance matrix of the post distribution.
393
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false.
394
+ """
365
395
  X = self._make_variable_X(xs)
366
396
  if self.predictor is None:
367
397
  self._warn_no_predictor("get_post_fcov()")
368
398
  predictor = gp_predictor(self.config)
369
399
  predictor.fit(self.training, 0)
370
400
  predictor.prepare(self.training)
371
- return predictor.get_post_fcov(self.training, X)
401
+ return predictor.get_post_fcov(self.training, X, diag)
372
402
  else:
373
403
  self._update_predictor()
374
- return self.predictor.get_post_fcov(self.training, X)
404
+ return self.predictor.get_post_fcov(self.training, X, diag)
375
405
 
376
406
  def get_score(
377
407
  self,
@@ -294,6 +294,23 @@ class policy(discrete.policy):
294
294
  return np.array(chosen_actions)
295
295
 
296
296
  def get_post_fmean(self, xs):
297
+ """
298
+ Calculate mean value of predictors (post distribution)
299
+
300
+ Parameters
301
+ ----------
302
+ xs: physbo.variable or np.ndarray
303
+ input parameters to calculate covariance
304
+ shape is (num_points, num_parameters)
305
+ diag: bool
306
+ If true, only variances (diagonal elements) are returned.
307
+
308
+ Returns
309
+ -------
310
+ fcov: numpy.ndarray
311
+ Covariance matrix of the post distribution.
312
+ Returned shape is (num_points, num_objectives).
313
+ """
297
314
  if self.predictor_list == [None] * self.num_objectives:
298
315
  self._warn_no_predictor("get_post_fmean()")
299
316
  predictor_list = []
@@ -312,7 +329,24 @@ class policy(discrete.policy):
312
329
  ]
313
330
  return np.array(fmean).T
314
331
 
315
- def get_post_fcov(self, xs):
332
+ def get_post_fcov(self, xs, diag=True):
333
+ """
334
+ Calculate covariance of predictors (post distribution)
335
+
336
+ Parameters
337
+ ----------
338
+ xs: physbo.variable or np.ndarray
339
+ input parameters to calculate covariance
340
+ shape is (num_points, num_parameters)
341
+ diag: bool
342
+ If true, only variances (diagonal elements) are returned.
343
+
344
+ Returns
345
+ -------
346
+ fcov: numpy.ndarray
347
+ Covariance matrix of the post distribution.
348
+ Returned shape is (num_points, num_objectives) if diag=true, (num_points, num_points, num_objectives) if diag=false.
349
+ """
316
350
  if self.predictor_list == [None] * self.num_objectives:
317
351
  self._warn_no_predictor("get_post_fcov()")
318
352
  predictor_list = []
@@ -326,10 +360,14 @@ class policy(discrete.policy):
326
360
  predictor_list = self.predictor_list[:]
327
361
  X = self._make_variable_X(xs)
328
362
  fcov = [
329
- predictor.get_post_fcov(training, X)
363
+ predictor.get_post_fcov(training, X, diag)
330
364
  for predictor, training in zip(predictor_list, self.training_list)
331
365
  ]
332
- return np.array(fcov).T
366
+ arr = np.array(fcov)
367
+ if diag:
368
+ return arr.T
369
+ else:
370
+ return np.einsum("nij->ijn", arr)
333
371
 
334
372
  def get_score(
335
373
  self,
@@ -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.1
1
+ Metadata-Version: 2.4
2
2
  Name: physbo
3
- Version: 2.0.2
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.0.2
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