Changeset 620
- Timestamp:
- 12/20/12 15:39:12 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/_symbolic.py
r619 r620 240 240 >>> print simplify_symbolic(equation, target='x2') 241 241 x2 = 3.0 + x1*x3 242 243 Further Inputs: 244 locals -- a dictionary of additional variables used in the symbolic 245 constraints equations, and their desired values. 242 246 """ #XXX: an expanded version of this code is found in build_constraints XXX# 243 247 # for now, we abort on multi-line equations or inequalities … … 376 380 >>> f([1.0, 0.0, 0.0, 1.0]) 377 381 [1.0, 0.0, -1.0, -0.5] 382 383 Further Inputs: 384 locals -- a dictionary of additional variables used in the symbolic 385 constraints equations, and their desired values. 378 386 """ 379 387 """ 380 Further Inputs:381 388 guess -- list of parameter values proposed to solve the constraints. 382 389 lower_bounds -- list of lower bounds on solution values. … … 639 646 >>> f([1.0, 0.0, 0.0, 1.0]) 640 647 [1.0, 0.0, -1.0, -0.5] 648 649 Further Inputs: 650 locals -- a dictionary of additional variables used in the symbolic 651 constraints equations, and their desired values. 641 652 """ 642 653 """ 643 Further Inputs:644 654 guess -- list of parameter values proposed to solve the constraints. 645 655 lower_bounds -- list of lower bounds on solution values. … … 699 709 >>> f([1.0, 2.0, 3.0]) 700 710 [1.0, -0.33333333333333204, 3.0] 711 712 Further Inputs: 713 locals -- a dictionary of additional variables used in the symbolic 714 constraints equations, and their desired values. 701 715 """ 702 716 """ 703 Further Inputs:704 717 guess -- list of parameter values proposed to solve the constraints. 705 718 lower_bounds -- list of lower bounds on solution values. -
branches/decorate/symbolic.py
r616 r620 456 456 code = """ 457 457 def %(container)s_%(name)s(x): return eval('%(equation)s') 458 %(container)s_%(name)s.__name__ = '%(container)s' 458 459 %(container)s_%(name)s.__doc__ = '%(equation)s'""" % fdict 459 460 #XXX: should locals just be the above dict of functions, or should we... … … 531 532 exec('%(equation)s') 532 533 return x 534 %(container)s_%(name)s.__name__ = '%(container)s' 533 535 """ % fdict #XXX: better, check if constraint satisfied... if not, then solve 534 536 #XXX: should locals just be the above dict of functions, or should we... … … 590 592 # iterate through penalties, building a compound penalty function 591 593 pf = lambda x:0.0 594 pfdoc = "" 592 595 for penalty, condition in zip(ptype, conditions): 596 pfdoc += "%s: %s\n" % (penalty.__name__, condition.__doc__) 593 597 apply = penalty(condition, **kwds) 594 598 pf = apply(pf) 599 pf.__doc__ = pfdoc.rstrip('\n') 600 pf.__name__ = 'penalty' 595 601 return pf 596 602 … … 657 663 # iterate through solvers, building a compound constraints solver 658 664 cf = lambda x:x 665 cfdoc = "" 659 666 for wrapper, condition in zip(ctype, conditions): 667 cfdoc += "%s: %s\n" % (wrapper.__name__, condition.__doc__) 660 668 apply = wrapper(condition, **kwds) 661 669 cf = apply(cf) 670 cf.__doc__ = cfdoc.rstrip('\n') 671 cf.__name__ = 'constraint' 662 672 return cf 663 673
Note: See TracChangeset
for help on using the changeset viewer.