- Timestamp:
- 12/30/15 09:13:52 (5 months ago)
- Location:
- mystic
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/constraints.py
r852 r853 438 438 args -- arguments for the penalty function [default: ()] 439 439 kwds -- keyword arguments for the penalty function [default: {}] 440 k -- penalty multiplier 441 h -- iterative multiplier 440 k -- penalty multiplier [default: 1] 441 h -- iterative multiplier [default: 5] 442 443 NOTE: The defaults provide a linear combination of the individual penalties 444 without any scaling. A different ptype (from 'mystic.penalty') will 445 apply a nonlinear scaling to the combined penalty, while a different 446 k will apply a linear scaling. 442 447 443 448 NOTE: This function is also useful for combining constraints solvers … … 445 450 Constraints solvers must first be converted to penalty functions 446 451 (i.e. with 'as_penalty'), then combined, then can be converted to 447 a constraints solver (i.e. with `as_constraint'). The resulting452 a constraints solver (i.e. with 'as_constraint'). The resulting 448 453 constraints will likely be more expensive to evaluate and less 449 454 accurate than writing the constraints solver from scratch. … … 453 458 #if k is not None: settings['k'] = k 454 459 #if h is not None: settings['h'] = h 460 k = settings.setdefault('k', 1) 461 if k is None: del settings['k'] 455 462 ptype = settings.pop('ptype', None) 456 463 if ptype is None: -
mystic/tests/test_combine.py
r852 r853 27 27 p3 = lambda x: abs(x3 - f3(x)) 28 28 p = (p1,p2,p3) 29 # p = [ptype(pi)(lambda x:0.) for pi in p] 30 # ptype = None 31 penalty = combine(*p, k=k, ptype=ptype) 29 p = [ptype(pi)(lambda x:0.) for pi in p] 30 penalty = combine(*p, k=k) 32 31 constraint = as_constraint(penalty, solver=solver) 33 32 … … 55 54 c = (c1,c2,c3) 56 55 56 k=1 57 57 solver = 'buckshot' #'diffev' 58 58 ptype = linear_equality #quadratic_equality 59 59 60 60 p = [as_penalty(ci, ptype) for ci in c] 61 penalty = combine(*p, k= 1, ptype=linear_equality)61 penalty = combine(*p, k=k) 62 62 constraint = as_constraint(penalty, solver=solver) 63 63
Note: See TracChangeset
for help on using the changeset viewer.