Ticket #76 (closed defect: fixed)
not all termination conditions work for all solvers
Reported by: | mmckerns | Owned by: | mmckerns |
---|---|---|---|
Priority: | major | Milestone: | mystic-0.2a1 |
Component: | mystic.solvers | Keywords: | |
Cc: |
Description
In theory, all termination conditions should be able to be applied to any of the solvers.
As of r177, using CandidateRelativeTolerance for DEsolver fails. Other termination condition / solver pairs should be tested.
Change History
comment:2 Changed 6 years ago by mmckerns
BUG in LINE 42 in termination.py ==> diff = tolerance*(abs(hist[-generations])+abs(hist[-1])) + eta
File "build/bdist.macosx-10.3-i386/egg/mystic/termination.py", line 42,
in _ IndexError?: list index out of range
def NormalizedChangeOverGeneration?(tolerance = 1e-4, generations = 2):
"""normalized change in cost is < tolerance over number of generations:
(cost[-g] - cost[-1]) / 0.5*(abs(cost[-g]) + abs(cost[-1])) <= tolerance"""
eta = 1e-20 def _(inst):
hist = inst.energy_history lg = len(hist) diff = tolerance*(abs(hist[-generations])+abs(hist[-1])) + eta return lg > generations and 2.0*(hist[-generations]-hist[-1]) <=
diff
return _
comment:3 Changed 6 years ago by mmckerns
BUG in LINE 56 in termination.py ==> and max(abs(fsim[0]-fsim[1:])) <= ftol)
File "build/bdist.macosx-10.3-i386/egg/mystic/termination.py", line 56,
in _ TypeError?: unsupported operand type(s) for -: 'int' and 'list'
def CandidateRelativeTolerance?(xtol=1e-4, ftol=1e-4):
"""absolute difference in candidates is < tolerance:
abs(xi-x0) <= xtol & abs(fi-f0) <= ftol, where x=params & f=cost"""
def _(inst):
sim = inst.population fsim = inst.popEnergy #FIXME: abs(inf - inf) will raise a warning... errdict = numpy.seterr(invalid='ignore') #FIXME: turn off warning answer = (max(numpy.ravel(abs(sim[1:]-sim[0]))) <= xtol \
and max(abs(fsim[0]-fsim[1:])) <= ftol)
numpy.seterr(invalid=errdictinvalid?) #FIXME: turn on warnings return answer
return _
comment:5 Changed 6 years ago by mmckerns
- Status changed from assigned to closed
- Resolution set to fixed
fixed bugs in termination conditions in r239
Chose to throw a WARNING instead of an ERROR for CandidateRelativeTolerance? when nPop < 2. Is this the best behavior?
see revision 183 for some tests