I’m looking for code that is well-suited to solving a fairly simple minimization problem:
I have a reference point $\mathbf p$ in 3D space, and I want to minimize $\|\mathbf x - \mathbf p\|^2$ subject to a constraint $F(\mathbf x)=0$.
The functions $F$ are very smooth, but typically have no useful convexity properties, and in some cases (not shown below) they might also be very complex and expensive to evaluate. The simple aspects (I think) are that there are only three independent variables, and the objective function is just a quadratic form. The problem comes from engineering geometry or CAD — I’m trying to find the minimum distance from the point $\mathbf p$ to the surface $\{\mathbf x : F(\mathbf x) = 0\}$.
Some examples of typical surfaces are:
Ellipsoid: $F(x,y,z) = 4x^2 + 9y^2 + z^2 - 1$.
Clebsch: $F(x,y,z) =64x^3 + 48x^2z - 192y^2x + 48y^2z - 31z^3 - 54z^2 - 24z$
ThreeHoles: $F(x,y,z) = x(x^2 - 3y^2) - z(z^2 - 1)$
SchwartzP: $F(x,y,z) = \cos(x) + \cos(y) + \cos(z)$
Scherk: $F(x,y,z) = \sin(z) - \tfrac12 \sinh(x) \sinh(y)$
Costa: $F(x,y,z) = (x^2 + y^2 - 1)z - (x^2 - y^2)$
I know that I can attack this problem by solving the equation $(\mathbf x - \mathbf p) \times \nabla F(\mathbf x) = 0$, but I thought using a minimization algorithm might work better.
My question: There are dozens of optimization algorithms, and I’m hoping that someone can recommend one (or more) that is well-suited to my problem, perhaps by taking advantage of its simplicity.
Ideally, I’d like to get working code, as opposed to just a mathematical description. I don’t really care what programming language is used. I don’t need great accuracy (5 or 6 good digits would be OK), but speed and reliability are important.