Given a set of items, each characterized by a quality $q_i\in(0,1)$. We can merge two items of quality $q_i$ and $q_j$ to a single item $k$ of quality $q_k=f(q_i,q_j)$, where $f$ is increasing in $q_i$ and $q_j$. Suppose that initially we have $n$ items of identical quality $q$, I want to obtain a final item of maximal quality, by a set of merging operations. How to find an optimal sequence of merging operations?
For example, if we have $4$ items, we can merge $1$ and $2$ to a new item $a$, $3$ and $4$ to a new item $b$, and then merge $a$ and $b$ to the final item; we can also merge $1$ and $2$ to item $a$ and then merge $a$ and $3$ to a new item and then merge it with $4$ to a final item. Has this problem been explored before mathematically?
Let me give two examples of $f$.
$f(x,y)=\frac{xy}{xy+(1−x)(1−y)}$. This function is commutative and associative (as a binary operation) so the quality of the final merged item is independent of the merge sequence;
$f(x,y)=\frac{10xy−(x+y)+1}{8xy−2(x+y)+5}$. In this case, what is the optimal merge sequence?