# optimize vertices using a cost function on triangles

I want to optimize the vertex positions in a mesh, with a given cost function on the associated triangles. The paper gives a cost function, which evaluates to an real number by using a sum over the triangles in the mesh, which connect the vertices to a valid simplical complex. They suggest to use a L-BFGS solver and i want to use PETSc to for the calculations.

The solver interface for L-BFGS (and some other algorithms) in PETSc gets a vector with the current values and has a pointer to a output vector for the residual values, with the same cardinality.

How do i design the cost function and the residual vector based on the cost function to evaluate the cost of vertex positions based on the resulting triangles?

i filled the f vector like this: $[v_1^x, v_1^y, v_1^z, \dots, v_N^x, v_N^y, v_N^z]$.

What do it put in the vector returned to get a good solution? I tried ...

• all the same: $\text{cost}(v) \equiv cost \in \mathbb{R}\ \forall v$ (VecSet(r, cost).)
• $\text{cost}(v_i^x) = \text{cost}(v_i^y) = \text{cost}(v_i^z) = \sum_{t \in T, v_i\in t} \text{cost}(t)\ \forall i=1\dots N$ with $T$ as the set of all triangles and the relation $v \in t$ when $v$ is a vertex of a triangle $t$.

Both do not obtain good solutions. Further i guess the residual may need to differ in x,y,z to get useful gradients for moving the vertices.

• "The paper gives a cost function, which evaluates to an real number by using a sum over the triangles in the mesh, which are connecting the triangles to a valid simplex complex." What paper? – Geoff Oxberry Mar 2 '15 at 21:04
• What is the cost function you want to use?? – nicoguaro Mar 3 '15 at 0:49
• dl.acm.org/citation.cfm?id=2631978.2602143 section 6.2 – allo Mar 3 '15 at 12:11
• You already wrote the answer: the vector needs to have the residual in it. – Wolfgang Bangerth Mar 4 '15 at 0:16
• I am still not sure, how you would define this residual. I have a cost function and i may split it into cost functions for triangles. The per vertex residual is not directly defined. The cost function optimal solution would be zero. Now the value(s) of the cost function need to be split into residuals for the vertices. – allo Mar 4 '15 at 14:36