Skip to content

Commit d45d868

Browse files
Merge branch 'master' into master
2 parents a2ab3cf + 0ed9f65 commit d45d868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+534
-533
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ python:
55
- "3.6"
66
- "3.7"
77
- "3.8"
8+
- "3.9"
89

910
install:
1011
- sudo apt-get install gfortran
1112
- pip install -r requirements.txt
13+
- pip install --upgrade numpy # some SciPy and pandas versions require newer NumPy
1214
- python setup.py build
1315

1416
script:
1517
- pip install nose
16-
- python setup.py test
18+
- nosetests -v

dfols/solver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def solve_main(objfun, x0, args, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_f
852852

853853
def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=None, nsamples=None, user_params=None,
854854
objfun_has_noise=False, scaling_within_bounds=False, do_logging=True, print_progress=False):
855-
x0 = x0.astype(np.float64)
855+
x0 = x0.astype(float)
856856
n = len(x0)
857857

858858
# Set missing inputs (if not specified) to some sensible defaults
@@ -861,8 +861,8 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8,
861861
xu = None
862862
else:
863863
assert len(bounds) == 2, "bounds must be a 2-tuple of (lower, upper), where both are arrays of size(x0)"
864-
xl = bounds[0].astype(np.float64) if bounds[0] is not None else None
865-
xu = bounds[1].astype(np.float64) if bounds[1] is not None else None
864+
xl = bounds[0].astype(float) if bounds[0] is not None else None
865+
xu = bounds[1].astype(float) if bounds[1] is not None else None
866866

867867
if (xl is None or xu is None) and scaling_within_bounds:
868868
scaling_within_bounds = False

dfols/tests/test_hessian.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class TestInitFromVector(unittest.TestCase):
4848
def runTest(self):
4949
n = 5
5050
nvals = n*(n+1)//2
51-
x = np.arange(nvals, dtype=np.float)
51+
x = np.arange(nvals, dtype=float)
5252
hess = Hessian(n, vals=x)
5353
self.assertEqual(hess.shape(), (nvals,), 'Wrong shape for initialisation')
5454
self.assertEqual(hess.dim(), n, 'Wrong dimension')
@@ -60,7 +60,7 @@ class TestInitFromMatrix(unittest.TestCase):
6060
def runTest(self):
6161
n = 3
6262
nvals = n*(n+1)//2
63-
A = np.arange(n**2, dtype=np.float).reshape((n,n))
63+
A = np.arange(n**2, dtype=float).reshape((n,n))
6464
hess = Hessian(n, vals=A+A.T) # force symmetric
6565
self.assertEqual(hess.shape(), (nvals,), 'Wrong shape for initialisation')
6666
self.assertEqual(hess.dim(), n, 'Wrong dimension')
@@ -72,7 +72,7 @@ def runTest(self):
7272
class TestToFull(unittest.TestCase):
7373
def runTest(self):
7474
n = 7
75-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
75+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
7676
H = A + A.T # force symmetric
7777
hess = Hessian(n, vals=H)
7878
self.assertTrue(np.all(hess.as_full() == H), 'Wrong values')
@@ -81,7 +81,7 @@ def runTest(self):
8181
class TestGetElementGood(unittest.TestCase):
8282
def runTest(self):
8383
n = 3
84-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
84+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
8585
H = A + A.T # force symmetric
8686
hess = Hessian(n, vals=H)
8787
for i in range(n):
@@ -93,7 +93,7 @@ def runTest(self):
9393
class TestGetElementBad(unittest.TestCase):
9494
def runTest(self):
9595
n = 4
96-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
96+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
9797
H = A + A.T # force symmetric
9898
hess = Hessian(n, vals=H)
9999
# When testing for assertion errors, need lambda to stop assertion from actually happening
@@ -114,7 +114,7 @@ def runTest(self):
114114
class TestSetElementGood(unittest.TestCase):
115115
def runTest(self):
116116
n = 3
117-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
117+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
118118
H = A + A.T # force symmetric
119119
hess = Hessian(n, vals=H)
120120
H2 = np.sin(H)
@@ -130,7 +130,7 @@ def runTest(self):
130130
class TestSetElementBad(unittest.TestCase):
131131
def runTest(self):
132132
n = 5
133-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
133+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
134134
H = A + A.T # force symmetric
135135
hess = Hessian(n, vals=H)
136136
# When testing for assertion errors, need lambda to stop assertion from actually happening
@@ -151,23 +151,23 @@ def runTest(self):
151151
class TestMultGood(unittest.TestCase):
152152
def runTest(self):
153153
n = 5
154-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
154+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
155155
H = np.sin(A + A.T) # force symmetric
156156
hess = Hessian(n, vals=H)
157-
vec = np.exp(np.arange(n, dtype=np.float))
157+
vec = np.exp(np.arange(n, dtype=float))
158158
hs = np.dot(H, vec)
159159
self.assertTrue(array_compare(hess*vec, hs, thresh=1e-12), 'Wrong values')
160160

