I have a problem which I am trying to solve using a simplex solver (but I am happy to use any approach that works).
$$ a_1 x_1 + a_2 x_2 + ... + a_n x_n= TotalCost $$ Where $a_i$ are constant inputs and $x_i$ are the weights that I am optimizing.
I have a constraint that the sum of weights needs to add up to one $$ \sum^n_{i=1} x_i = 1 $$
I wish to have the largest possible number of non-zero weights. However, some weights will be zero (because they have a very high cost). There are solutions to this (such as this Q). However, this doesn't seem to work with my constraint that the weights always sum to one.
How to impose sparsity (or the opposite) in this case?
--- Added later ---
Take for example $n=4$ $$ a = (0.2, 0.25, 0.25, 1.0)$$ The lowest cost solution is $x = (1, 0, 0, 0)$ but I would like to biase the solution such that $x = (0.8, 0.1, 0.1, 0)$ becomes optimal.
My first instinct would be to add a term of the form $$ \lambda \sum^n_{i=1} x_i^2 $$ where $\lambda$ is a constant (i.e. something aking to a $L_2$ regularization) but that is no longer linear.
One can add an $ \alpha \ z$ term, where $ z \ge x_i \ \forall \ i$ but such a constraint seems to either do nothing (when $\alpha$ is too small) or force all $x_i$ that are non-zero to be equal.
Assumptions:
The objective is to minimize the total cost $$C=a_1x_1 + \cdots + a_nx_n$$ subject to $$x_1 + \cdots + x_n=1$$ but also, you want to impose to some additional constraints . . .
As a proposed solution, you could add the constraints $$x_k \ge \left({\small{\frac{a_{k+1}}{a_k}}}\right)x_{k+1}$$ for $1\le k \le n-1$, together with the constraint $$x_n \ge d$$ for some fixed positive constant $d$.