User:Ag2gaeh/sandbox

The Varignon frame, named after Pierre Varignon, is a mechanical device which can be used to determine an optimal location of a warehouse for the destribution of goods to a set of shops. Optimal means that the sum the weighted distances of the shops to the warehouse should be minimal. The frame consists of a board with n holes corresponding to the n shops at the locations $$\mathbf x_1, ...\mathbf x_n$$, n strings are tied together in a knot at one end, the loose ends are passed, one each, through the holes and are attached to weights below the board (see diagram). If the influence of friction and other odds of the real world are neglected, the knot will take a position of equilibrium $$\mathbf v$$. It can be shown (see below), that point $$\mathbf v$$ is the optimal location which minimizes the weighted sum of distances
 * (1): $$\ D(\mathbf x)=\sum_{i=1}^n m_i|\mathbf x_i-\mathbf x|$$.

The optimization problem is called Weber problem.

Mechanical Problem - Optimization Problem
If the holes have locations $$\mathbf x_1, \dots, \mathbf x_n$$ and the masses of the weights are $$m_1,...,m_n$$ then the force acting at the i-th string has the magnitude $$m_i\cdot g$$ ($$g=9.81 \text{m/sec} $$: constant of gravity) and direction $$ \tfrac{\mathbf x_i- \mathbf v}{|\mathbf x_i-\mathbf v|}$$ (unitvector). Summing up all forces and cancelling the common term $$g$$ one gets the equation
 * (2):$$\ \mathbf F(\mathbf v)=\sum_{i=1}^n m_i\frac{\mathbf x_i-\mathbf v}{|\mathbf x_i-\mathbf v|}=\mathbf 0$$.

(At the point of equilibrium the sum of all forces is zero !)

This is a non-linear system for the coordinates of point $$\mathbf v$$ which can be solved iteratively by the Weiszfeld-algorithm (see below)

The connection between equation (1) and equation (2) is:
 * (3): $$\ \mathbf F(\mathbf x)= \nabla D(\mathbf x) = \begin{bmatrix}

\frac{\partial D}{\partial x} \\ \frac{\partial D}{\partial y} \end{bmatrix}.$$ Hence Function $$D$$ has at point $$\mathbf v$$ a local extremum and the Varignon frame provides the optimal location experimentally.

Example
For the following example the points are
 * $$\mathbf x_1=(0,0),\ \mathbf x_2=(40,0),\ \mathbf x_3=(50,40),$$
 * $$\mathbf x_4=(10,50),\ \mathbf x_5=(-10,30)$$

and the weights
 * $$m_1=10,\; m_2=10,\; m_3=20,\; m_4=10,\; m_5=5$$.

The coordinates of the optimal solution (red) are $$(32.5, 30.1)$$ and the optimal weighted sum of lenghts is $$L_\text{op} = 1679$$. The second picture shows level curves which consist of points of equal but not optimal sums. Level curves can be used for assigning areas, where the wheighted sums do not exceed a fixed level. Geometrically they are implicit curves with equations
 * $$\; D(\mathbf x)-c=0, \; c>L_\text{op}\;$$ (see equation (1)).



Special cases n=1 und n=2

 * In case of $$n=1$$ one gets $$ \mathbf v = \mathbf x_1$$.
 * In case of $$n=2$$ and $$m_2>m_1$$ one gets $$ \mathbf v = \mathbf x_2$$.
 * In case of $$n=2$$ and $$m_2=m_1$$ point $$ \mathbf v $$ can be any point of the line section $$\overline{X_1X_2}$$ (see diagram). In this case the level curves (points with the same  not-optimal sum) are confocal ellipses  with the points $$\mathbf x_1,\mathbf x_2$$ as common foci.

Weiszfeld-algorithm and a fixpoint problem


Replacing in formula (2) vector $$\mathbf v$$ in the nominator by $$\mathbf v_{k+1}$$ and in the denominator by $$\mathbf v_k$$ and solving the equation for $$\mathbf v_{k+1}$$ one gets :
 * (4):$$\quad \mathbf v_{k+1}=\sum_{i=1}^n \frac{m_i\mathbf x_i}{|\mathbf x_i-\mathbf v_k|}\big/ \sum_{i=1}^n \frac{m_i}{|\mathbf x_i-\mathbf v_k|}$$

which describes an iteration. As starting point is chosen the center of mass with mass $$m_i$$ in point $$\mathbf x_i$$:
 * $$\mathbf v_0= \frac{\sum_{i=1}^n m_i \mathbf x_i}{\sum_{i=1}^n m_i}$$.

This algorithm is called Weiszfeld-algorithm.

Formula (4) can be seen as the iteration formula for determining the fixed point of function
 * (5)$$\quad \mathbf G(\mathbf x)=\sum_{i=1}^n \frac{m_i\mathbf x_i}{|\mathbf x_i-\mathbf x|}\big/ \sum_{i=1}^n \frac{m_i}{|\mathbf x_i-\mathbf x|}$$

with fixpoint equation
 * $$\quad \mathbf x= G(\mathbf x)$$

(see fixed point)

Remark on numerical problems: The iteration algorithm described here may have numerical problems if point $$\mathbf v_k$$ is near of one of the points $$\mathbf x_1,...\mathbf x_n$$.