Quasi-optimal least squares: inhomogeneous boundary conditions, and application with machine learning | Synapse