root/trunk/openopt/scikits/openopt/examples/llsp_2.py

Revision 1300, 0.9 KB (checked in by dmitrey.kroshko, 18 months ago)

minor bugfix + changes in examples/llsp2.py

Line 
1__docformat__ = "restructuredtext en"
2
3from numpy import diag,  ones, sin, cos, arange, sqrt, vstack, zeros, dot
4from scikits.openopt import LLSP, NLP
5
6N = 150
7C1 = diag(sqrt(arange(N)))
8C2 = (1.5+arange(N)).reshape(1, -1) * (0.8+arange(N)).reshape(-1, 1)
9C = vstack((C1, C2))
10d = arange(2*N)
11lb = -2.0+sin(arange(N))
12ub = 5+cos(arange(N))
13
14############################LLSP################################
15LLSPsolver = 'bvls'
16p = LLSP(C, d, lb=lb, ub=ub)
17r = p.solve(LLSPsolver)
18#############################NLP################################
19NLPsolver = 'scipy_lbfgsb'# you could try scipy_tnc or ralg as well
20#NLPsolver = 'scipy_tnc'
21p2 = LLSP(C, d, lb=lb, ub=ub)
22r2=p2.solve('nlp:'+NLPsolver)
23##################################################################
24print '###########Results:###########'
25print 'LLSP solver '+ LLSPsolver + ':', r.ff
26print 'NLP solver '+ NLPsolver + ':', r2.ff
Note: See TracBrowser for help on using the browser.