DFO-LS 1.2.1__py3-none-any.whl → 1.4.1__py3-none-any.whl

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.

Potentially problematic release.


This version of DFO-LS might be problematic. Click here for more details.

dfols/util.py CHANGED
@@ -27,11 +27,14 @@ from __future__ import absolute_import, division, print_function, unicode_litera
27
27
 
28
28
  import logging
29
29
  import numpy as np
30
+ import scipy.linalg as LA
30
31
  import sys
31
32
 
32
33
 
33
34
  __all__ = ['sumsq', 'eval_least_squares_objective', 'model_value', 'random_orthog_directions_within_bounds',
34
- 'random_directions_within_bounds', 'apply_scaling', 'remove_scaling']
35
+ 'random_directions_within_bounds', 'apply_scaling', 'remove_scaling', 'pbox', 'pball', 'dykstra', 'qr_rank']
36
+
37
+ module_logger = logging.getLogger(__name__)
35
38
 
36
39
 
37
40
  def sumsq(x):
@@ -61,9 +64,9 @@ def eval_least_squares_objective(objfun, x, args=(), verbose=True, eval_num=0, p
61
64
 
62
65
  if verbose:
63
66
  if len(x) < full_x_thresh:
64
- logging.info("Function eval %i at point %i has f = %.15g at x = " % (eval_num, pt_num, f) + str(x))
67
+ module_logger.info("Function eval %i at point %i has f = %.15g at x = " % (eval_num, pt_num, f) + str(x))
65
68
  else:
66
- logging.info("Function eval %i at point %i has f = %.15g at x = [...]" % (eval_num, pt_num, f))
69
+ module_logger.info("Function eval %i at point %i has f = %.15g at x = [...]" % (eval_num, pt_num, f))
67
70
 
68
71
  return fvec, f
69
72
 
@@ -207,3 +210,50 @@ def remove_scaling(x_scaled, scaling_changes):
207
210
  shift, scale = scaling_changes
208
211
  return shift + x_scaled * scale
209
212
 
213
+
214
+ def dykstra(P,x0,max_iter=100,tol=1e-10):
215
+ x = x0.copy()
216
+ p = len(P)
217
+ y = np.zeros((p,x0.shape[0]))
218
+
219
+ n = 0
220
+ cI = float('inf')
221
+ while n < max_iter and cI >= tol:
222
+ cI = 0
223
+ for i in range(0,p):
224
+ # Update iterate
225
+ prev_x = x.copy()
226
+ x = P[i](prev_x - y[i,:])
227
+
228
+ # Update increment
229
+ prev_y = y[i,:].copy()
230
+ y[i,:] = x - (prev_x - prev_y)
231
+
232
+ # Stop condition
233
+ cI += np.linalg.norm(prev_y - y[i,:])**2
234
+
235
+ n += 1
236
+
237
+ return x
238
+
239
+
240
+ def pball(x,c,r):
241
+ return c + (r/np.max([np.linalg.norm(x-c),r]))*(x-c)
242
+
243
+
244
+ def pbox(x,l,u):
245
+ return np.minimum(np.maximum(x,l), u)
246
+
247
+ '''
248
+ Calculates rank of square matrix with QR.
249
+ We use the fact that the rank of a square matrix A
250
+ can be given by the number of nonzero diagonal elements of
251
+ R in the QR factorization of A.
252
+ '''
253
+ def qr_rank(A,tol=1e-15):
254
+ m,n = A.shape
255
+ assert m == n, "Input matrix must be square"
256
+ Q,R = LA.qr(A)
257
+ D = np.abs(np.diag(R))
258
+ rank = np.sum(D > tol)
259
+ return rank, D
@@ -1,16 +0,0 @@
1
- dfols/__init__.py,sha256=WdWULFDmitwdbZ3JEcrbkb5DjXr0ZM6efAqSe-iPsr8,1620
2
- dfols/controller.py,sha256=7puR1_zuu47Vr-xEhqubEJRzLv2Yja3X2O_WeDaDSV0,35652
3
- dfols/diagnostic_info.py,sha256=2kEUkL-MS4eDENUf1r2hOWsntP8OxMDKi_kyHmrC9V4,6081
4
- dfols/hessian.py,sha256=DKOm520rrFFaXVXu-BsD7aj2_ilJohxZ2tnMsnSa8zE,4265
5
- dfols/model.py,sha256=OHi-Y50OajpIauzfGcYPdCSrM8gvXYTGjb3NY7enk9s,18020
6
- dfols/params.py,sha256=1Mplj96q9anYa6d3PCkXgsxp-tc9fP4mNtQxwm7bveE,16749
7
- dfols/solver.py,sha256=RPUQpgPRkcUVMvc6tJ-0bYckg8EesMMeQ1meRJk3u_k,59180
8
- dfols/trust_region.py,sha256=75Z0z2d6ENh8t9t_e95IVwgNaWlZpyZF4rdkMJ54qhc,19152
9
- dfols/util.py,sha256=gpDa71PSFhFMqIJdmndnJ0vE25BiSulscRPS6MlIyaE,8667
10
- dfols/version.py,sha256=GQUgqQ6kgZyC6ohszFAofexRKp-dKwWY81bo7q2hlI8,926
11
- DFO_LS-1.2.1.dist-info/LICENSE.txt,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
12
- DFO_LS-1.2.1.dist-info/METADATA,sha256=nyESs24W-UXP0yYFZ8XX7YGOv39pIPKc8UAvRHrLfEc,7039
13
- DFO_LS-1.2.1.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
14
- DFO_LS-1.2.1.dist-info/top_level.txt,sha256=UfxRhaDN8HQx2_l17KbrDrERJ90OCN7VKkDMpYYbRLU,6
15
- DFO_LS-1.2.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
16
- DFO_LS-1.2.1.dist-info/RECORD,,
@@ -1 +0,0 @@
1
-
dfols/version.py DELETED
@@ -1,25 +0,0 @@
1
- """
2
- Version number
3
- ====
4
-
5
- This program is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation, either version 3 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program. If not, see <http://www.gnu.org/licenses/>.
17
-
18
- The development of this software was sponsored by NAG Ltd. (http://www.nag.co.uk)
19
- and the EPSRC Centre For Doctoral Training in Industrially Focused Mathematical
20
- Modelling (EP/L015803/1) at the University of Oxford. Please contact NAG for
21
- alternative licensing.
22
-
23
- """
24
-
25
- __version__ = '1.2.1'