diff --git a/.gitignore b/.gitignore index bcfb3d73..5c39733b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.pyc -SimPEG.sublime-project -SimPEG.sublime-workspace -docs/_build/ \ No newline at end of file +*.so +*.sublime-project +*.sublime-workspace +docs/_build/ +myNotebooks/* diff --git a/SimPEG/forward/DCProblem.py b/SimPEG/forward/DCProblem.py index 132966a8..9ddb5332 100644 --- a/SimPEG/forward/DCProblem.py +++ b/SimPEG/forward/DCProblem.py @@ -16,7 +16,7 @@ class DCProblem(ModelTransforms.LogModel, Problem): """ def __init__(self, mesh): - super(DCProblem, self).__init__(mesh) + Problem.__init__(self, mesh) self.mesh.setCellGradBC('neumann') def reshapeFields(self, u): diff --git a/SimPEG/forward/LinearProblem.py b/SimPEG/forward/LinearProblem.py index d30a5b4d..ef92957b 100644 --- a/SimPEG/forward/LinearProblem.py +++ b/SimPEG/forward/LinearProblem.py @@ -13,13 +13,13 @@ class LinearProblem(Problem): return self.G.dot(m) def J(self, m, v, u=None): - return G.dot(v) + return self.G.dot(v) def Jt(self, m, v, u=None): - return G.T.dot(v) + return self.G.T.dot(v) -if __name__ == '__main__': - N = 100 + +def example(N): h = np.ones(N)/N M = TensorMesh([h]) @@ -28,8 +28,6 @@ if __name__ == '__main__': p = -0.25 q = 0.25 - - g = lambda k: np.exp(p*jk[k]*M.vectorCCx)*np.cos(2*np.pi*q*jk[k]*M.vectorCCx) G = np.empty((nk, M.nC)) @@ -38,12 +36,6 @@ if __name__ == '__main__': G[i,:] = g(i) - - plt.figure(1) - for i in range(nk): - plt.plot(G[i,:]) - - m_true = np.zeros(M.nC) m_true[M.vectorCCx > 0.3] = 1. m_true[M.vectorCCx > 0.45] = -0.5 @@ -55,29 +47,29 @@ if __name__ == '__main__': d_obs = d_true + noise - # plt.figure(3) - # plt.plot(d_true,'-o') - # plt.plot(d_obs,'r-o') - - - - - prob = LinearProblem(M) prob.G = G prob.dobs = d_obs prob.std = np.ones_like(d_obs)*0.1 + return prob, m_true + + +if __name__ == '__main__': + + prob, m_true = example(100) + M = prob.mesh + reg = Regularization(M) - opt = InexactGaussNewton(maxIter=20) - inv = Inversion(prob,reg,opt,beta0=1e-4) - m0 = np.zeros_like(m_true) mrec = inv.run(m0) + plt.figure(1) + for i in range(prob.G.shape[0]): + plt.plot(prob.G[i,:]) plt.figure(2) diff --git a/SimPEG/forward/Problem.py b/SimPEG/forward/Problem.py index 2e6831f7..cf22baae 100644 --- a/SimPEG/forward/Problem.py +++ b/SimPEG/forward/Problem.py @@ -140,7 +140,7 @@ class Problem(object): This can often be computed given a vector (i.e. J(v)) rather than stored, as J is a large dense matrix. """ - pass + raise NotImplementedError('J is not yet implemented.') def Jt(self, m, v, u=None): """ @@ -152,7 +152,7 @@ class Problem(object): Effect of transpose of J on a vector v. """ - pass + raise NotImplementedError('Jt is not yet implemented.') def J_approx(self, m, v, u=None): diff --git a/SimPEG/inverse/BetaSchedule.py b/SimPEG/inverse/BetaSchedule.py index fe197340..af4d883d 100644 --- a/SimPEG/inverse/BetaSchedule.py +++ b/SimPEG/inverse/BetaSchedule.py @@ -8,5 +8,5 @@ class Cooling(object): def getBeta(self): if self._beta is None: - return beta0 - return self._beta / beta_coolingFactor + return self.beta0 + return self._beta / self.beta_coolingFactor diff --git a/SimPEG/inverse/Inversion.py b/SimPEG/inverse/Inversion.py index 3aa8ce58..e3d500b1 100644 --- a/SimPEG/inverse/Inversion.py +++ b/SimPEG/inverse/Inversion.py @@ -1,35 +1,33 @@ import numpy as np import scipy.sparse as sp -from SimPEG.utils import sdiag, mkvc +import SimPEG +from SimPEG.utils import sdiag, mkvc, setKwargs, checkStoppers, printStoppers +from Optimize import Remember +from BetaSchedule import Cooling -class Inversion(object): - """docstring for Inversion""" +class BaseInversion(object): + """docstring for BaseInversion""" - maxIter = 10 - name = 'SimPEG Inversion' + maxIter = 1 + name = 'BaseInversion' + debug = False + beta0 = 1e4 def __init__(self, prob, reg, opt, **kwargs): + setKwargs(self, **kwargs) self.prob = prob self.reg = reg self.opt = opt self.opt.parent = self - self.setKwargs(**kwargs) - def setKwargs(self, **kwargs): - """Sets key word arguments (kwargs) that are present in the object, throw an error if they don't exist.""" - for attr in kwargs: - if hasattr(self, attr): - setattr(self, attr, kwargs[attr]) - else: - raise Exception('%s attr is not recognized' % attr) + self.stoppers = [SimPEG.inverse.StoppingCriteria.iteration, SimPEG.inverse.StoppingCriteria.phi_d_target_Inversion] - def printInit(self): - print "%s %s %s" % ('='*22, self.name, '='*22) - print " # beta phi_d phi_m f norm(dJ) #LS" - print "%s" % '-'*62 - - def printIter(self): - print "%3d %1.2e %1.2e %1.2e %1.2e %1.2e %3d" % (self.opt._iter, self._beta, self._phi_d_last, self._phi_m_last, self.opt.f, np.linalg.norm(self.opt.g), self.opt._iterLS) + # Check if we have inserted printers into the optimization + if not np.any([p is SimPEG.inverse.IterationPrinters.phi_d for p in self.opt.printers]): + self.opt.printers.insert(1,SimPEG.inverse.IterationPrinters.beta) + self.opt.printers.insert(2,SimPEG.inverse.IterationPrinters.phi_d) + self.opt.printers.insert(3,SimPEG.inverse.IterationPrinters.phi_m) + self.opt.stoppers.append(SimPEG.inverse.StoppingCriteria.phi_d_target_Minimize) @property def Wd(self): @@ -53,34 +51,85 @@ class Inversion(object): if getattr(self, '_phi_d_target', None) is None: return self.prob.dobs.size # return self._phi_d_target + @phi_d_target.setter def phi_d_target(self, value): self._phi_d_target = value def run(self, m0): - m = m0 - self._iter = 0 - self._beta = None + self.startup(m0) while True: self._beta = self.getBeta() - m = self.opt.minimize(self.evalFunction,m) + self.m = self.opt.minimize(self.evalFunction, self.m) + self.doEndIteration() if self.stoppingCriteria(): break - self._iter += 1 - return m - beta0 = 1.e2 - beta_coolingFactor = 5. + self.printDone() + return self.m + + def startup(self, m0): + """ + **startup** is called at the start of any new run call. + + If you have things that also need to run on startup, you can create a method:: + + def _startup*(self, x0): + pass + + Where the * can be any string. If present, _startup* will be called at the start of the default startup call. + You may also completely overwrite this function. + + :param numpy.ndarray x0: initial x + :rtype: None + :return: None + """ + for method in [posible for posible in dir(self) if '_startup' in posible]: + if self.debug: print 'startup is calling self.'+method + getattr(self,method)(m0) + + self.m = m0 + self._iter = 0 + self._beta = None + + def doEndIteration(self): + """ + **doEndIteration** is called at the end of each run iteration. + + If you have things that also need to run at the end of every iteration, you can create a method:: + + def _doEndIteration*(self, xt): + pass + + Where the * can be any string. If present, _doEndIteration* will be called at the start of the default doEndIteration call. + You may also completely overwrite this function. + + :param numpy.ndarray xt: tested new iterate that ensures a descent direction. + :rtype: None + :return: None + """ + for method in [posible for posible in dir(self) if '_doEndIteration' in posible]: + if self.debug: print 'doEndIteration is calling self.'+method + getattr(self,method)() + + # store old values + self.phi_d_last = self.phi_d + self.phi_m_last = self.phi_m + self._iter += 1 def getBeta(self): - if self._beta is None: - return self.beta0 - return self._beta / self.beta_coolingFactor + return self.beta0 def stoppingCriteria(self): - self._STOP = np.zeros(2,dtype=bool) - self._STOP[0] = self._iter >= self.maxIter - self._STOP[1] = self._phi_d_last <= self.phi_d_target - return np.any(self._STOP) + if self.debug: print 'checking stoppingCriteria' + return checkStoppers(self, self.stoppers) + + + def printDone(self): + """ + **printDone** is called at the end of the inversion routine. + + """ + printStoppers(self, self.stoppers) def evalFunction(self, m, return_g=True, return_H=True): @@ -89,8 +138,8 @@ class Inversion(object): phi_d = self.dataObj(m, u) phi_m = self.reg.modelObj(m) - self._phi_d_last = phi_d - self._phi_m_last = phi_m + self.phi_d = phi_d + self.phi_m = phi_m f = phi_d + self._beta * phi_m @@ -111,7 +160,7 @@ class Inversion(object): operator = sp.linalg.LinearOperator( (m.size, m.size), H_fun, dtype=float ) out += (operator,) - return out + return out if len(out) > 1 else out[0] def dataObj(self, m, u=None): @@ -219,3 +268,10 @@ class Inversion(object): return dmisfit +class Inversion(Cooling, Remember, BaseInversion): + + maxIter = 10 + name = "SimPEG Inversion" + + def __init__(self, prob, reg, opt, **kwargs): + BaseInversion.__init__(self, prob, reg, opt, **kwargs) diff --git a/SimPEG/inverse/Optimize.py b/SimPEG/inverse/Optimize.py index 6221246f..37c8b296 100644 --- a/SimPEG/inverse/Optimize.py +++ b/SimPEG/inverse/Optimize.py @@ -1,6 +1,6 @@ import numpy as np import matplotlib.pyplot as plt -from SimPEG.utils import mkvc, sdiag +from SimPEG.utils import mkvc, sdiag, setKwargs, printTitles, printLine, printStoppers, checkStoppers norm = np.linalg.norm import scipy.sparse as sp from SimPEG import Solver @@ -12,6 +12,75 @@ except Exception, e: print 'Warning: you may not have the required pubsub installed, use pypubsub. You will not be able to listen to events.' doPub = False +class StoppingCriteria(object): + """docstring for StoppingCriteria""" + + iteration = { "str": "%d : maxIter = %3d <= iter = %3d", + "left": lambda M: M.maxIter, "right": lambda M: M._iter, + "stopType": "critical"} + + iterationLS = { "str": "%d : maxIterLS = %3d <= iterLS = %3d", + "left": lambda M: M.maxIterLS, "right": lambda M: M._iterLS, + "stopType": "critical"} + + armijoGoldstein = { "str": "%d : ft = %1.4e <= alp*descent = %1.4e", + "left": lambda M: M._LS_ft, "right": lambda M: M.f + M.LSreduction * M._LS_descent, + "stopType": "optimal"} + + tolerance_f = { "str": "%d : |fc-fOld| = %1.4e <= tolF*(1+|f0|) = %1.4e", + "left": lambda M: 1 if M._iter==0 else abs(M.f-M.f_last), "right": lambda M: 0 if M._iter==0 else M.tolF*(1+abs(M.f0)), + "stopType": "optimal"} + + moving_x = { "str": "%d : |xc-x_last| = %1.4e <= tolX*(1+|x0|) = %1.4e", + "left": lambda M: 1 if M._iter==0 else norm(M.xc-M.x_last), "right": lambda M: 0 if M._iter==0 else M.tolX*(1+norm(M.x0)), + "stopType": "optimal"} + + tolerance_g = { "str": "%d : |proj(x-g)-x| = %1.4e <= tolG = %1.4e", + "left": lambda M: norm(M.projection(M.xc - M.g) - M.xc), "right": lambda M: M.tolG, + "stopType": "optimal"} + + norm_g = { "str": "%d : |proj(x-g)-x| = %1.4e <= 1e3*eps = %1.4e", + "left": lambda M: norm(M.projection(M.xc - M.g) - M.xc), "right": lambda M: 1e3*M.eps, + "stopType": "critical"} + + bindingSet = { "str": "%d : probSize = %3d <= bindingSet = %3d", + "left": lambda M: M.xc.size, "right": lambda M: np.sum(M.bindingSet(M.xc)), + "stopType": "critical"} + + bindingSet_LS = { "str": "%d : probSize = %3d <= bindingSet = %3d", + "left": lambda M: M._LS_xt.size, "right": lambda M: np.sum(M.bindingSet(M._LS_xt)), + "stopType": "critical"} + + phi_d_target_Minimize = { "str": "%d : phi_d = %1.4e <= phi_d_target = %1.4e ", + "left": lambda M: M.parent.phi_d, "right": lambda M: M.parent.phi_d_target, + "stopType": "critical"} + + phi_d_target_Inversion = { "str": "%d : phi_d = %1.4e <= phi_d_target = %1.4e ", + "left": lambda I: I.phi_d, "right": lambda I: I.phi_d_target, + "stopType": "critical"} + + +class IterationPrinters(object): + """docstring for IterationPrinters""" + + iteration = {"title": "#", "value": lambda M: M._iter, "width": 5, "format": "%3d"} + f = {"title": "f", "value": lambda M: M.f, "width": 10, "format": "%1.2e"} + norm_g = {"title": "|proj(x-g)-x|", "value": lambda M: norm(M.projection(M.xc - M.g) - M.xc), "width": 15, "format": "%1.2e"} + totalLS = {"title": "LS", "value": lambda M: M._iterLS, "width": 5, "format": "%d"} + + iterationLS = {"title": "#", "value": lambda M: (M._iter, M._iterLS), "width": 5, "format": "%3d.%d"} + LS_ft = {"title": "ft", "value": lambda M: M._LS_ft, "width": 10, "format": "%1.2e"} + LS_t = {"title": "t", "value": lambda M: M._LS_t, "width": 10, "format": "%0.5f"} + LS_armijoGoldstein = {"title": "f + alp*g.T*p", "value": lambda M: M.f + M.LSreduction*M._LS_descent, "width": 16, "format": "%1.2e"} + + itType = {"title": "itType", "value": lambda M: M._itType, "width": 8, "format": "%s"} + aSet = {"title": "aSet", "value": lambda M: np.sum(M.activeSet(M.xc)), "width": 8, "format": "%d"} + bSet = {"title": "bSet", "value": lambda M: np.sum(M.bindingSet(M.xc)), "width": 8, "format": "%d"} + comment = {"title": "Comment", "value": lambda M: M.projComment, "width": 7, "format": "%s"} + + beta = {"title": "beta", "value": lambda M: M.parent._beta, "width": 10, "format": "%1.2e"} + phi_d = {"title": "phi_d", "value": lambda M: M.parent.phi_d, "width": 10, "format": "%1.2e"} + phi_m = {"title": "phi_m", "value": lambda M: M.parent.phi_m, "width": 10, "format": "%1.2e"} class Minimize(object): @@ -22,7 +91,7 @@ class Minimize(object): """ - name = "GeneralOptimizationAlgorithm" + name = "General Optimization Algorithm" maxIter = 20 maxIterLS = 10 @@ -34,17 +103,18 @@ class Minimize(object): tolG = 1e-1 eps = 1e-5 + debug = False + debugLS = False + def __init__(self, **kwargs): self._id = int(np.random.rand()*1e6) # create a unique identifier to this program to be used in pubsub - self.setKwargs(**kwargs) + self.stoppers = [StoppingCriteria.tolerance_f, StoppingCriteria.moving_x, StoppingCriteria.tolerance_g, StoppingCriteria.norm_g, StoppingCriteria.iteration] + self.stoppersLS = [StoppingCriteria.armijoGoldstein, StoppingCriteria.iterationLS] - def setKwargs(self, **kwargs): - """Sets key word arguments (kwargs) that are present in the object, throw an error if they don't exist.""" - for attr in kwargs: - if hasattr(self, attr): - setattr(self, attr, kwargs[attr]) - else: - raise Exception('%s attr is not recognized' % attr) + self.printers = [IterationPrinters.iteration, IterationPrinters.f, IterationPrinters.norm_g, IterationPrinters.totalLS] + self.printersLS = [IterationPrinters.iterationLS, IterationPrinters.LS_ft, IterationPrinters.LS_t, IterationPrinters.LS_armijoGoldstein] + + setKwargs(self, **kwargs) def minimize(self, evalFunction, x0): """ @@ -59,6 +129,14 @@ class Minimize(object): (f[, g][, H]) = evalFunction(x, return_g=False, return_H=False ) + def evalFunction(x, return_g=False, return_H=False): + out = (f,) + if return_g: + out += (g,) + if return_H: + out += (H,) + return out if len(out) > 1 else out[0] + Events are fired with the following inputs via pypubsub:: @@ -146,19 +224,33 @@ class Minimize(object): xc = x0 _iter = _iterLS = 0 + If you have things that also need to run on startup, you can create a method:: + + def _startup*(self, x0): + pass + + Where the * can be any string. If present, _startup* will be called at the start of the default startup call. + You may also completely overwrite this function. + :param numpy.ndarray x0: initial x :rtype: None :return: None """ + for method in [posible for posible in dir(self) if '_startup' in posible]: + if self.debug: print 'startup is calling self.'+method + getattr(self,method)(x0) + self._iter = 0 self._iterLS = 0 - self._STOP = np.zeros((5,1),dtype=bool) + x0 = self.projection(x0) # ensure that we start of feasible. self.x0 = x0 self.xc = x0 - self.xOld = x0 + self.f_last = np.nan + self.x_last = x0 - def printInit(self): + + def printInit(self, inLS=False): """ **printInit** is called at the beginning of the optimization routine. @@ -166,15 +258,12 @@ class Minimize(object): parent.printInit function and call that. """ - if doPub: pub.sendMessage('Minimize.printInit', minimize=self) - if self.parent is not None and hasattr(self.parent, 'printInit'): - self.parent.printInit() - return - print "%s %s %s" % ('='*22, self.name, '='*22) - print "iter\tJc\t\tnorm(dJ)\tLS" - print "%s" % '-'*57 + if doPub and not inLS: pub.sendMessage('Minimize.printInit', minimize=self) + pad = ' '*10 if inLS else '' + name = self.name if not inLS else self.nameLS + printTitles(self, self.printers if not inLS else self.printersLS, name, pad) - def printIter(self): + def printIter(self, inLS=False): """ **printIter** is called directly after function evaluations. @@ -182,13 +271,11 @@ class Minimize(object): parent.printIter function and call that. """ - if doPub: pub.sendMessage('Minimize.printIter', minimize=self) - if self.parent is not None and hasattr(self.parent, 'printIter'): - self.parent.printIter() - return - print "%3d\t%1.2e\t%1.2e\t%d" % (self._iter, self.f, norm(self.g), self._iterLS) + if doPub and not inLS: pub.sendMessage('Minimize.printIter', minimize=self) + pad = ' '*10 if inLS else '' + printLine(self, self.printers if not inLS else self.printersLS, pad=pad) - def printDone(self): + def printDone(self, inLS=False): """ **printDone** is called at the end of the optimization routine. @@ -196,31 +283,19 @@ class Minimize(object): parent.printDone function and call that. """ - if doPub: pub.sendMessage('Minimize.printDone', minimize=self) - if self.parent is not None and hasattr(self.parent, 'printDone'): - self.parent.printDone() - return - print "%s STOP! %s" % ('-'*25,'-'*25) - # TODO: put controls on gradient value, min model update, and function value - if self._iter > 0: - print "%d : |fc-fOld| = %1.4e <= tolF*(1+|fStop|) = %1.4e" % (self._STOP[0], abs(self.f-self.fOld), self.tolF*(1+abs(self.fStop))) - print "%d : |xc-xOld| = %1.4e <= tolX*(1+|x0|) = %1.4e" % (self._STOP[1], norm(self.xc-self.xOld), self.tolX*(1+norm(self.x0))) - print "%d : |g| = %1.4e <= tolG*(1+|fStop|) = %1.4e" % (self._STOP[2], norm(self.g), self.tolG*(1+abs(self.fStop))) - print "%d : |g| = %1.4e <= 1e3*eps = %1.4e" % (self._STOP[3], norm(self.g), 1e3*self.eps) - print "%d : iter = %3d\t <= maxIter\t = %3d" % (self._STOP[4], self._iter, self.maxIter) - print "%s DONE! %s\n" % ('='*25,'='*25) + if doPub and not inLS: pub.sendMessage('Minimize.printDone', minimize=self) + pad = ' '*10 if inLS else '' + stop, done = (' STOP! ', ' DONE! ') if not inLS else ('----------------', ' End Linesearch ') + stoppers = self.stoppers if not inLS else self.stoppersLS + printStoppers(self, stoppers, pad='', stop=stop, done=done) - def stoppingCriteria(self): + + def stoppingCriteria(self, inLS=False): if self._iter == 0: - self.fStop = self.f # Save this for stopping criteria + self.f0 = self.f + self.g0 = self.g + return checkStoppers(self, self.stoppers if not inLS else self.stoppersLS) - # check stopping rules - self._STOP[0] = self._iter > 0 and (abs(self.f-self.fOld) <= self.tolF*(1+abs(self.fStop))) - self._STOP[1] = self._iter > 0 and (norm(self.xc-self.xOld) <= self.tolX*(1+norm(self.x0))) - self._STOP[2] = norm(self.g) <= self.tolG*(1+abs(self.fStop)) - self._STOP[3] = norm(self.g) <= 1e3*self.eps - self._STOP[4] = self._iter >= self.maxIter - return all(self._STOP[0:3]) | any(self._STOP[3:]) def projection(self, p): """ @@ -278,6 +353,8 @@ class Minimize(object): p = self.maxStep*p/np.abs(p.max()) return p + nameLS = "Armijo linesearch" + def modifySearchDirection(self, p): """ **modifySearchDirection** changes the search direction based on some sort of linesearch or trust-region criteria. @@ -296,20 +373,23 @@ class Minimize(object): :rtype: numpy.ndarray,bool :return: (xt, passLS) """ - # Armijo linesearch - descent = np.inner(self.g, p) - t = 1 - iterLS = 0 - while iterLS < self.maxIterLS: - xt = self.projection(self.xc + t*p) - ft = self.evalFunction(xt, return_g=False, return_H=False) - if ft < self.f + t*self.LSreduction*descent: - break - iterLS += 1 - t = self.LSshorten*t + # Projected Armijo linesearch + self._LS_t = 1 + self._iterLS = 0 + while self._iterLS < self.maxIterLS: + self._LS_xt = self.projection(self.xc + self._LS_t*p) + self._LS_ft = self.evalFunction(self._LS_xt, return_g=False, return_H=False) + self._LS_descent = np.inner(self.g, self._LS_xt - self.xc) # this takes into account multiplying by t, but is important for projection. + if self.stoppingCriteria(inLS=True): break + self._iterLS += 1 + self._LS_t = self.LSshorten*self._LS_t + if self.debugLS: + if self._iterLS == 1: self.printInit(inLS=True) + self.printIter(inLS=True) - self._iterLS = iterLS - return xt, iterLS < self.maxIterLS + if self.debugLS and self._iterLS > 0: self.printDone(inLS=True) + + return self._LS_xt, self._iterLS < self.maxIterLS def modifySearchDirectionBreak(self, p): """ @@ -327,35 +407,227 @@ class Minimize(object): :rtype: numpy.ndarray,bool :return: (xt, breakCaught) """ + self.printDone(inLS=True) print 'The linesearch got broken. Boo.' return p, False def doEndIteration(self, xt): """ - **doEndIteration** is called at the end of each minimize iteration. + **doEndIteration** is called at the end of each minimize iteration. - By default, function values and x locations are shuffled to store 1 past iteration in memory. + By default, function values and x locations are shuffled to store 1 past iteration in memory. - self.xc must be updated in this code. + self.xc must be updated in this code. - :param numpy.ndarray xt: tested new iterate that ensures a descent direction. - :rtype: None - :return: None + + If you have things that also need to run at the end of every iteration, you can create a method:: + + def _doEndIteration*(self, xt): + pass + + Where the * can be any string. If present, _doEndIteration* will be called at the start of the default doEndIteration call. + You may also completely overwrite this function. + + :param numpy.ndarray xt: tested new iterate that ensures a descent direction. + :rtype: None + :return: None """ + for method in [posible for posible in dir(self) if '_doEndIteration' in posible]: + if self.debug: print 'doEndIteration is calling self.'+method + getattr(self,method)(xt) + # store old values - self.fOld = self.f - self.xOld, self.xc = self.xc, xt + self.f_last = self.f + self.x_last, self.xc = self.xc, xt self._iter += 1 + if self.debug: self.printDone() -class GaussNewton(Minimize): - name = 'GaussNewton' + +class Remember(object): + """ + This mixin remembers all the things you tend to forget. + + You can remember parameters directly, naming the str in Minimize, + or pass a tuple with the name and the function that takes Minimize. + + For Example:: + + opt.remember('f',('norm_g', lambda M: np.linalg.norm(M.g))) + + opt.minimize(evalFunction, x0) + + opt.recall('f') + + The param name (str) can also be located in the parent (if no conflicts), + and it will be looked up by default. + """ + + _rememberThese = [] + + def remember(self, *args): + self._rememberThese = args + + def recall(self, param): + assert param in self._rememberList, "You didn't tell me to remember "+param+", you gotta tell me what to remember!" + return self._rememberList[param] + + def _startupRemember(self, x0): + self._rememberList = {} + for param in self._rememberThese: + if type(param) is str: + self._rememberList[param] = [] + elif type(param) is tuple: + self._rememberList[param[0]] = [] + + def _doEndIterationRemember(self, *args): + for param in self._rememberThese: + if type(param) is str: + if self.debug: print 'Remember is remembering: ' + param + val = getattr(self, param, None) + if val is None and getattr(self, 'parent', None) is not None: + # Look to the parent for the param if not found here. + val = getattr(self.parent, param, None) + self._rememberList[param].append( val ) + elif type(param) is tuple: + if self.debug: print 'Remember is remembering: ' + param[0] + self._rememberList[param[0]].append( param[1](self) ) + + + +class ProjectedGradient(Minimize, Remember): + name = 'Projected Gradient' + + maxIterCG = 10 + tolCG = 1e-3 + + lower = -np.inf + upper = np.inf + + def __init__(self,**kwargs): + super(ProjectedGradient, self).__init__(**kwargs) + + self.stoppers.append(StoppingCriteria.bindingSet) + self.stoppersLS.append(StoppingCriteria.bindingSet_LS) + + self.printers.extend([ IterationPrinters.itType, IterationPrinters.aSet, IterationPrinters.bSet, IterationPrinters.comment ]) + + + def _startup(self, x0): + # ensure bound vectors are the same size as the model + if type(self.lower) is not np.ndarray: + self.lower = np.ones_like(x0)*self.lower + if type(self.upper) is not np.ndarray: + self.upper = np.ones_like(x0)*self.upper + + self.explorePG = True + self.exploreCG = False + self.stopDoingPG = False + + self._itType = 'SD' + self.projComment = '' + + self.aSet_prev = self.activeSet(x0) + + def projection(self, x): + """Make sure we are feasible.""" + return np.median(np.c_[self.lower,x,self.upper],axis=1) + + def activeSet(self, x): + """If we are on a bound""" + return np.logical_or(x == self.lower, x == self.upper) + + def inactiveSet(self, x): + """The free variables.""" + return np.logical_not(self.activeSet(x)) + + def bindingSet(self, x): + """ + If we are on a bound and the negative gradient points away from the feasible set. + + Optimality condition. (Satisfies Kuhn-Tucker) MoreToraldo91 + + """ + bind_up = np.logical_and(x == self.lower, self.g >= 0) + bind_low = np.logical_and(x == self.upper, self.g <= 0) + return np.logical_or(bind_up, bind_low) + + def findSearchDirection(self): + self.aSet_prev = self.activeSet(self.xc) + allBoundsAreActive = sum(self.aSet_prev) == self.xc.size + + if self.debug: print 'findSearchDirection: stopDoingPG: ', self.stopDoingPG + if self.debug: print 'findSearchDirection: explorePG: ', self.explorePG + if self.debug: print 'findSearchDirection: exploreCG: ', self.exploreCG + if self.debug: print 'findSearchDirection: aSet', np.sum(self.activeSet(self.xc)) + if self.debug: print 'findSearchDirection: bSet', np.sum(self.bindingSet(self.xc)) + if self.debug: print 'findSearchDirection: allBoundsAreActive: ', allBoundsAreActive + + if self.explorePG or not self.exploreCG or allBoundsAreActive: + if self.debug: print 'findSearchDirection.PG: doingPG' + self._itType = 'SD' + p = -self.g + else: + if self.debug: print 'findSearchDirection.CG: doingCG' + # Reset the max decrease each time you do a CG iteration + self.f_decrease_max = -np.inf + + self._itType = '.CG.' + + iSet = self.inactiveSet(self.xc) # The inactive set (free variables) + bSet = self.bindingSet(self.xc) + shape = (self.xc.size, np.sum(iSet)) + v = np.ones(shape[1]) + i = np.where(iSet)[0] + j = np.arange(shape[1]) + if self.debug: print 'findSearchDirection.CG: Z.shape', shape + Z = sp.csr_matrix((v, (i, j)), shape=shape) + + def reduceHess(v): + # Z is tall and skinny + return Z.T*(self.H*(Z*v)) + operator = sp.linalg.LinearOperator( (shape[1], shape[1]), reduceHess, dtype=float ) + p, info = sp.linalg.cg(operator, -Z.T*self.g, tol=self.tolCG, maxiter=self.maxIterCG) + p = Z*p # bring up to full size + # aSet_after = self.activeSet(self.xc+p) + return p + + def _doEndIteration_ProjectedGradient(self, xt): + aSet = self.activeSet(xt) + bSet = self.bindingSet(xt) + + self.explorePG = not np.all(aSet == self.aSet_prev) # explore proximal gradient + self.exploreCG = np.all(aSet == bSet) # explore conjugate gradient + + f_current_decrease = self.f_last - self.f + self.projComment = '' + if self._iter < 1: + # Note that this is reset on every CG iteration. + self.f_decrease_max = -np.inf + else: + self.f_decrease_max = max(self.f_decrease_max, f_current_decrease) + self.stopDoingPG = f_current_decrease < 0.25 * self.f_decrease_max + if self.stopDoingPG: + self.projComment = 'Stop SD' + self.explorePG = False + self.exploreCG = True + # implement 3.8, MoreToraldo91 + #self.eta_2 * max_decrease where max decrease + # if true go to CG + # don't do too many steps of PG in a row. + + if self.debug: print 'doEndIteration.ProjGrad, f_current_decrease: ', f_current_decrease + if self.debug: print 'doEndIteration.ProjGrad, f_decrease_max: ', self.f_decrease_max + if self.debug: print 'doEndIteration.ProjGrad, stopDoingSD: ', self.stopDoingSD + +class GaussNewton(Minimize, Remember): + name = 'Gauss Newton' def findSearchDirection(self): return Solver(self.H).solve(-self.g) -class InexactGaussNewton(Minimize): - name = 'InexactGaussNewton' +class InexactGaussNewton(Minimize, Remember): + name = 'Inexact Gauss Newton' maxIterCG = 10 tolCG = 1e-5 @@ -366,8 +638,8 @@ class InexactGaussNewton(Minimize): return p -class SteepestDescent(Minimize): - name = 'SteepestDescent' +class SteepestDescent(Minimize, Remember): + name = 'Steepest Descent' def findSearchDirection(self): return -self.g @@ -377,9 +649,9 @@ if __name__ == '__main__': x0 = np.array([2.6, 3.7]) checkDerivative(Rosenbrock, x0, plotIt=False) - def listener1(minimize,p): - print 'hi: ', p - if doPub: pub.subscribe(listener1, 'Minimize.searchDirection') + # def listener1(minimize,p): + # print 'hi: ', p + # if doPub: pub.subscribe(listener1, 'Minimize.searchDirection') xOpt = GaussNewton(maxIter=20,tolF=1e-10,tolX=1e-10,tolG=1e-10).minimize(Rosenbrock,x0) print "xOpt=[%f, %f]" % (xOpt[0], xOpt[1]) diff --git a/SimPEG/setup.py b/SimPEG/setup.py new file mode 100644 index 00000000..c421cb4b --- /dev/null +++ b/SimPEG/setup.py @@ -0,0 +1,8 @@ +import os +print 'Compiling TriSolve.' +os.system('f2py -c utils/TriSolve.f -m TriSolve') +print 'TriSolve Compiled! yay.' +print 'Moving TriSolve into Utils.' +os.system('mv TriSolve.so utils/TriSolve.so') +print 'Thats it. Well Done Computer.' + diff --git a/SimPEG/tests/TestUtils.py b/SimPEG/tests/TestUtils.py index 140b56fa..1cc2bbae 100644 --- a/SimPEG/tests/TestUtils.py +++ b/SimPEG/tests/TestUtils.py @@ -5,11 +5,17 @@ from SimPEG.utils import mkvc, sdiag from SimPEG import utils from SimPEG.mesh import TensorMesh, LogicallyOrthogonalMesh import numpy as np +import scipy.sparse as sp import unittest import inspect -happiness = ['The test be workin!', 'You get a gold star!', 'Yay passed!', 'Happy little convergence test!', 'That was easy!', 'Testing is important.', 'You are awesome.', 'Go Test Go!', 'Once upon a time, a happy little test passed.', 'And then everyone was happy.'] -sadness = ['No gold star for you.','Try again soon.','Thankfully, persistence is a great substitute for talent.','It might be easier to call this a feature...','Coffee break?', 'Boooooooo :(', 'Testing is important. Do it again.'] +try: + import getpass + name = getpass.getuser()[0].upper() + getpass.getuser()[1:] +except Exception, e: + name = 'You' +happiness = ['The test be workin!', 'You get a gold star!', 'Yay passed!', 'Happy little convergence test!', 'That was easy!', 'Testing is important.', 'You are awesome.', 'Go Test Go!', 'Once upon a time, a happy little test passed.', 'And then everyone was happy.','Not just a pretty face '+name,'You deserve a pat on the back!','Well done '+name+'!', 'Awesome, '+name+', just awesome.'] +sadness = ['No gold star for you.','Try again soon.','Thankfully, persistence is a great substitute for talent.','It might be easier to call this a feature...','Coffee break?', 'Boooooooo :(', 'Testing is important. Do it again.',"Did you put your clever trousers on today?",'Just think about a dancing dinosaur and life will get better!','You had so much promise '+name+', oh well...', name.upper()+' ERROR!','Get on it '+name+'!', 'You break it, you fix it.'] class OrderTest(unittest.TestCase): """ @@ -174,14 +180,14 @@ def Rosenbrock(x, return_g=True, return_H=True): f = 100*(x[1]-x[0]**2)**2+(1-x[0])**2 g = np.array([2*(200*x[0]**3-200*x[0]*x[1]+x[0]-1), 200*(x[1]-x[0]**2)]) - H = np.array([[-400*x[1]+1200*x[0]**2+2, -400*x[0]], [-400*x[0], 200]]) + H = sp.csr_matrix(np.array([[-400*x[1]+1200*x[0]**2+2, -400*x[0]], [-400*x[0], 200]])) out = (f,) if return_g: out += (g,) if return_H: out += (H,) - return out + return out if len(out) > 1 else out[0] def checkDerivative(fctn, x0, num=7, plotIt=True, dx=None): """ @@ -269,6 +275,28 @@ def checkDerivative(fctn, x0, num=7, plotIt=True, dx=None): return passTest + +def getQuadratic(A, b): + """ + Given A and b, this returns a quadratic, Q + + .. math:: + + \mathbf{Q( x ) = 0.5 x A x + b x} + """ + def Quadratic(x, return_g=True, return_H=True): + f = 0.5 * x.dot( A.dot(x)) + b.dot( x ) + out = (f,) + if return_g: + g = A.dot(x) + b + out += (g,) + if return_H: + H = A + out += (H,) + return out if len(out) > 1 else out[0] + return Quadratic + + if __name__ == '__main__': def simplePass(x): diff --git a/SimPEG/tests/__init__.py b/SimPEG/tests/__init__.py index f896cfd0..d082562d 100644 --- a/SimPEG/tests/__init__.py +++ b/SimPEG/tests/__init__.py @@ -1,2 +1,2 @@ import TestUtils -from TestUtils import checkDerivative, Rosenbrock, OrderTest +from TestUtils import checkDerivative, Rosenbrock, OrderTest, getQuadratic diff --git a/SimPEG/tests/api_TestResults.rst b/SimPEG/tests/api_TestResults.rst deleted file mode 100644 index 0d63a328..00000000 --- a/SimPEG/tests/api_TestResults.rst +++ /dev/null @@ -1,355 +0,0 @@ -.. _api_TestResults: - -.. raw:: html - - -
- - -Start Time: 2013-11-05 15:24:44
-Duration: 0:00:00.007500
-Status: Pass 22
- -This demonstrates the report output by Prasanna.Yelsangikar.
-Show - Summary - Failed - All -
-| Test Group/Test case | -Count | -Pass | -Fail | -Error | -View | -
| test_basemesh.TestBaseMesh | -11 | -11 | -0 | -0 | -Detail | -
test_meshDimensions |
- pass | -||||
test_mesh_nc |
- pass | -||||
test_mesh_nc_xyz |
- pass | -||||
test_mesh_ne |
- pass | -||||
test_mesh_nf |
- pass | -||||
test_mesh_numbers |
- pass | -||||
test_mesh_r_CC_M |
- pass | -||||
test_mesh_r_E_M |
- pass | -||||
test_mesh_r_E_V |
- pass | -||||
test_mesh_r_F_M |
- pass | -||||
test_mesh_r_F_V |
- pass | -||||
| test_basemesh.TestMeshNumbers2D | -11 | -11 | -0 | -0 | -Detail | -
test_meshDimensions |
- pass | -||||
test_mesh_nc |
- pass | -||||
test_mesh_nc_xyz |
- pass | -||||
test_mesh_ne |
- pass | -||||
test_mesh_nf |
- pass | -||||
test_mesh_numbers |
- pass | -||||
test_mesh_r_CC_M |
- pass | -||||
test_mesh_r_E_M |
- pass | -||||
test_mesh_r_E_V |
- pass | -||||
test_mesh_r_F_M |
- pass | -||||
test_mesh_r_F_V |
- pass | -||||
| Total | -22 | -22 | -0 | -0 | -- |
Start Time: 2013-11-06 12:40:59
-Duration: 0:00:32.198864
-Status: Pass 108 Failure 1
+Start Time: 2013-11-12 13:34:53
+Duration: 0:00:31.732498
+Status: Pass 117
SimPEG Test Report was automatically generated.
- ft6.6:
+ pt6.6:
uniformTensorMesh: Interpolation 2D: N
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 6.94e-02 |
- 16 | 1.84e-02 | 3.7623 | 1.9116
- 32 | 4.71e-03 | 3.9144 | 1.9688
- 64 | 1.17e-03 | 4.0345 | 2.0124
+ 8 | 6.98e-02 |
+ 16 | 1.85e-02 | 3.7771 | 1.9173
+ 32 | 4.76e-03 | 3.8827 | 1.9571
+ 64 | 1.20e-03 | 3.9676 | 1.9883
---------------------------------------------
- Happy little convergence test!
+ You deserve a pat on the back!
randomTensorMesh: Interpolation 2D: N
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 8.81e-02 |
- 16 | 5.76e-02 | 1.5297 | -3.5238
- 32 | 7.75e-03 | 7.4339 | 1.3398
- 64 | 4.05e-03 | 1.9119 | 1.4844
+ 8 | 2.05e-01 |
+ 16 | 4.37e-02 | 4.6889 | 2.7894
+ 32 | 1.30e-02 | 3.3576 | 1.7086
+ 64 | 3.69e-03 | 3.5290 | 1.8138
---------------------------------------------
- Failed to pass test on randomTensorMesh.
- Coffee break?
+ Go Test Go!
- Traceback (most recent call last):
- File "/Users/rowan/git/simpeg/SimPEG/tests/test_interpolation.py", line 96, in test_orderN
- self.orderTest()
- File "/Users/rowan/git/simpeg/SimPEG/tests/TestUtils.py", line 170, in orderTest
- self.assertTrue(passTest)
- AssertionError: False is not true
@@ -988,24 +981,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.25e-02 |
- 16 | 1.72e-02 | 4.2196 | 2.0771
- 32 | 4.48e-03 | 3.8373 | 1.9401
- 64 | 1.12e-03 | 3.9989 | 1.9996
+ 8 | 7.56e-02 |
+ 16 | 1.87e-02 | 4.0396 | 2.0142
+ 32 | 4.52e-03 | 4.1409 | 2.0499
+ 64 | 1.19e-03 | 3.8144 | 1.9315
---------------------------------------------
- Happy little convergence test!
+ Not just a pretty face Rowan
randomTensorMesh: Interpolation CC
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 1.26e-01 |
- 16 | 3.04e-02 | 4.1365 | 2.6792
- 32 | 9.68e-03 | 3.1396 | 1.3016
- 64 | 2.16e-03 | 4.4835 | 2.1777
+ 8 | 1.03e-01 |
+ 16 | 5.43e-02 | 1.8919 | 1.5786
+ 32 | 1.33e-02 | 4.0699 | 1.4626
+ 64 | 3.40e-03 | 3.9265 | 2.7539
---------------------------------------------
- Go Test Go!
+ Awesome, Rowan, just awesome.
@@ -1036,24 +1029,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.00e-02 |
- 16 | 1.86e-02 | 3.7692 | 1.9142
- 32 | 4.70e-03 | 3.9513 | 1.9823
- 64 | 1.17e-03 | 4.0254 | 2.0091
+ 8 | 7.04e-02 |
+ 16 | 1.86e-02 | 3.7784 | 1.9178
+ 32 | 4.78e-03 | 3.8981 | 1.9628
+ 64 | 1.20e-03 | 3.9741 | 1.9906
---------------------------------------------
- And then everyone was happy.
+ Well done Rowan!
randomTensorMesh: Interpolation Ex
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 1.96e-01 |
- 16 | 7.36e-02 | 2.6702 | 1.5661
- 32 | 1.11e-02 | 6.6531 | 2.2469
- 64 | 2.73e-03 | 4.0452 | 2.0076
+ 8 | 2.52e-01 |
+ 16 | 2.58e-02 | 9.7516 | 5.3251
+ 32 | 1.69e-02 | 1.5285 | 0.4736
+ 64 | 3.83e-03 | 4.4134 | 2.6664
---------------------------------------------
- Testing is important.
+ You deserve a pat on the back!
@@ -1084,24 +1077,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.04e-02 |
- 16 | 1.88e-02 | 3.7349 | 1.9011
- 32 | 4.66e-03 | 4.0418 | 2.0150
- 64 | 1.15e-03 | 4.0491 | 2.0176
+ 8 | 7.03e-02 |
+ 16 | 1.83e-02 | 3.8430 | 1.9422
+ 32 | 4.72e-03 | 3.8783 | 1.9554
+ 64 | 1.17e-03 | 4.0244 | 2.0088
---------------------------------------------
- And then everyone was happy.
+ Yay passed!
randomTensorMesh: Interpolation Ey
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 1.85e-01 |
- 16 | 4.54e-02 | 4.0706 | 3.4078
- 32 | 1.48e-02 | 3.0575 | 1.2728
- 64 | 3.48e-03 | 4.2700 | 2.0226
+ 8 | 7.70e-02 |
+ 16 | 2.92e-02 | 2.6359 | 2.0836
+ 32 | 1.66e-02 | 1.7612 | 0.7062
+ 64 | 3.79e-03 | 4.3764 | 2.5121
---------------------------------------------
- That was easy!
+ Well done Rowan!
@@ -1132,24 +1125,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.03e-02 |
- 16 | 1.85e-02 | 3.8002 | 1.9261
- 32 | 4.79e-03 | 3.8649 | 1.9504
- 64 | 1.16e-03 | 4.1181 | 2.0420
+ 8 | 7.04e-02 |
+ 16 | 1.87e-02 | 3.7587 | 1.9102
+ 32 | 4.79e-03 | 3.9106 | 1.9674
+ 64 | 1.17e-03 | 4.1061 | 2.0378
---------------------------------------------
- Once upon a time, a happy little test passed.
+ You are awesome.
randomTensorMesh: Interpolation Ez
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.18e-02 |
- 16 | 3.34e-02 | 2.1510 | 1.1488
- 32 | 1.14e-02 | 2.9219 | 1.2972
- 64 | 2.75e-03 | 4.1557 | 2.4585
+ 8 | 1.56e-01 |
+ 16 | 3.70e-02 | 4.2142 | 1.7123
+ 32 | 1.16e-02 | 3.1865 | 1.2409
+ 64 | 4.18e-03 | 2.7767 | 1.8503
---------------------------------------------
- And then everyone was happy.
+ That was easy!
@@ -1180,24 +1173,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.25e-02 |
- 16 | 1.72e-02 | 4.2196 | 2.0771
- 32 | 4.48e-03 | 3.8373 | 1.9401
- 64 | 1.12e-03 | 3.9989 | 1.9996
+ 8 | 7.56e-02 |
+ 16 | 1.87e-02 | 4.0396 | 2.0142
+ 32 | 4.52e-03 | 4.1409 | 2.0499
+ 64 | 1.19e-03 | 3.8144 | 1.9315
---------------------------------------------
- Happy little convergence test!
+ The test be workin!
randomTensorMesh: Interpolation Fx
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 9.21e-02 |
- 16 | 4.74e-02 | 1.9431 | 0.7643
- 32 | 1.14e-02 | 4.1492 | 2.4749
- 64 | 4.04e-03 | 2.8256 | 2.0054
+ 8 | 4.85e-02 |
+ 16 | 3.26e-02 | 1.4891 | 0.4457
+ 32 | 7.59e-03 | 4.2884 | 2.0210
+ 64 | 2.21e-03 | 3.4371 | 2.3960
---------------------------------------------
- That was easy!
+ Go Test Go!
@@ -1228,24 +1221,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.60e-02 |
- 16 | 1.91e-02 | 3.9776 | 1.9919
- 32 | 4.71e-03 | 4.0535 | 2.0192
- 64 | 1.17e-03 | 4.0214 | 2.0077
+ 8 | 7.55e-02 |
+ 16 | 1.86e-02 | 4.0668 | 2.0239
+ 32 | 4.25e-03 | 4.3625 | 2.1252
+ 64 | 1.12e-03 | 3.7855 | 1.9205
---------------------------------------------
- Yay passed!
+ Once upon a time, a happy little test passed.
randomTensorMesh: Interpolation Fy
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 9.66e-02 |
- 16 | 3.13e-02 | 3.0829 | 2.0124
- 32 | 1.05e-02 | 2.9896 | 1.2264
- 64 | 2.26e-03 | 4.6440 | 2.4746
+ 8 | 1.26e-01 |
+ 16 | 5.43e-02 | 2.3127 | 1.1973
+ 32 | 6.95e-03 | 7.8090 | 3.7839
+ 64 | 2.07e-03 | 3.3670 | 1.4675
---------------------------------------------
- The test be workin!
+ You get a gold star!
@@ -1276,22 +1269,22 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.54e-02 |
- 16 | 1.84e-02 | 4.0848 | 2.0303
- 32 | 4.36e-03 | 4.2284 | 2.0801
- 64 | 1.20e-03 | 3.6481 | 1.8671
+ 8 | 7.56e-02 |
+ 16 | 1.87e-02 | 4.0457 | 2.0164
+ 32 | 4.58e-03 | 4.0787 | 2.0281
+ 64 | 1.19e-03 | 3.8390 | 1.9407
---------------------------------------------
- Yay passed!
+ You are awesome.
randomTensorMesh: Interpolation Fz
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 5.96e-02 |
- 16 | 2.18e-02 | 2.7361 | 1.5629
- 32 | 8.92e-03 | 2.4404 | 1.7604
- 64 | 3.75e-03 | 2.3769 | 1.2017
+ 8 | 1.17e-01 |
+ 16 | 2.69e-02 | 4.3374 | 2.1585
+ 32 | 1.64e-02 | 1.6402 | 0.8257
+ 64 | 3.86e-03 | 4.2449 | 1.7674
---------------------------------------------
Happy little convergence test!
@@ -1324,24 +1317,24 @@ Test Results
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 7.00e-02 |
- 16 | 1.86e-02 | 3.7692 | 1.9142
- 32 | 4.70e-03 | 3.9513 | 1.9823
- 64 | 1.17e-03 | 4.0254 | 2.0091
+ 8 | 7.04e-02 |
+ 16 | 1.86e-02 | 3.7784 | 1.9178
+ 32 | 4.78e-03 | 3.8981 | 1.9628
+ 64 | 1.20e-03 | 3.9741 | 1.9906
---------------------------------------------
- That was easy!
+ The test be workin!
randomTensorMesh: Interpolation N
_____________________________________________
h | error | e(i-1)/e(i) | order
~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~~~~|~~~~~~~~~~
- 8 | 1.27e-01 |
- 16 | 1.71e-02 | 7.4252 | 3.9214
- 32 | 1.11e-02 | 1.5418 | 0.8132
- 64 | 4.00e-03 | 2.7731 | 1.3231
+ 8 | 1.78e-01 |
+ 16 | 3.66e-02 | 4.8776 | 3.1782
+ 32 | 1.61e-02 | 2.2707 | 1.1549
+ 64 | 3.17e-03 | 5.0740 | 2.0894
---------------------------------------------
- And then everyone was happy.
+ Happy little convergence test!
@@ -1433,7 +1426,7 @@ Test Results
16 | 2.42e-03 |
32 | 6.06e-04 | 4.0001 | 2.0000
---------------------------------------------
- You are awesome.
+ Happy little convergence test!
uniformLOM: Edge Inner Product - Isotropic
@@ -1443,7 +1436,7 @@ Test Results
16 | 2.42e-03 |
32 | 6.06e-04 | 4.0001 | 2.0000
---------------------------------------------
- Testing is important.
+ Once upon a time, a happy little test passed.
rotateLOM: Edge Inner Product - Isotropic
@@ -1453,7 +1446,7 @@ Test Results
16 | 2.81e-03 |
32 | 7.11e-04 | 3.9432 | 1.9794
---------------------------------------------
- Yay passed!
+ You deserve a pat on the back!
@@ -1487,7 +1480,7 @@ Test Results
16 | 6.29e-04 |
32 | 1.57e-04 | 3.9978 | 1.9992
---------------------------------------------
- Yay passed!
+ Testing is important.
uniformLOM: Face Inner Product - Isotropic
@@ -1497,7 +1490,7 @@ Test Results
16 | 6.29e-04 |
32 | 1.57e-04 | 3.9978 | 1.9992
---------------------------------------------
- You get a gold star!
+ And then everyone was happy.
rotateLOM: Face Inner Product - Isotropic
@@ -1507,7 +1500,7 @@ Test Results
16 | 3.08e-04 |
32 | 7.07e-05 | 4.3564 | 2.1231
---------------------------------------------
- You get a gold star!
+ Not just a pretty face Rowan
@@ -1541,7 +1534,7 @@ Test Results
16 | 6.99e-03 |
32 | 1.75e-03 | 3.9996 | 1.9998
---------------------------------------------
- And then everyone was happy.
+ That was easy!
uniformLOM: Edge Inner Product - Anisotropic
@@ -1551,7 +1544,7 @@ Test Results
16 | 6.99e-03 |
32 | 1.75e-03 | 3.9996 | 1.9998
---------------------------------------------
- The test be workin!
+ You get a gold star!
rotateLOM: Edge Inner Product - Anisotropic
@@ -1561,7 +1554,7 @@ Test Results
16 | 7.70e-03 |
32 | 1.94e-03 | 3.9622 | 1.9863
---------------------------------------------
- The test be workin!
+ Happy little convergence test!
@@ -1595,7 +1588,7 @@ Test Results
16 | 2.68e-03 |
32 | 6.69e-04 | 3.9982 | 1.9993
---------------------------------------------
- Yay passed!
+ And then everyone was happy.
uniformLOM: Face Inner Product - Anisotropic
@@ -1605,7 +1598,7 @@ Test Results
16 | 2.68e-03 |
32 | 6.69e-04 | 3.9982 | 1.9993
---------------------------------------------
- Happy little convergence test!
+ Yay passed!
rotateLOM: Face Inner Product - Anisotropic
@@ -1615,7 +1608,7 @@ Test Results
16 | 2.15e-03 |
32 | 5.25e-04 | 4.0845 | 2.0302
---------------------------------------------
- Go Test Go!
+ Yay passed!
@@ -1649,7 +1642,7 @@ Test Results
16 | 6.79e-03 |
32 | 1.70e-03 | 3.9996 | 1.9998
---------------------------------------------
- You are awesome.
+ The test be workin!
uniformLOM: Edge Inner Product - Full Tensor
@@ -1659,7 +1652,7 @@ Test Results
16 | 6.79e-03 |
32 | 1.70e-03 | 3.9996 | 1.9998
---------------------------------------------
- Go Test Go!
+ And then everyone was happy.
rotateLOM: Edge Inner Product - Full Tensor
@@ -1669,7 +1662,7 @@ Test Results
16 | 7.49e-03 |
32 | 1.89e-03 | 3.9617 | 1.9861
---------------------------------------------
- That was easy!
+ The test be workin!
@@ -1703,7 +1696,7 @@ Test Results
16 | 3.10e-03 |
32 | 7.74e-04 | 3.9981 | 1.9993
---------------------------------------------
- Yay passed!
+ You get a gold star!
uniformLOM: Face Inner Product - Full Tensor
@@ -1713,7 +1706,7 @@ Test Results
16 | 3.10e-03 |
32 | 7.74e-04 | 3.9981 | 1.9993
---------------------------------------------
- Happy little convergence test!
+ The test be workin!
rotateLOM: Face Inner Product - Full Tensor
@@ -1723,7 +1716,7 @@ Test Results
16 | 2.54e-03 |
32 | 6.23e-04 | 4.0741 | 2.0265
---------------------------------------------
- That was easy!
+ You deserve a pat on the back!
@@ -1770,7 +1763,7 @@ Test Results
64 | 2.18e-02 | 4.0001 | 2.0000
128 | 5.46e-03 | 4.0000 | 2.0000
---------------------------------------------
- And then everyone was happy.
+ The test be workin!
uniformLOM: 2D Edge Inner Product - Isotropic
@@ -1784,7 +1777,7 @@ Test Results
64 | 2.18e-02 | 4.0001 | 2.0000
128 | 5.46e-03 | 4.0000 | 2.0000
---------------------------------------------
- And then everyone was happy.
+ You get a gold star!
rotateLOM: 2D Edge Inner Product - Isotropic
@@ -1798,7 +1791,7 @@ Test Results
64 | 2.00e-02 | 4.0155 | 2.0056
128 | 5.00e-03 | 4.0038 | 2.0014
---------------------------------------------
- Go Test Go!
+ You are awesome.
@@ -1836,7 +1829,7 @@ Test Results
64 | 2.53e-02 | 4.0000 | 2.0000
128 | 6.32e-03 | 4.0000 | 2.0000
---------------------------------------------
- Yay passed!
+ Happy little convergence test!
uniformLOM: 2D Face Inner Product - Isotropic
@@ -1850,7 +1843,7 @@ Test Results
64 | 2.53e-02 | 4.0000 | 2.0000
128 | 6.32e-03 | 4.0000 | 2.0000
---------------------------------------------
- Yay passed!
+ Not just a pretty face Rowan
rotateLOM: 2D Face Inner Product - Isotropic
@@ -1864,7 +1857,7 @@ Test Results
64 | 2.30e-02 | 4.0132 | 2.0048
128 | 5.74e-03 | 4.0009 | 2.0003
---------------------------------------------
- You get a gold star!
+ That was easy!
@@ -1902,7 +1895,7 @@ Test Results
64 | 1.30e-01 | 4.0000 | 2.0000
128 | 3.24e-02 | 4.0000 | 2.0000
---------------------------------------------
- Once upon a time, a happy little test passed.
+ That was easy!
uniformLOM: 2D Face Inner Product - Anisotropic
@@ -1916,7 +1909,7 @@ Test Results
64 | 1.30e-01 | 4.0000 | 2.0000
128 | 3.24e-02 | 4.0000 | 2.0000
---------------------------------------------
- Testing is important.
+ Go Test Go!
rotateLOM: 2D Face Inner Product - Anisotropic
@@ -1930,7 +1923,7 @@ Test Results
64 | 1.28e-01 | 4.0007 | 2.0003
128 | 3.19e-02 | 3.9975 | 1.9991
---------------------------------------------
- That was easy!
+ You are awesome.
@@ -1968,7 +1961,7 @@ Test Results
64 | 3.66e-02 | 4.0000 | 2.0000
128 | 9.14e-03 | 4.0000 | 2.0000
---------------------------------------------
- Yay passed!
+ Not just a pretty face Rowan
uniformLOM: 2D Edge Inner Product - Anisotropic
@@ -1982,7 +1975,7 @@ Test Results
64 | 3.66e-02 | 4.0000 | 2.0000
128 | 9.14e-03 | 4.0000 | 2.0000
---------------------------------------------
- You are awesome.
+ Well done Rowan!
rotateLOM: 2D Edge Inner Product - Anisotropic
@@ -2048,7 +2041,7 @@ Test Results
64 | 1.52e-01 | 4.0000 | 2.0000
128 | 3.80e-02 | 4.0000 | 2.0000
---------------------------------------------
- Happy little convergence test!
+ Awesome, Rowan, just awesome.
rotateLOM: 2D Face Inner Product - Full Tensor
@@ -2062,7 +2055,7 @@ Test Results
64 | 1.45e-01 | 4.0074 | 2.0027
128 | 3.62e-02 | 3.9984 | 1.9994
---------------------------------------------
- Testing is important.
+ You deserve a pat on the back!
@@ -2100,7 +2093,7 @@ Test Results
64 | 3.78e-03 | 4.0001 | 2.0000
128 | 9.46e-04 | 4.0000 | 2.0000
---------------------------------------------
- You are awesome.
+ Not just a pretty face Rowan
uniformLOM: 2D Edge Inner Product - Full Tensor
@@ -2114,7 +2107,7 @@ Test Results
64 | 3.78e-03 | 4.0001 | 2.0000
128 | 9.46e-04 | 4.0000 | 2.0000
---------------------------------------------
- Happy little convergence test!
+ Testing is important.
rotateLOM: 2D Edge Inner Product - Full Tensor
@@ -2128,7 +2121,7 @@ Test Results
64 | 1.98e-02 | 3.8708 | 1.9526
128 | 5.03e-03 | 3.9418 | 1.9789
---------------------------------------------
- You get a gold star!
+ Happy little convergence test!
@@ -2173,7 +2166,7 @@ Test Results
16 | 4.45e-04 | 3.9561 | 1.9841
32 | 1.12e-04 | 3.9799 | 1.9927
---------------------------------------------
- Testing is important.
+ Yay passed!
uniformLOM: Averaging 2D: E2CC
@@ -2185,7 +2178,7 @@ Test Results
16 | 4.45e-04 | 3.9561 | 1.9841
32 | 1.12e-04 | 3.9799 | 1.9927
---------------------------------------------
- And then everyone was happy.
+ That was easy!
rotateLOM: Averaging 2D: E2CC
@@ -2197,7 +2190,7 @@ Test Results
16 | 4.66e-04 | 3.8970 | 1.9624
32 | 1.18e-04 | 3.9552 | 1.9837
---------------------------------------------
- Happy little convergence test!
+ Go Test Go!
@@ -2233,7 +2226,7 @@ Test Results
16 | 4.45e-04 | 3.9561 | 1.9841
32 | 1.12e-04 | 3.9799 | 1.9927
---------------------------------------------
- Yay passed!
+ Once upon a time, a happy little test passed.
uniformLOM: Averaging 2D: F2CC
@@ -2245,7 +2238,7 @@ Test Results
16 | 4.45e-04 | 3.9561 | 1.9841
32 | 1.12e-04 | 3.9799 | 1.9927
---------------------------------------------
- The test be workin!
+ Go Test Go!
rotateLOM: Averaging 2D: F2CC
@@ -2257,7 +2250,7 @@ Test Results
16 | 4.66e-04 | 3.8970 | 1.9624
32 | 1.18e-04 | 3.9552 | 1.9837
---------------------------------------------
- Testing is important.
+ The test be workin!
@@ -2293,7 +2286,7 @@ Test Results
16 | 8.90e-04 | 3.9561 | 1.9841
32 | 2.24e-04 | 3.9799 | 1.9927
---------------------------------------------
- Go Test Go!
+ Well done Rowan!
uniformLOM: Averaging 2D: N2CC
@@ -2305,7 +2298,7 @@ Test Results
16 | 8.90e-04 | 3.9561 | 1.9841
32 | 2.24e-04 | 3.9799 | 1.9927
---------------------------------------------
- And then everyone was happy.
+ That was easy!
rotateLOM: Averaging 2D: N2CC
@@ -2317,7 +2310,7 @@ Test Results
16 | 9.33e-04 | 3.8980 | 1.9627
32 | 2.36e-04 | 3.9577 | 1.9847
---------------------------------------------
- Testing is important.
+ That was easy!
@@ -2353,7 +2346,7 @@ Test Results
16 | 4.88e-04 | 3.9932 | 1.9975
32 | 1.22e-04 | 3.9983 | 1.9994
---------------------------------------------
- You are awesome.
+ Happy little convergence test!
uniformLOM: Averaging 2D: N2E
@@ -2365,7 +2358,7 @@ Test Results
16 | 4.88e-04 | 3.9932 | 1.9975
32 | 1.22e-04 | 3.9983 | 1.9994
---------------------------------------------
- Go Test Go!
+ That was easy!
rotateLOM: Averaging 2D: N2E
@@ -2377,7 +2370,7 @@ Test Results
16 | 7.34e-04 | 3.7229 | 1.8964
32 | 1.86e-04 | 3.9505 | 1.9820
---------------------------------------------
- Once upon a time, a happy little test passed.
+ You deserve a pat on the back!
@@ -2413,7 +2406,7 @@ Test Results
16 | 4.88e-04 | 3.9932 | 1.9975
32 | 1.22e-04 | 3.9983 | 1.9994
---------------------------------------------
- And then everyone was happy.
+ Testing is important.
uniformLOM: Averaging 2D: N2F
@@ -2425,7 +2418,7 @@ Test Results
16 | 4.88e-04 | 3.9932 | 1.9975
32 | 1.22e-04 | 3.9983 | 1.9994
---------------------------------------------
- That was easy!
+ And then everyone was happy.
rotateLOM: Averaging 2D: N2F
@@ -2437,7 +2430,7 @@ Test Results
16 | 7.34e-04 | 3.7229 | 1.8964
32 | 1.86e-04 | 3.9505 | 1.9820
---------------------------------------------
- Once upon a time, a happy little test passed.
+ Yay passed!
@@ -2482,7 +2475,7 @@ Test Results
16 | 6.63e-04 | 3.7311 | 1.8996
32 | 1.71e-04 | 3.8674 | 1.9514
---------------------------------------------
- The test be workin!
+ Go Test Go!
uniformLOM: Averaging 3D: E2CC
@@ -2494,7 +2487,7 @@ Test Results
16 | 6.63e-04 | 3.7311 | 1.8996
32 | 1.71e-04 | 3.8674 | 1.9514
---------------------------------------------
- And then everyone was happy.
+ Once upon a time, a happy little test passed.
rotateLOM: Averaging 3D: E2CC
@@ -2542,7 +2535,7 @@ Test Results
16 | 3.32e-04 | 3.7311 | 1.8996
32 | 8.57e-05 | 3.8674 | 1.9514
---------------------------------------------
- The test be workin!
+ Once upon a time, a happy little test passed.
uniformLOM: Averaging 3D: F2CC
@@ -2554,7 +2547,7 @@ Test Results
16 | 3.32e-04 | 3.7311 | 1.8996
32 | 8.57e-05 | 3.8674 | 1.9514
---------------------------------------------
- The test be workin!
+ You deserve a pat on the back!
rotateLOM: Averaging 3D: F2CC
@@ -2566,7 +2559,7 @@ Test Results
16 | 3.88e-04 | 3.2842 | 1.7155
32 | 1.04e-04 | 3.7417 | 1.9037
---------------------------------------------
- Happy little convergence test!
+ You deserve a pat on the back!
@@ -2602,7 +2595,7 @@ Test Results
16 | 9.95e-04 | 3.7311 | 1.8996
32 | 2.57e-04 | 3.8674 | 1.9514
---------------------------------------------
- The test be workin!
+ Happy little convergence test!
uniformLOM: Averaging 3D: N2CC
@@ -2614,7 +2607,7 @@ Test Results
16 | 9.95e-04 | 3.7311 | 1.8996
32 | 2.57e-04 | 3.8674 | 1.9514
---------------------------------------------
- You are awesome.
+ Once upon a time, a happy little test passed.
rotateLOM: Averaging 3D: N2CC
@@ -2626,7 +2619,7 @@ Test Results
16 | 1.17e-03 | 3.2862 | 1.7164
32 | 3.11e-04 | 3.7413 | 1.9036
---------------------------------------------
- You are awesome.
+ Well done Rowan!
@@ -2662,7 +2655,7 @@ Test Results
16 | 1.29e-03 | 3.8779 | 1.9553
32 | 3.27e-04 | 3.9382 | 1.9775
---------------------------------------------
- That was easy!
+ Once upon a time, a happy little test passed.
uniformLOM: Averaging 3D: N2E
@@ -2674,7 +2667,7 @@ Test Results
16 | 1.29e-03 | 3.8779 | 1.9553
32 | 3.27e-04 | 3.9382 | 1.9775
---------------------------------------------
- You get a gold star!
+ Awesome, Rowan, just awesome.
rotateLOM: Averaging 3D: N2E
@@ -2686,7 +2679,7 @@ Test Results
16 | 1.70e-03 | 3.5908 | 1.8443
32 | 4.41e-04 | 3.8566 | 1.9473
---------------------------------------------
- And then everyone was happy.
+ Well done Rowan!
@@ -2722,7 +2715,7 @@ Test Results
16 | 1.27e-03 | 3.8285 | 1.9368
32 | 3.25e-04 | 3.9144 | 1.9688
---------------------------------------------
- Happy little convergence test!
+ Well done Rowan!
uniformLOM: Averaging 3D: N2F
@@ -2746,7 +2739,7 @@ Test Results
16 | 1.49e-03 | 3.6148 | 1.8539
32 | 3.92e-04 | 3.7997 | 1.9259
---------------------------------------------
- You get a gold star!
+ Yay passed!
@@ -2791,7 +2784,7 @@ Test Results
16 | 3.95e-02 | 3.7462 | 1.9054
32 | 1.00e-02 | 3.9364 | 1.9769
---------------------------------------------
- That was easy!
+ You are awesome.
uniformLOM: Curl
@@ -2803,7 +2796,7 @@ Test Results
16 | 3.95e-02 | 3.7462 | 1.9054
32 | 1.00e-02 | 3.9364 | 1.9769
---------------------------------------------
- The test be workin!
+ Go Test Go!
rotateLOM: Curl
@@ -2815,7 +2808,7 @@ Test Results
16 | 1.70e-02 | 5.2040 | 2.3796
32 | 3.77e-03 | 4.5126 | 2.1740
---------------------------------------------
- The test be workin!
+ Happy little convergence test!
@@ -2859,7 +2852,7 @@ Test Results
16 | 1.19e-01 | 3.7462 | 1.9054
32 | 3.01e-02 | 3.9364 | 1.9769
---------------------------------------------
- Yay passed!
+ You deserve a pat on the back!
uniformLOM: Face Divergence
@@ -2870,7 +2863,7 @@ Test Results
16 | 1.19e-01 | 3.7462 | 1.9054
32 | 3.01e-02 | 3.9364 | 1.9769
---------------------------------------------
- And then everyone was happy.
+ The test be workin!
rotateLOM: Face Divergence
@@ -2881,7 +2874,7 @@ Test Results
16 | 9.53e-04 | 9.5374 | 3.2536
32 | 2.75e-04 | 3.4594 | 1.7905
---------------------------------------------
- You are awesome.
+ Go Test Go!
@@ -2926,7 +2919,7 @@ Test Results
32 | 2.01e-02 | 3.9364 | 1.9769
64 | 5.04e-03 | 3.9841 | 1.9943
---------------------------------------------
- You get a gold star!
+ Yay passed!
uniformLOM: Face Divergence 2D
@@ -2938,7 +2931,7 @@ Test Results
32 | 2.01e-02 | 3.9364 | 1.9769
64 | 5.04e-03 | 3.9841 | 1.9943
---------------------------------------------
- Once upon a time, a happy little test passed.
+ Yay passed!
rotateLOM: Face Divergence 2D
@@ -2950,7 +2943,7 @@ Test Results
32 | 2.01e-02 | 3.9364 | 1.9769
64 | 5.57e-03 | 3.6062 | 1.8505
---------------------------------------------
- Testing is important.
+ And then everyone was happy.
@@ -2995,7 +2988,7 @@ Test Results
16 | 1.34e-04 | 3.9116 | 1.9678
32 | 3.39e-05 | 3.9578 | 1.9847
---------------------------------------------
- You are awesome.
+ You get a gold star!
uniformLOM: Nodal Gradient
@@ -3007,7 +3000,7 @@ Test Results
16 | 1.34e-04 | 3.9116 | 1.9678
32 | 3.39e-05 | 3.9578 | 1.9847
---------------------------------------------
- Once upon a time, a happy little test passed.
+ Testing is important.
rotateLOM: Nodal Gradient
@@ -3064,7 +3057,7 @@ Test Results
16 | 1.34e-04 | 3.9116 | 1.9678
32 | 3.39e-05 | 3.9578 | 1.9847
---------------------------------------------
- Testing is important.
+ You are awesome.
uniformLOM: Nodal Gradient 2D
@@ -3076,7 +3069,7 @@ Test Results
16 | 1.34e-04 | 3.9116 | 1.9678
32 | 3.39e-05 | 3.9578 | 1.9847
---------------------------------------------
- That was easy!
+ The test be workin!
rotateLOM: Nodal Gradient 2D
@@ -3088,10 +3081,183 @@ Test Results
16 | 1.80e-04 | 3.6343 | 1.8617
32 | 4.64e-05 | 3.8804 | 1.9562
---------------------------------------------
- Yay passed!
+ Not just a pretty face Rowan
+
+ + + pt18.1: =========== Gauss Newton =========== + # f |proj(x-g)-x| LS + ----------------------------------- + 0 1.00e+00 2.00e+00 0 + 1 9.53e-01 1.34e+01 2 + 2 4.83e-01 1.19e+00 0 + 3 4.57e-01 1.31e+01 1 + 4 1.89e-01 5.75e-01 0 + 5 1.39e-01 8.15e+00 1 + 6 5.49e-02 5.04e-01 0 + 7 2.91e-02 2.73e+00 1 + 8 9.86e-03 1.37e+00 0 + 9 2.32e-03 1.15e+00 0 + 10 2.38e-04 2.52e-01 0 + 11 4.93e-06 6.73e-02 0 + ------------------------- STOP! ------------------------- + 1 : |fc-fOld| = 2.3305e-04 <= tolF*(1+|f0|) = 2.0000e-01 + 1 : |xc-x_last| = 2.8253e-02 <= tolX*(1+|x0|) = 1.0000e-01 + 1 : |proj(x-g)-x| = 6.7282e-02 <= tolG = 1.0000e-01 + 0 : |proj(x-g)-x| = 6.7282e-02 <= 1e3*eps = 1.0000e-02 + 0 : maxIter = 20 <= iter = 11 + ------------------------- DONE! ------------------------- + xopt: [ 0.99842987 0.99670531] + x_true: [ 1. 1.] + + ++
+ + pt18.2: =========== Gauss Newton =========== + # f |proj(x-g)-x| LS + ----------------------------------- + 0 0.00e+00 7.07e+00 0 + 1 -2.50e+01 0.00e+00 0 + ------------------------- STOP! ------------------------- + 0 : |fc-fOld| = 2.5000e+01 <= tolF*(1+|f0|) = 1.0000e-01 + 0 : |xc-x_last| = 7.0711e+00 <= tolX*(1+|x0|) = 1.0000e-01 + 1 : |proj(x-g)-x| = 0.0000e+00 <= tolG = 1.0000e-01 + 1 : |proj(x-g)-x| = 0.0000e+00 <= 1e3*eps = 1.0000e-02 + 0 : maxIter = 20 <= iter = 1 + ------------------------- DONE! ------------------------- + xopt: [ 5. 5.] + x_true: [ 5. 5.] + + ++
+ + pt18.3: ======================= Projected Gradient ======================= + # f |proj(x-g)-x| LS itType aSet bSet Comment + ------------------------------------------------------------------ + 0 0.00e+00 2.24e+00 0 SD 0 0 + 1 -8.50e+00 0.00e+00 0 SD 1 1 + ------------------------- STOP! ------------------------- + 0 : |fc-fOld| = 8.5000e+00 <= tolF*(1+|f0|) = 1.0000e-01 + 0 : |xc-x_last| = 2.2361e+00 <= tolX*(1+|x0|) = 1.0000e-01 + 1 : |proj(x-g)-x| = 0.0000e+00 <= tolG = 1.0000e-01 + 1 : |proj(x-g)-x| = 0.0000e+00 <= 1e3*eps = 1.0000e-02 + 0 : maxIter = 20 <= iter = 1 + 0 : probSize = 2 <= bindingSet = 1 + ------------------------- DONE! ------------------------- + xopt: [ 2. -1.] + x_true: [ 2. -1.] + + ++
+
+ pt18.4: ======================= Projected Gradient =======================
+ # f |proj(x-g)-x| LS itType aSet bSet Comment
+ ------------------------------------------------------------------
+ 0 0.00e+00 2.83e+00 0 SD 0 0
+ 1 -1.60e+01 0.00e+00 0 SD 2 2
+ ------------------------- STOP! -------------------------
+ 0 : |fc-fOld| = 1.6000e+01 <= tolF*(1+|f0|) = 1.0000e-01
+ 0 : |xc-x_last| = 2.8284e+00 <= tolX*(1+|x0|) = 1.0000e-01
+ 1 : |proj(x-g)-x| = 0.0000e+00 <= tolG = 1.0000e-01
+ 1 : |proj(x-g)-x| = 0.0000e+00 <= 1e3*eps = 1.0000e-02
+ 0 : maxIter = 20 <= iter = 1
+ 1 : probSize = 2 <= bindingSet = 2
+ ------------------------- DONE! -------------------------
+ xopt: [ 2. 2.]
+ x_true: [ 2. 2.]
+
+
- pt20.1:
+ pt21.1:
uniformTensorMesh: Poisson Equation - Backward
_____________________________________________
h | error | e(i-1)/e(i) | order
@@ -3235,7 +3421,7 @@ Test Results
20 | 7.96e-03 | 1.5342 | 1.9182
24 | 5.59e-03 | 1.4258 | 1.9458
---------------------------------------------
- Once upon a time, a happy little test passed.
+ Awesome, Rowan, just awesome.
@@ -3246,22 +3432,22 @@ Test Results
- pt20.2:
+ pt21.2:
uniformTensorMesh: Poisson Equation - Forward
_____________________________________________
h | error | e(i-1)/e(i) | order
@@ -3270,7 +3456,7 @@ Test Results
20 | 9.35e-01 | 1.5271 | 1.8974
24 | 6.58e-01 | 1.4223 | 1.9320
---------------------------------------------
- That was easy!
+ Not just a pretty face Rowan
@@ -3287,34 +3473,34 @@ Test Results
3
0
0
- Detail
+ Detail
- pt21.1: ==================== checkDerivative ====================
+ pt22.1: ==================== checkDerivative ====================
iter h |J0-Jt| |J0+h*dJ'*dx-Jt| Order
---------------------------------------------------------
- 0 1.00e-01 2.250e-01 4.500e-01 nan
- 1 1.00e-02 2.251e-02 4.501e-02 1.000
- 2 1.00e-03 2.250e-03 4.500e-03 1.000
- 3 1.00e-04 2.250e-04 4.500e-04 1.000
- 4 1.00e-05 2.250e-05 4.500e-05 1.000
- 5 1.00e-06 2.250e-06 4.500e-06 1.000
- 6 1.00e-07 2.250e-07 4.500e-07 1.000
+ 0 1.00e-01 1.967e-01 3.904e-01 nan
+ 1 1.00e-02 1.941e-02 3.880e-02 1.003
+ 2 1.00e-03 1.939e-03 3.877e-03 1.000
+ 3 1.00e-04 1.938e-04 3.876e-04 1.000
+ 4 1.00e-05 1.938e-05 3.876e-05 1.000
+ 5 1.00e-06 1.938e-06 3.876e-06 1.000
+ 6 1.00e-07 1.938e-07 3.876e-07 1.000
*********************************************************
<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>
*********************************************************
@@ -3329,33 +3515,33 @@ Test Results
- pt21.2: ==================== checkDerivative ====================
+ pt22.2: ==================== checkDerivative ====================
iter h |J0-Jt| |J0+h*dJ'*dx-Jt| Order
---------------------------------------------------------
- 0 1.00e-01 1.423e-01 1.342e-02 nan
- 1 1.00e-02 1.498e-02 1.291e-04 2.017
- 2 1.00e-03 1.505e-03 1.286e-06 2.002
- 3 1.00e-04 1.506e-04 1.285e-08 2.000
- 4 1.00e-05 1.506e-05 1.285e-10 2.000
- 5 1.00e-06 1.506e-06 1.285e-12 2.000
- 6 1.00e-07 1.506e-07 1.279e-14 2.002
+ 0 1.00e-01 1.210e-01 1.399e-03 nan
+ 1 1.00e-02 1.215e-02 1.279e-05 2.039
+ 2 1.00e-03 1.216e-03 1.269e-07 2.003
+ 3 1.00e-04 1.216e-04 1.268e-09 2.000
+ 4 1.00e-05 1.216e-05 1.268e-11 2.000
+ 5 1.00e-06 1.216e-06 1.267e-13 2.000
+ 6 1.00e-07 1.216e-07 1.249e-15 2.006
========================= PASS! =========================
- That was easy!
+ Well done Rowan!
@@ -3366,33 +3552,33 @@ Test Results
- pt21.3: ==================== checkDerivative ====================
+ pt22.3: ==================== checkDerivative ====================
iter h |J0-Jt| |J0+h*dJ'*dx-Jt| Order
---------------------------------------------------------
- 0 1.00e-01 1.025e-01 1.606e-02 nan
- 1 1.00e-02 1.080e-02 1.596e-04 2.003
- 2 1.00e-03 1.086e-03 1.595e-06 2.000
- 3 1.00e-04 1.087e-04 1.595e-08 2.000
- 4 1.00e-05 1.087e-05 1.595e-10 2.000
- 5 1.00e-06 1.087e-06 1.595e-12 2.000
- 6 1.00e-07 1.087e-07 1.604e-14 1.997
+ 0 1.00e-01 2.414e-01 4.527e-03 nan
+ 1 1.00e-02 2.393e-02 5.089e-05 1.949
+ 2 1.00e-03 2.390e-03 5.150e-07 1.995
+ 3 1.00e-04 2.390e-04 5.156e-09 1.999
+ 4 1.00e-05 2.390e-05 5.157e-11 2.000
+ 5 1.00e-06 2.390e-06 5.157e-13 2.000
+ 6 1.00e-07 2.390e-07 5.174e-15 1.999
========================= PASS! =========================
- And then everyone was happy.
+ Go Test Go!
@@ -3409,54 +3595,54 @@ Test Results
8
0
0
- Detail
+ Detail