Changeset 1154
- Timestamp:
- 07/22/08 05:43:36 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/examples/oofun_input.py
r1152 r1154 7 7 c1(x) = c0(x)^2-1 <=0 8 8 c2(x) = c1(x)^2-1.5 <=0 9 c3(x) = c0(x) + 2*c2(x) + 1.5 <= 0 9 10 10 11 using openopt's oofun … … 20 21 df = lambda x: 2 * (x-arange(n)) 21 22 22 # parameter "name" is optional23 23 c0 = oofun(lambda x: x[-1] ** 2 + x[-2] ** 2 - 1, name = 'constraint 0') 24 24 c1 = oofun(lambda c: c**2 - 1, input = c0, name = 'constraint 1') 25 c2 = oofun(lambda c: c**2 - 1.5, input = c1, name = 'constraint 2') 25 c2 = oofun(lambda c: c**2 - 1.5, input = c1) # parameter "name" is optional 26 c3 = oofun(lambda y, z: y + 2*z + 1.5, input = [c0, c2], name = 'constraint 3') 26 27 27 p = NLP(f, x0, df=df, c=[c0, c1, c2], maxIter = 1e4, maxFunEvals = 1e10, iprint = 10) 28 c = [c2, c0, c1, c3] # ORDER: any 29 30 p = NLP(f, x0, df=df, c=c) 28 31 r = p.solve('ralg') 32 #Solver: Time Elapsed = 0.64 CPU Time Elapsed = 0.61 33 #objFunValue: 332.71635 (feasible, max constraint = 0)
