# WORHP Kata of August 2023: Tsiolkovsky rocket equation ⌚ 2023-08-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: The Tsiolkovsky rocket equation computes the maximum change of velocity $\Delta v$ of a rocket:
$\Delta v = v_e \ln\frac{m_0}{m_f}$
Here, $v_e$ is the effective exhaust velocity, $m_0$ is the initial total mass (including propellant), and $m_f$ is the final total mass (without propellant).
This equation also applies for rockets with more stages, for which the velocity gains in all stages are added.

Here is our optimization problem: The $n$ stages of an $n$-stage rocket have the masses $m_1,\dots, m_n$, where $\sum\limits_{i=1}^n m_i = 100$ (in arbitrary units) and each consists of 90% of propellant. After burning the first stage (and gaining the velocity) the hull of the first stage is pushed away, and the second stage is ignited, etc. The payload is $m_L = 10$, and the effective exhaust velocity $v_e$ of all stages is the same.
What is the maximum change of velocity which a 2-stage or 3-stage rocket can gain?

A solution will be provided with the next WORHP Kata.

Solution of last WORHP Kata: If $M\in\mathbb{R}^{n\times n}$ is a solution to the queens puzzle, these constraints have to be fulfilled:
 exactly one queen in each column: $\sum\limits_{i=1}^n M_{ij} = 1,$ $j=1,\dots,n$ $\prod\limits_{i=1}^n 1-M_{ij} = 0,$ $j=1,\dots,n$ exactly one queen in each row: $\sum\limits_{i=1}^n M_{ji} = 1,$ $j=1,\dots,n$ $\prod\limits_{i=1}^n 1-M_{ji} = 0,$ $j=1,\dots,n$ not more than one queen on each downward diagonal/subdiagonal: $0 \le \sum\limits_{i=1}^{n-j} M_{i+j, i} \le 1,$ $j=0,\dots,n-1$ $0 \le \sum\limits_{i=1}^{n-j} M_{i, i+j} \le 1,$ $j=1,\dots,n-1$ not more than one queen on each upward diagonal/subdiagonal: $0 \le \sum\limits_{i=1}^{n-j} M_{n+1-i-j, i} \le 1,$ $j=0,\dots,n-1$ $0 \le \sum\limits_{i=1}^{n-j} M_{n+1-i, i+j} \le 1,$ $j=1,\dots,n-1$
For $n=4$ we found this solution in 6 iterations (starting from zero initial guess): For $n=6$ and $n=8$ we used the (randomly chosen) initial guess $M_{4,2} = 0.1$, $M_{2,4} = 0.1$ (and zero otherwise) and found solutions in 49 resp. 42 iterations:  