/usr/share/pyshared/openopt/solvers/Standalone/toms587_oo.py is in python-openopt 0.38+svn1589-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | from numpy.linalg import norm
from numpy import dot, asfarray, atleast_1d, zeros, ones, int, float128, float64, where, inf, hstack, vstack, array, ravel
from openopt.kernel.baseSolver import baseSolver
from toms587 import lsei
from openopt.kernel.ooMisc import xBounds2Matrix
f = lambda x: norm(dot(p.C, x) - p.d)
class toms587(baseSolver):
__name__ = 'toms587'
__license__ = "BSD"
__authors__ = 'R. J. HANSON AND K. H. HASKELL'
#__alg__ = ''
__info__ = 'requires manual compilation of toms_587.f by f2py, see OO online doc for details'
#__optionalDataThatCanBeHandled__ = ['A', 'Aeq', 'b', 'beq', 'lb', 'ub']
T = float64
def __init__(self): pass
def __solver__(self, p):
xBounds2Matrix(p)
T = self.T
n = p.n
#xf = zeros(n, T)
xf = zeros(1, T)
A, B = T(p.C), T(p.d).reshape(-1, 1)
G, H = T(p.A), T(p.b).reshape(-1, 1)
E, F = T(p.Aeq), T(p.beq).reshape(-1, 1)
me, ma, mg = F.size, B.size, H.size
#mdw = me + ma + mg
prgopt = ravel(1.0)
w = vstack((hstack((E, F)), hstack((A, B)), hstack((G, H))))
mode = -15
rnorme, rnorml = -15.0, -15.0
ip = array((-15, -15, -15))
ws = ravel(-15.0)
#bl, bu = p.lb.copy(), p.ub.copy()
# bl[where(bl==-inf)[0]] = -self.BVLS_inf
# bu[where(bu==inf)[0]] = self.BVLS_inf
# if hasattr(bvls, 'boundedleastsquares'):#f90 version
# p.debugmsg('using BVLS.f90')
# xf,loopa = bvls.boundedleastsquares.bvls(key,a,b,bl,bu,istate)
# else:
# p.debugmsg('using BVLS.f')
# bvls.bvls(key, a, b, bl, bu, xf, w, act, zz, istate, loopa)
#lsei(w,me,ma,mg,n,prgopt,xf,rnorme,rnorml,mode,ws,ip,[mdw])
#print w.flatten()
lsei(w.flatten(),me,ma,mg,n,prgopt,xf,rnorme,rnorml,mode,ws,ip)
#p.iter = loopa
ff = atleast_1d(asfarray(f(xf)))
p.xf = p.xk = xf
p.ff = p.fk = ff
p.istop = 1000
|