Changeset 604 for branches


Ignore:
Timestamp:
12/05/12 09:42:48 (3 years ago)
Author:
mmckerns
Message:

added SetPenalty? method for penalty functions, and penalty kwd for one-liners;
added wrap_penalty method to tools; use penalty kwd in decorate/test_penalty

Location:
branches/decorate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/decorate/test_penalty.py

    r602 r604  
    1313  @quadratic_equality(condition=range_constraint, kwds={'target':5.0}) 
    1414  @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) 
    1720 
    1821  from mystic.solvers import fmin_powell 
    1922  from numpy import array 
    2023  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) 
    2225 
    2326  assert round(mean(y)) == 5.0 
  • branches/decorate/test_wrapper.py

    r603 r604  
    261261    return impose_spread(spread, x) 
    262262 
    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}) 
    265265  def constraints(x): 
    266266    return x 
Note: See TracChangeset for help on using the changeset viewer.