Find a convex combination of scalars given a point within them. I've been banging my head on this one all day! I'm going to do my best to explain the problem, but bear with me.
Given a set of numbers $S = \{X_1, X_2, \dots, X_n\}$ and a scalar $T$, where it is guaranteed that there is at least one member of $S$ that is less than $T$ and at least one member that's greater than $T$,
I'm looking for an algorithm to create a Convex Combination of these scalars that equals $T$. 
For example, for the set $\{2,4\}$ and the scalar $3$, the answer is:
$$.5 \cdot 2 + .5 \cdot 4 = 3.$$
I believe in many cases there are infinite infinitely many solutions.
I'm looking for a generalized algorithm/formula to find these coefficients.
Additionally, I would like for the coefficient weights to be distributed as evenly as possible (of course while still adding up to 1.)
For instance, for the set $\{1,2,4\}$ and the scalar $3$, a technically valid solution would be the same as the first example but with the coefficient for $1$ assigned a weight of 0 - but it would be prefferable to assign a non-zero weight.
I may not be thinking through this last part very clearly :)

Denote the set of numbers $S$ by the column vector $x=[x_1,x_2,\ldots,x_N]^T$. Let us denote the set of numbers we are looking for by the column vector $a=[a_1,a_2,\ldots,a_N]^T$. Also, denote $b=[1,1,\ldots,1]^T$ Then the set of all solutions for your problem can be found by solving 
\begin{align}
\min_a 0 \\
\text{subject to }&a^Tx=T \\
&a^Tb=1\\
&a\geq0
\end{align}
Let us say, you wish to give any particular weight to each of the solution, say the vector $w=[w_1,w_2,\ldots,w_N]^T$. Then the solution can be found by solving 
\begin{align}
\min_a w^Ta \\
\text{subject to }&a^Tx=T \\
&a^Tb=1\\
&a\geq0
\end{align}
Both of this problems are linear programming problems and hence should be solvable by simplex algorithm.