161161

162162
class TestMultBad(unittest.TestCase):
163163
def runTest(self):
164164
n = 5
165-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
165+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
166166
H = A + A.T # force symmetric
167167
hess = Hessian(n, vals=H)
168168
# When testing for assertion errors, need lambda to stop assertion from actually happening
169169
self.assertRaises(AssertionError, lambda: hess * 1.0)
170170
self.assertRaises(AssertionError, lambda: hess * None)
171171
self.assertRaises(AssertionError, lambda: hess * [float(i) for i in range(n)])
172-
self.assertRaises(AssertionError, lambda: hess * np.arange(n-1, dtype=np.float))
173-
self.assertRaises(AssertionError, lambda: hess * np.arange(n+1, dtype=np.float))
172+
self.assertRaises(AssertionError, lambda: hess * np.arange(n-1, dtype=float))
173+
self.assertRaises(AssertionError, lambda: hess * np.arange(n+1, dtype=float))

dfols/tests/test_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,6 @@ def runTest(self):
168168
self.assertTrue(array_compare(soln.resid, objfun(soln.x), thresh=1e-10), "Wrong resid")
169169
print(soln.jacobian)
170170
print(jac(soln.x))
171-
self.assertTrue(array_compare(soln.jacobian, jac(soln.x), thresh=1e-2), "Wrong Jacobian")
171+
self.assertTrue(array_compare(soln.jacobian, jac(soln.x), thresh=1e-1), "Wrong Jacobian")
172172
self.assertTrue(abs(soln.f) < 1e-10, "Wrong fmin")
173173

dfols/tests/test_trust_region.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def runTest(self):
8989
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
9090
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
9191
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
92-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
92+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
9393
print(crvmin)
9494
self.assertAlmostEqual(crvmin, 1.2, 'Wrong crvmin')
9595

@@ -112,7 +112,7 @@ def runTest(self):
112112
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
113113
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
114114
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
115-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
115+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
116116
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
117117

118118

@@ -134,7 +134,7 @@ def runTest(self):
134134
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
135135
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
136136
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
137-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
137+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
138138
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
139139

140140

@@ -156,7 +156,7 @@ def runTest(self):
156156
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
157157
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
158158
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
159-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
159+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
160160
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
161161
# self.assertAlmostEqual(crvmin, crvmin_cauchy, 'Wrong crvmin')
162162

@@ -179,7 +179,7 @@ def runTest(self):
179179
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
180180
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
181181
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
182-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
182+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
183183
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
184184

185185

@@ -203,7 +203,7 @@ def runTest(self):
203203
# print(s_cauchy)
204204
# print(d)
205205
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
206-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
206+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
207207
print(crvmin)
208208
self.assertAlmostEqual(crvmin, -1.0, 'Wrong crvmin')
209209

dfols/tests/test_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def runTest(self):
5353
class TestModelValue(unittest.TestCase):
5454
def runTest(self):
5555
n = 5
56-
A = np.arange(n ** 2, dtype=np.float).reshape((n, n))
56+
A = np.arange(n ** 2, dtype=float).reshape((n, n))
5757
H = np.sin(A + A.T) # force symmetric
58-
vec = np.exp(np.arange(n, dtype=np.float))
59-
g = np.cos(3*np.arange(n, dtype=np.float) - 2.0)
58+
vec = np.exp(np.arange(n, dtype=float))
59+
g = np.cos(3*np.arange(n, dtype=float) - 2.0)
6060
mval = np.dot(g, vec) + 0.5 * np.dot(vec, np.dot(H, vec))
6161
self.assertAlmostEqual(mval, model_value(g, H, vec), msg='Wrong value')
6262

docs/advanced.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ References
107107
----------
108108

109109
.. [CFMR2018]
110-
C. Cartis, J. Fiala, B. Marteau and L. Roberts, `Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers <https://arxiv.org/abs/1804.00154>`_, technical report, University of Oxford, (2018).
110+
Coralia Cartis, Jan Fiala, Benjamin Marteau and Lindon Roberts, `Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers <https://doi.org/10.1145/3338517>`_, *ACM Transactions on Mathematical Software*, 45:3 (2019), pp. 32:1-32:41 [`preprint <https://arxiv.org/abs/1804.00154>`_]
111111

docs/build/doctrees/advanced.doctree

77 Bytes
Binary file not shown.
-149 Bytes
Binary file not shown.
167 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)