Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6278a99
commit 6762968
Showing
2 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import print_function | ||
import numpy as np | ||
from scipy.spatial.distance import cdist | ||
|
||
import psdr | ||
|
||
def test_minimax_covering(m = 2): | ||
np.random.seed(0) | ||
|
||
dom = psdr.BoxDomain(-np.ones(m), np.ones(m)) | ||
r = 0.5 | ||
|
||
X = psdr.minimax_covering(dom, r) | ||
X2 = dom.sample(1e5) | ||
D = cdist(X, X2) | ||
min_dist = np.max(np.min(cdist(X, X2), axis = 0)) | ||
print("minimum distance %5.2e; target %5.2e" % (min_dist, r)) | ||
assert min_dist < r, "Sampling did not meet target separation" | ||
|
||
if __name__ == '__main__': | ||
test_minimax_covering() |