= Projection onto a box-constrained hyperplane
Let
$$
C=\{x\in\mathbb R^n:0\le x_i\le1,\quad a^Tx=b\}.
$$
This <closed convex set> is nonempty exactly when
$$
\sum_{a_i<0}a_i\le b\le\sum_{a_i>0}a_i.
$$
These are the minimum and maximum of the linear constraint on the box. If the interval condition fails, there is no projection onto $C$.
For feasible data, minimizing $\frac12\|x-y\|_2^2$ with multiplier $\nu$ for $a^Tx=b$ separates across coordinates:
$$
x_i(\nu)=\min(1,\max(0,y_i-\nu a_i)).
$$
The scalar function $\phi(\nu)=a^Tx(\nu)$ is continuous and nonincreasing. On a piece with free coordinates, $\phi\prime(\nu)=-\sum_{0<x_i<1}a_i^2\le0$. Its limiting values are the two box extrema, so one can choose $\nu$ with $\phi(\nu)=b$; plateaus can make the multiplier nonunique, while the projected vector remains unique by <strict convexity>. For $a=0$, feasibility requires $b=0$ and coordinatewise clipping alone suffices.
For example, with $a=(1,1,1)$, $b=1$ and $y=(0.8,0.7,-0.2)$, taking $\nu=0.25$ gives the projection $(0.55,0.45,0)$. When $a$ is the all-ones vector and $b$ is an integer, the constraint set is a <capped simplex>. The clipped scalar equation permits efficient <bisection> or a breakpoint search.
Back to article page