- Timestamp:
- 12/05/12 09:42:48 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/test_penalty.py
r602 r604 13 13 @quadratic_equality(condition=range_constraint, kwds={'target':5.0}) 14 14 @quadratic_equality(condition=mean_constraint, kwds={'target':5.0}) 15 def cost(x): #XXX: def penalty(x): return x 16 return abs(sum(x) - 5.0) #XXX: # ...then give penalty to solver 15 def penalty(x): 16 return 0.0 17 18 def cost(x): 19 return abs(sum(x) - 5.0) 17 20 18 21 from mystic.solvers import fmin_powell 19 22 from numpy import array 20 23 x = array([1,2,3,4,5]) 21 y = fmin_powell(cost, x, disp=False)24 y = fmin_powell(cost, x, penalty=penalty, disp=False) 22 25 23 26 assert round(mean(y)) == 5.0 -
branches/decorate/test_wrapper.py
r603 r604 261 261 return impose_spread(spread, x) 262 262 263 @nested(inner=range_constraint, kwds={'spread':5.0}) #XXX: @with_range(5.0)264 @nested(inner=mean_constraint, kwds={'mean':5.0}) #XXX: @with_mean(5.0)263 @nested(inner=range_constraint, kwds={'spread':5.0}) 264 @nested(inner=mean_constraint, kwds={'mean':5.0}) 265 265 def constraints(x): 266 266 return x
Note: See TracChangeset
for help on using the changeset viewer.