Changeset 160
- Timestamp:
- 08/02/09 21:14:05 (7 years ago)
- Location:
- branches/alta/mystic-0.1a2
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alta/mystic-0.1a2/examples/test_bfgs.py
r159 r160 3 3 """ 4 4 Example: 5 - Minimize simple test functionsusing BFGS optimization.5 - Minimize the Rosenbrock function using BFGS optimization. 6 6 7 7 Demonstrates: … … 39 39 print 40 40 print "Using BFGS Quasi-Newton:" 41 y= fmin_bfgs(rosen, x0, fprime=rosen_der, gtol=1e-4, maxiter=100)42 print y41 x = fmin_bfgs(rosen, x0, fprime=rosen_der, gtol=1e-4, maxiter=100) 42 print x -
branches/alta/mystic-0.1a2/mystic/anneal_solver.py
r158 r160 40 40 Adapted for Mystic, 2009 41 41 """ 42 43 __all__ = ['AnnealSolver','anneal'] 42 44 43 45 # Mystic and numpy imports … … 200 202 def __init__(self, dim): 201 203 """ 202 Takes two initial inputs:204 Takes one initial input: 203 205 dim -- dimensionality of the problem 204 206 -
branches/alta/mystic-0.1a2/mystic/scipy_bfgs.py
r159 r160 336 336 def __init__(self, dim): 337 337 """ 338 Takes two initial inputs:338 Takes one initial input: 339 339 dim -- dimensionality of the problem 340 340 … … 345 345 def Solve(self, func, sigint_callback=None, 346 346 EvaluationMonitor=Null, StepMonitor=Null, GradMonitor=Null, 347 InvHessianMonitor=Null, ExtraArgs=( (), ()), **kwds):347 InvHessianMonitor=Null, ExtraArgs=(), **kwds): 348 348 """Minimize a function using BFGS. 349 349 … … 366 366 GradMonitor -- Monitors the gradient. 367 367 InvHessianMonitor -- Monitors the inverse Hessian. 368 ExtraArgs -- extra arguments for func and fprime .368 ExtraArgs -- extra arguments for func and fprime (same for both) 369 369 370 370 Further Inputs: … … 405 405 self._EARLYEXIT = False 406 406 407 fcalls, func = wrap_function(func, args [0], EvaluationMonitor)407 fcalls, func = wrap_function(func, args, EvaluationMonitor) 408 408 if self._useStrictRange: 409 409 x0 = self._clipGuessWithinRangeBoundary(x0) … … 426 426 gcalls, myfprime = wrap_function(approx_fprime, (func, epsilon), GradMonitor) 427 427 else: 428 gcalls, myfprime = wrap_function(fprime, args [1], GradMonitor)428 gcalls, myfprime = wrap_function(fprime, args, GradMonitor) 429 429 430 430 gfk = myfprime(x0) … … 442 442 while (gnorm > gtol) and (k < self._maxiter): 443 443 pk = -numpy.dot(Hk,gfk) 444 444 445 # alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \ 445 446 # linesearch.line_search(func,myfprime,xk,pk,gfk, … … 447 448 # how do I get linesearch.line_search? it is in scipy, but 448 449 # requires minpack2.so.... 450 449 451 # temporary fix: 450 452 alpha_k = None … … 531 533 # Interface for using BFGSSolver 532 534 533 def fmin_bfgs(func, x0, fprime=None, args=( (),()), gtol=1e-5, norm=Inf,535 def fmin_bfgs(func, x0, fprime=None, args=(), gtol=1e-5, norm=Inf, 534 536 epsilon=_epsilon, maxiter=None, full_output=0, disp=1, 535 537 retall=0, callback=None): … … 547 549 fprime : callable f'(x,*args) 548 550 Gradient of f. 549 args : tuple of tuples550 Extra arguments passed to f and fprime .551 args : tuple 552 Extra arguments passed to f and fprime (same to both) 551 553 gtol : float 552 554 Gradient norm must be less than gtol before successful termination. … … 585 587 warnflag : integer 586 588 1 : Maximum number of iterations exceeded. 587 2 : Gradient and/or function calls not changing.588 589 allvecs : list 589 590 Results at each iteration. Only returned if retall is True. … … 622 623 Hk = invhessianmon.y[-1] 623 624 624 if fcalls >= solver._maxfun:625 if iterations >= solver._maxiter: 625 626 warnflag = 1 626 elif iterations >= solver._maxiter:627 warnflag = 2628 627 629 628 if full_output: -
branches/alta/mystic-0.1a2/mystic/snobfit_solver.py
r158 r160 52 52 Adapted to Mystic 7/2009 -- Alta Fang 53 53 """ 54 55 __all__ = ['SnobfitSolver','snobfit'] 54 56 55 57 # Snobfit imports
Note: See TracChangeset
for help on using the changeset viewer.