For continuous optimizations, what is the condition that says an optimal value lies on the boundary and not in the interior? Suppose I want to solve the problem
\begin{equation}
\min_{x \in \mathcal{X}} f(x)
\end{equation}
where $f$ is assumed to be continuously differentiable, and $\mathcal{X}$ is closed and possibly compact.
I know that an interior optimal point $x^*$ satisfies $\nabla f(x^*) = 0$
And in general, optimal points satisfies $\nabla f(x^\star)^T (x - x^*)  \geq  0, \forall x \in \mathcal{X}$
But what about points that only lie on the boundary $\partial \mathcal{X}$? What is a condition that characterizes these points?
I am thinking of a condition that reads,
$\nabla f(x^\star)^T (x - x^*)  \geq  0, \forall x \in \mathcal{X}$ and $\nabla f(x^\star)  \neq 0$
However, $\nabla f$ cannot be evaluated on the boundary. So this condition doesn't actually make any sense.
Does anyone know how to reconcile the non-existence of $\nabla f$ and characterization of boundary optimal points?

You  need differentiability of $f$ on an open set containing $\mathcal X$ or
uniform continuity of $\nabla f$.
Consider $\min \sqrt x$ subject to $x\ge0$. Then $x=0$ is a solution but $\nabla f(0)$ does not exist.
