root/trunk/openopt/scikits/openopt/examples/llsp_1.py
| Revision 1281, 0.5 kB (checked in by dmitrey.kroshko, 3 months ago) |
|---|
| Line | |
|---|---|
| 1 | __docformat__ = "restructuredtext en" |
| 2 | |
| 3 | from numpy import empty, sin, cos, arange |
| 4 | from scikits.openopt import LLSP |
| 5 | |
| 6 | M, N = 1000, 100 |
| 7 | C = empty((M,N)) |
| 8 | d = empty(M) |
| 9 | |
| 10 | for j in xrange(M): |
| 11 | d[j] = 1.5*N+80*sin(j) |
| 12 | C[j] = 8*sin(4.0+arange(N)) + 15*cos(j) |
| 13 | |
| 14 | p = LLSP(C, d) |
| 15 | r = p.solve('lapack_dgelss') #requires scipy installed |
| 16 | # or using single-precision: |
| 17 | #r = p.solve('lapack_sgelss') |
| 18 | |
| 19 | #using llsp2nlp converter with an NLP solver: |
| 20 | #r = p.solve('nlp:scipy_cg') |
| 21 | |
| 22 | print 'f_opt:', r.ff # 1601171.51977 |
| 23 | #print 'x_opt:', r.xf |
Note: See TracBrowser for help on using the browser.
