Log in

WORHP Kata of May 2023: Points on a sphere ⌚ 2023-05-01

A kata (in the context of programming) is a small training unit to practise coding. In this series of WORHP Katas we present standard problems of optimization which you can use to get familiar with optimization (and our optimization software WORHP).

Kata: We want to distribute 12 points on a unit sphere in . For each pair of points, we compute the reciprocal of their distance. Find the distribution which minimizes the sum of all these reciprocals!

A solution will be provided with the next WORHP Kata.


Solution of last WORHP Kata: For a line and a point we can find the perpendicular foot as
and the Euclidean distance from the point to the line as:
To avoid a not differentiable formulation, we introduce an auxiliary optimization variable , which stands for the minimum distance of all points to the line, i.e. for all points. Hence we have to solve this problem:

Using this CPP code and our solver WORHP, we get after 7 iterations:
In this plot, we see the data points in orange, the optimal line, and the perpendicular feet:
When checking the constraints, we see that three points share the same maximal distance from the line, as our solution yields equality for .