def __init__(self, ssarun, method): """ :param ssarun: The :class:`PISM.invert.ssa.SSAForwardRun` defining the forward problem. :param method: String describing the actual algorithm to use. Must be a key in :attr:`tao_types`.""" InvSSASolver.__init__(self, ssarun, method) self.listeners = [] self.solver = None self.ip = None if self.tao_types.get(method) is None: raise ValueError("Unknown TAO Tikhonov inversion method: %s" % method)
def __init__(self, ssarun, method): """ :param ssarun: The :class:`PISM.ssa.SSARun` defining the forward problem. See :class:`PISM.inv_ssa.SSAForwardRunFromInputFile`. :param method: String describing the actual ``siple`` algorithm to use. One of ``sd``, ``nlcg`` or ``ign``.""" InvSSASolver.__init__(self, ssarun, method) self.target_misfit = PISM.optionsReal("-inv_target_misfit", "m/year; desired root misfit for inversions", default=None) monitor_adjoint = PISM.optionsFlag("-inv_monitor_adjoint", "Track accuracy of the adjoint during computation", default=False) morozov_scale_factor = PISM.optionsFlag("-inv_morozov_scale", "Scale factor (>=1) for Morozov discrepancy principle", default=1.0) ls_verbose = PISM.optionsFlag("-inv_ls_verbose", "Turn on a verbose linesearch.", default=False) ign_theta = PISM.optionsReal("-ign_theta", "theta parameter for IGN algorithm", default=0.5) max_it = PISM.optionsInt("-inv_max_it", "maximum iteration count", default=1000) if self.target_misfit is None: raise RuntimeError("Missing required option -inv_target_misfit") velocity_scale = ssarun.grid.ctx().config().get_double("inv_ssa_velocity_scale", "m/year") self.target_misfit /= velocity_scale self.forward_problem = SSAForwardProblem(ssarun) # Determine the inversion algorithm, and set up its arguments. if self.method == "ign": Solver = InvertSSAIGN else: Solver = InvertSSANLCG self.u_i = None self.zeta_i = None params = Solver.defaultParameters() params.ITER_MAX = max_it if self.method == "sd": params.steepest_descent = True params.ITER_MAX = 10000 elif self.method == "ign": params.linearsolver.ITER_MAX = 10000 params.linearsolver.verbose = True if ls_verbose: params.linesearch.verbose = True params.verbose = True params.thetaMax = ign_theta params.mu = morozov_scale_factor params.deriv_eps = 0. self.siple_solver = Solver(self.forward_problem, params=params) if monitor_adjoint: self.addIterationListener(MonitorAdjoint()) if self.method == 'ign': self.addLinearIterationListener(MonitorAdjointLin())
def __init__(self, ssarun, method): """ :param ssarun: The :class:`PISM.ssa.SSARun` defining the forward problem. See :class:`PISM.inv_ssa.SSAForwardRunFromInputFile`. :param method: String describing the actual ``siple`` algorithm to use. One of ``sd``, ``nlcg`` or ``ign``.""" InvSSASolver.__init__(self, ssarun, method) self.target_misfit = PISM.optionsReal("-inv_target_misfit", "m/year; desired root misfit for inversions", default=None) monitor_adjoint = PISM.optionsFlag("-inv_monitor_adjoint", "Track accuracy of the adjoint during computation", default=False) morozov_scale_factor = PISM.optionsFlag("-inv_morozov_scale", "Scale factor (>=1) for Morozov discrepancy principle", default=1.0) ls_verbose = PISM.optionsFlag("-inv_ls_verbose", "Turn on a verbose linesearch.", default=False) ign_theta = PISM.optionsReal("-ign_theta", "theta parameter for IGN algorithm", default=0.5) max_it = PISM.optionsInt("-inv_max_it", "maximum iteration count", default=1000) if self.target_misfit is None: raise RuntimeError("Missing required option -inv_target_misfit") velocity_scale = ssarun.grid.ctx().config().get_double("inverse.ssa.velocity_scale", "m/year") self.target_misfit /= velocity_scale self.forward_problem = SSAForwardProblem(ssarun) # Determine the inversion algorithm, and set up its arguments. if self.method == "ign": Solver = InvertSSAIGN else: Solver = InvertSSANLCG self.u_i = None self.zeta_i = None params = Solver.defaultParameters() params.ITER_MAX = max_it if self.method == "sd": params.steepest_descent = True params.ITER_MAX = 10000 elif self.method == "ign": params.linearsolver.ITER_MAX = 10000 params.linearsolver.verbose = True if ls_verbose: params.linesearch.verbose = True params.verbose = True params.thetaMax = ign_theta params.mu = morozov_scale_factor params.deriv_eps = 0. self.siple_solver = Solver(self.forward_problem, params=params) if monitor_adjoint: self.addIterationListener(MonitorAdjoint()) if self.method == 'ign': self.addLinearIterationListener(MonitorAdjointLin())
def __init__(self, ssarun, method): self.solver = None InvSSASolver.__init__(self, ssarun, method) self.target_misfit = PISM.optionsFlag("-inv_target_misfit", "m/year; desired root misfit for inversions", default=None) if self.target_misfit is None: raise RuntimeError("Missing required option -inv_target_misfit") # FIXME: m_vel_scale is not defined (what are the units?) self.target_misfit = self.target_misfit / m_vel_scale self.listeners = []
def __init__(self, ssarun, method): self.solver = None InvSSASolver.__init__(self, ssarun, method) target_misfit = PISM.OptionReal("-inv_target_misfit", "m/year; desired root misfit for inversions", 0.0) if target_misfit.is_set(): self.target_misfit = target_misfit.value() else: raise RuntimeError("Missing required option -inv_target_misfit") # FIXME: m_vel_scale is not defined (what are the units?) self.target_misfit = self.target_misfit / m_vel_scale self.listeners = []
def __init__(self, ssarun, method): self.solver = None InvSSASolver.__init__(self, ssarun, method) target_misfit = PISM.OptionReal( "-inv_target_misfit", "m/year; desired root misfit for inversions", 0.0) if target_misfit.is_set(): self.target_misfit = target_misfit.value() else: raise RuntimeError("Missing required option -inv_target_misfit") # FIXME: m_vel_scale is not defined (what are the units?) self.target_misfit = self.target_misfit / m_vel_scale self.listeners = []