# How to model a non-linear least-squares problem for triangles

I have a non-linear least-squares problem to solve and with my current modeling the solver is either very slow or does not converge to a correct solution.

For the problem I need to minimize an energy on a set of triangles, which is defined by

$$\sum_f E_d(f) + \sum_e E_s(e)$$ with faces given by their vertices $f=((u_1,v_1), (u_2,v_2), (u_3,v_3))$ and shared edges given by the vertices of both adjacent triangles $e=((u_1, v_1)_{T_{1}}, (u_2, v_2)_{T_{1}}, (u_2, v_2)_{T_{2}}, (u_2, v_2)_{T_{2}})$, where 1,2,3 are local indices for the triangle/edge and the vertices are from a common set $X = \{(u_1, v_1), \dots, (u_{|V|}, v_{|V|})\}$.

The edge indices are defined such that for the inner edges of a manifold mesh holds $(u_1, v_1)_{T_{1}}=(u_1, v_1)_{T_{2}},\ (u_2, v_2)_{T_{1}}=(u_2, v_2)_{T_{2}}$.

I am using the ceres solver using the line search algorithm and modeling the problem as two residual blocks of size $|F|$ and $|E|$, defined by

$$\vec{E}_f(\vec{X}) = (E_f(f_1), \dots, E_f(f_{|F|})) \\ \vec{E}_s(\vec{X}) = (E_s(e_1), \dots, E_s(e_{|E|}))$$

This works for many inputs, but is converging slowly and sometimes to local minima.

To model it using more blocks, I tried to create one block per triangle and one block per edge, leading to one block per face and one block per edge having only one residual

$$E_{f_i}(\vec{X}) = E_f(f_i) \\ E_{e_j}(\vec{X}) = E_s(e_j) \\$$

where $E_{f_i}$ and $E_{e_j}$ are only depending on the 6 respectively 8 values which are relevant for their energy, which should result in a sparse problem which is hopefully fast to solve.

As far as I understood the problem modeling in the ceres solver, modeling the problem this way should be possible and probably the faster way to solve it, but I get totally different results and the result of the modeling using separate blocks seems completely wrong.

What can be my problem here and what is the best way to model such aproblem for fast solving?

(The problem is based on the methods in the autocuts parametrization paper. The solving process there is iterated a few times sharpening a smoothing term in $E_s$, but the question is only about a single iteration.)