(apologies for the n00b question)


Let's say we have a vector of length $n$, with to-be-determined values: $a\_1, a\_2, ...,a\_n$.


And we have information that partial sums of these elements are equal to something, say:
$$
a\_1 + a\_2 + ... + a\_{k\_1} = A\_{1} \\
a\_{k\_1+1} + a\_{k\_1+2} + ... + a\_n = B\_1 \\
a\_1 + a\_2 + ... + a\_{k\_2} = A\_2 \\
a\_{k\_2+1} + a\_{k\_2+2} + ... + a\_n = B\_2 \\
...\\
a\_1 + a\_2 + ... + a\_{k\_m} = A\_m \\
a\_{k\_m+1} + a\_{k\_m+2} + ... + a\_n = B\_m \\
$$


Where $m<<n$: so we have much fewer such $m$ equations/constraints than the $n$ unknown values $a\_i$.


If we want to know which combination of $a\_i$ values can solve these equations, there are probably infinite many such combinations (or 0). So I'd like to add two constraints to this:


1. $a\_i>0$ for any i.
2. I want the solution with $a\_i$ values that are as "similar" to each other as possible. For example, keeping $\sum\_{i=1}^n (a\_i - \bar a)^2$ as small as possible (L2 norm). Where $\bar a = \sum \frac{a\_i}{n}$.


How is such optimization problem called? (would also love to know how to solve it, but I assume that once I have the name, I can find solvers).



How do you call a linear programming problem when the solution should be "constrained" to a norm?
If you are willing to replace $a\_i > 0$ by $a\_i \ge 0$,
then this becomes a **quadratic program**. Indeed,
it can be formulated as
\begin{align\*}
\text{Minimize}\quad & \frac12 a^\top Q a + q^\top a, \\
\text{such that} \quad & C a = d, \\
& a \ge 0.
\end{align\*}
Here, $Q$ and $C$ are matrices of appropriate size and $q$ and $d$ are vectors (these objects come from your data). Moreover, the matrix $Q$ is positive semidefinite.


[If you insist on keeping $a\_i > 0$, the corresponding problem might fail to have solutions.]


