Ipopt is a solver for convex problems that are twice differentiable. Your problem doesn’t meet these requirements, and it has a divide-by-zero issue when g(a,b) = 0.
You should consider other ways of formulating this problem (e.g., as a MIP maximizing f(a,b) - g(a,b) where g(a, b) >= 0.000001 using this reformulation of max: 9 Mixed integer optimization — MOSEK Modeling Cookbook 3.3.0).