Changeset 151
- Timestamp:
- 07/23/09 11:47:37 (7 years ago)
- Location:
- releases/mystic-0.1a2/mystic
- Files:
-
- 4 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/mystic-0.1a2/mystic/termination.py
r124 r151 59 59 return _ 60 60 61 def SnobfitTermination(fglob=0, rtol=1e-6, ftol=1e-6, nstop=250): 62 """fglob -- the user specified global function value. 63 rtol -- a relative error for checking stopping criterion. 64 ftol -- acceptable relative error in func(xopt) for convergence. 65 nstop -- number of times no improvement is tolerated. 66 67 Terminate if no improvement after nstop iterations or if 68 abs((fopt-fglob)/fglob) < rtol for fglob != 0, abs(fopt) < ftol 69 for fglob == 0""" 70 71 def _(inst): 72 answer = False 73 hist = inst.energy_history 74 if len(hist) > nstop and (hist[-nstop]-hist[-1]) < 0: 75 answer = True 76 else: 77 fopt = inst.bestEnergy 78 if fglob: 79 if abs((fopt-fglob)/fglob) < rtol: 80 answer = True 81 else: # safeguard if functions with fglob=0 are added by user 82 if abs(fopt) < ftol: 83 answer = True 84 return answer 85 return _ 86 61 87 # end of file
Note: See TracChangeset
for help on using the changeset viewer.