Changeset 854


Ignore:
Timestamp:
12/31/15 05:13:28 (5 months ago)
Author:
mmckerns
Message:

minor tweaks; renamed penalize coupler to additive, renamed combine to combined

Location:
mystic
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • mystic/examples2/g01_alt2.py

    r853 r854  
    1919                    penalty6, penalty7, penalty8, penalty9 
    2020 
    21 from mystic.constraints import as_constraint, combine 
     21from mystic.constraints import as_constraint, combined 
    2222from mystic.penalty import linear_inequality 
    2323 
     
    2525             penalty6,penalty7,penalty8,penalty9) 
    2626 
    27 penalty = combine(*[linear_inequality(pi)(lambda x:0.) for pi in penalties]) 
     27penalty = combined(*[linear_inequality(pi)(lambda x:0.) for pi in penalties]) 
    2828solver = as_constraint(penalty) 
    2929 
  • mystic/mystic/constraints.py

    r853 r854  
    1212           'with_mean','with_variance','with_std','with_spread','normalized', 
    1313           'issolution','solve','discrete','integers','near_integers', 
    14            'unique','has_unique','impose_unique', 'combine'] 
     14           'unique','has_unique','impose_unique', 'combined'] 
    1515 
    1616from mystic.math.measures import * 
     
    428428 
    429429 
    430 def combine(*penalties, **settings): #XXX: is this in the right module? 
     430def combined(*penalties, **settings): #XXX: is this in the right module? 
    431431    """combine several penalties into a single penalty function 
    432432 
  • mystic/mystic/coupler.py

    r776 r854  
    116116 
    117117#################################################### 
    118 def penalize_proxy(penalty=lambda x:0.0, args=None, kwds=None): 
     118def additive_proxy(penalty=lambda x:0.0, args=None, kwds=None): 
    119119    """penalize a function with another function: y = f(x) to y' = f(x) + p(x) 
    120120     
     
    134134    return dec 
    135135 
    136 def penalize(penalty=lambda x:0.0, args=None, kwds=None): 
     136def additive(penalty=lambda x:0.0, args=None, kwds=None): 
    137137    """penalize a function with another function: y = f(x) to y' = f(x) + p(x) 
    138138     
     
    146146    ...  
    147147    >>> # equivalent to: (x+1) + (x**2)  
    148     >>> @penalize(squared) 
     148    >>> @additive(squared) 
    149149    ... def constrain(x): 
    150150    ...   return x+1 
     
    163163    return dec 
    164164 
    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,..? 
    166166#XXX: create a counter for n += 1 ? 
    167167 
  • mystic/tests/test_combined.py

    r853 r854  
    33''' 
    44 
    5 from mystic.constraints import combine 
     5from mystic.constraints import combined 
    66  
    77 
     
    2828    p = (p1,p2,p3) 
    2929    p = [ptype(pi)(lambda x:0.) for pi in p] 
    30     penalty = combine(*p, k=k) 
     30    penalty = combined(*p, k=k) 
    3131    constraint = as_constraint(penalty, solver=solver) 
    3232 
     
    5959 
    6060    p = [as_penalty(ci, ptype) for ci in c] 
    61     penalty = combine(*p, k=k) 
     61    penalty = combined(*p, k=k) 
    6262    constraint = as_constraint(penalty, solver=solver) 
    6363 
Note: See TracChangeset for help on using the changeset viewer.