root/PythonPackages/OpenOpt/openopt/examples/llsp_1.py

Revision 184, 509 bytes (checked in by dmitrey, 3 months ago)

minor change for LLSP example

Line  
1 __docformat__ = "restructuredtext en"
2
3 from numpy import empty, sin, cos, arange
4 from openopt import LLSP
5
6 M, N = 3, 2
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 # 611.600991401
23 #print 'x_opt:', r.xf
Note: See TracBrowser for help on using the browser.