Problem
Let y
be an array of float numbers (of length $n$) bounded in the range [0,1]. I am trying to compute the array x
that respects the following criteria:
x
must be of length $n$ toox
must also be bounded in the range [0,1]- No two values of
x
must be closer to each other than $\epsilon$. That is $ \epsilon \le x_i - x_j \space \forall i \neq j$
So far, there are an infinite number of possible solutions. There is therefore a statistic to optimize though.
- The sum of square differences between
x
andy
must be minimized. That is $\sum_{i=1}^n (x_i - y_i)^2$ must be minimized.
In short
I want to find x
given y
such as
$$ \begin{align} \text{minimize}& & f(\mathbf{x}) &= \sum_{i=1}^n (x_i - y_i)^2 \\ \text{subject to}& & x_{j+1} - x_j &\geq \varepsilon, j = 1, 2, \ldots, n-1 \\ & & min(x) &\geq 0 \\ & & max(x) & \leq 1 \\ \end{align}$$
Expected Output 1
$y = [0,\frac{1}{2},\frac{1}{2},\frac{1}{2},\frac{3}{4}]$
$x = [0,\frac{1}{2}-\epsilon,\frac{1}{2},\frac{1}{2}+\epsilon,\frac{3}{4}]$
Expected Output 2
$y = [0,0,0]$
$x = [0,\epsilon,2\cdot \epsilon]$
Of course, there are cases where no solution exist. Typically, in the second example if $2\cdot \epsilon > 1$, then there are no solution. In such case, the program should throw an error.
Can you give me advice on how to go about solving this problem?