Changeset 854
- Timestamp:
- 12/31/15 05:13:28 (5 months ago)
- Location:
- mystic
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
mystic/examples2/g01_alt2.py
r853 r854 19 19 penalty6, penalty7, penalty8, penalty9 20 20 21 from mystic.constraints import as_constraint, combine 21 from mystic.constraints import as_constraint, combined 22 22 from mystic.penalty import linear_inequality 23 23 … … 25 25 penalty6,penalty7,penalty8,penalty9) 26 26 27 penalty = combine (*[linear_inequality(pi)(lambda x:0.) for pi in penalties])27 penalty = combined(*[linear_inequality(pi)(lambda x:0.) for pi in penalties]) 28 28 solver = as_constraint(penalty) 29 29 -
mystic/mystic/constraints.py
r853 r854 12 12 'with_mean','with_variance','with_std','with_spread','normalized', 13 13 'issolution','solve','discrete','integers','near_integers', 14 'unique','has_unique','impose_unique', 'combine ']14 'unique','has_unique','impose_unique', 'combined'] 15 15 16 16 from mystic.math.measures import * … … 428 428 429 429 430 def combine (*penalties, **settings): #XXX: is this in the right module?430 def combined(*penalties, **settings): #XXX: is this in the right module? 431 431 """combine several penalties into a single penalty function 432 432 -
mystic/mystic/coupler.py
r776 r854 116 116 117 117 #################################################### 118 def penalize_proxy(penalty=lambda x:0.0, args=None, kwds=None):118 def additive_proxy(penalty=lambda x:0.0, args=None, kwds=None): 119 119 """penalize a function with another function: y = f(x) to y' = f(x) + p(x) 120 120 … … 134 134 return dec 135 135 136 def penalize(penalty=lambda x:0.0, args=None, kwds=None):136 def additive(penalty=lambda x:0.0, args=None, kwds=None): 137 137 """penalize a function with another function: y = f(x) to y' = f(x) + p(x) 138 138 … … 146 146 ... 147 147 >>> # equivalent to: (x+1) + (x**2) 148 >>> @ penalize(squared)148 >>> @additive(squared) 149 149 ... def constrain(x): 150 150 ... return x+1 … … 163 163 return dec 164 164 165 #XXX: can do multiple @ penalize; but better is compound penalty with And,Or,..?165 #XXX: can do multiple @additive; but better is compound penalty with And,Or,..? 166 166 #XXX: create a counter for n += 1 ? 167 167 -
mystic/tests/test_combined.py
r853 r854 3 3 ''' 4 4 5 from mystic.constraints import combine 5 from mystic.constraints import combined 6 6 7 7 … … 28 28 p = (p1,p2,p3) 29 29 p = [ptype(pi)(lambda x:0.) for pi in p] 30 penalty = combine (*p, k=k)30 penalty = combined(*p, k=k) 31 31 constraint = as_constraint(penalty, solver=solver) 32 32 … … 59 59 60 60 p = [as_penalty(ci, ptype) for ci in c] 61 penalty = combine (*p, k=k)61 penalty = combined(*p, k=k) 62 62 constraint = as_constraint(penalty, solver=solver) 63 63
Note: See TracChangeset
for help on using the changeset viewer.