I need some help with a 'generalised Lego problem':
Given a function $f(x)\geq 0$ on an interval $[a,b]$, and a 'building block' function $p(x)\geq 0$ with compact support. The maximum of f shall be larger than the maximum of p. Think of $[a,b]=[-5, 5]$ and the support of $p$ shall be $[-.2, .2]$.
My goal is to approximate $f$ by stacking translations of $p$ (i.e. local copies of the form $p(x-x^{\ast})$ for given grid points $x^{\ast}$).
My approach so far: Given a grid $\{x_i\}_{i=1,\dots,n}$, I am looking for non-negative integer coefficients $\{a_i\}_{i=1,\dots,n}$, such that the following is minimal: $$ \|f-\sum_{i}a_i \,p(\cdot-x_i)\|_{L^2}^2 := \int_a^b \left|f(x)-\sum_{i}a_ip(x-x_i)\right|^2\,dx\;. $$
It is straightforward to reformulate this problem as $$ \frac{1}{2}\cdot \mathbf{a}^\top\mathbf{Q}\mathbf{a} + \mathbf{b}^{\top}\mathbf{a} \to \min\;, $$ with a symmetric matrix $\mathbf{Q}$ and a vector $\mathbf{b}$.
(Up to constant factors, $\mathbf{Q}$ and $\mathbf{f}$ have entries $\left(p(\cdot-x_i), p(\cdot-x_j\right)_{L^2}$ and $\left(p(\cdot-x_i), f\right)_{L^2}$, respectively. )
I am aware that if the coefficients were to be allowed to be arbitrarily real, this is standard. How do I tackle this problem with integer and non-negative solutions without having to buy a huge and expensive black-box optimisation software? Or am I following the wrong approach at all? Would it be even possible to optimise for the grid as well?
There are a number of open-source solvers available from COIN-OR. I'm not a MATLAB user, but a quick search turned up the OPTI Toolbox for MATLAB, which includes several of the COIN-OR projects.