Thank you very much for the detailed explanation. I would in principle be interested in collaborating on adding such functionality to TAO, especially since robust handling of domain errors would be very valuable for PDE-constrained inverse problems.
That said, my experience with PETSc is mostly through petsc4py and some interfacing from deal.II, so I am not very familiar with the internals of TAO or the C-level API. I would therefore need some guidance on where such functionality should live inside the TAO infrastructure, and how similar mechanisms are implemented in SNES or TS. If you can point me to the relevant parts of the TAO codebase and outline the expected design (e.g., how the domain-error flag should propagate through the solver), I would be happy to explore how I could contribute. Thanks again for your support and for considering this extension to TAO. Best, Simon Am Do., 4. Dez. 2025 um 16:32 Uhr schrieb Barry Smith <[email protected]>: > Simon, > > Thanks for the question. We would love to have such functionality in > TAO, but we do not currently have it. > > For SNES, we provide SNESSetFunctionDomainError() and > SNESSetJacobianDomainError() which can be called (on any subset of the MPI > processes in the MPI communicator) to indicate such a domain error. > Currently, SNES simply checks this way (in a collective, friendly manner > without extra communication) and returns a clean > SNES_DIVERGED_FUNCTION_DOMAIN via the SNESConvergedReason. We would like > at least some of the SNES solvers to handle this better, as you suggest, by > backtracking to find a valid point in the domain. > > For TS we provide TSSetFunctionDomainError(), which allows the user to > pass in a function to check if a point is in the domain. It is currently > unused. I think it should use the same approach as SNES. > > So for TAO, I envision a similar TaoSetFunctionDomainError(), > TaoSetJacobianDomainError(), and TaoSetHessianDomainError(), which would > allow particular TAO solvers to "back off" but continue running as you > request. > > Would you be interested in collaborating with us on adding such support > to Tao? In particular, focusing exactly on the Tao solver algorithm you are > using? We don't currently have PETSc developers focusing on Tao, so can > only make progress on it by actively collaborating with others who need > new/improved functionality. > > > Barry > > > On Dec 4, 2025, at 3:03 AM, Simon Wiesheier <[email protected]> > wrote: > > Dear PETSc developers and users, > > I am considering using TAO’s Primal-Dual Interior-Point Method (PDIPM) for > a constrained optimization problem in solid mechanics. The objective > involves solving a nonlinear PDE (hyperelasticity) for each parameter > vector, and for some parameter combinations the PDE solver may fail to > converge or produce non-physical states. > > With MATLAB’s fmincon, it is possible to signal such failures by returning > NaN/Inf for the objective, and the solver will then backtrack or try a > different step without crashing. > > My questions are: > > 1. > > How does TAO’s PDIPM handle cases where the user objective or gradient > callback returns NaN/Inf (e.g., due to PDE solver failure)? > 2. > > Is there a recommended way in TAO/PETSc to gracefully signal an > evaluation failure (like “bad point in parameter space”) so that the > algorithm can back off and try a smaller step, instead of aborting? > 3. > > If the recommended pattern is *not* to return NaNs, what is the best > practice in TAO for such PDE-constrained problems? > > Any guidance on how TAO/PDIPM is intended to behave in the presence of > evaluation failures would be greatly appreciated. > > Best regards, > > Simon > > >
