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

Revision 1546, 1.0 KB (checked in by dmitrey.kroshko, 16 months ago)

update for GUI example

Line 
1"""
2OpenOpt GUI:
3     function manage() usage example
4"""
5
6from scikits.openopt import NLP, manage
7from numpy import cos, arange, ones, asarray, abs, zeros
8N = 100
9M = 5
10p = NLP(lambda x: ((x-M)**2).sum(), cos(arange(N)))
11p.lb, p.ub = -6*ones(p.n), 6*ones(p.n)
12p.lb[3] = 5.5
13p.ub[4] = 4.5
14p.c = lambda x: [2* x[0] **4-32, x[1]**2+x[2]**2 - 8]
15p.h = (lambda x: 1e1*(x[-1]-1)**4, lambda x: (x[-2]-1.5)**4)
16
17"""
18minTime is used here
19for to provide enough time for user
20to play with GUI
21"""
22
23minTime = 15 # sec
24p.name = 'GUI_example'
25p.minTime = minTime
26
27"""
28hence maxIter, maxFunEvals etc
29will not trigger till minTime
30
31only same iter point x_k-1=x_k
32or some coords = nan
33can stop calculations
34
35other antistop criteria: minFunEvals, minIter, minCPUTime
36however, some solvers cannot handle them
37 """
38
39# start=True means don't wait for user to press "Run"
40r = manage(p,'ralg', plot=1, start=True)
41"""
42   or calling manage() as filed of p:
43r = p.manage('algencan', plot=1)
44"""
45if r is not None:
46    # r is None if user has pressed "Exit" button
47    print 'objfunc val:', r.ff
48
Note: See TracBrowser for help on using the browser.