I'm an engineer with not-so-strong mathematics skills.
My apologies if my title is misleading, as I am unsure how to properly categorize this issue.
I came across a practical problem at work, described as follows:
$a$, $b$, and $c$ are nonnegative integers that satisfy the following conditions:
$0 \leq a \leq 1$,
$0 \leq b \leq 51$,
$0 \leq c \leq 40$,
with $a + b + c = 10$.
The task is to find the minimum value of the function
$f(a, b, c) = (a - \frac{10}{3})^2 + (b - \frac{10}{3})^2 + (c - \frac{10}{3})^2$,
as well as the corresponding values of $a$, $b$, and $c$.
Based on my basic mathematical knowledge, I solved this problem on a case-by-case basis, assuming $a = 0$ and $a = 1$ respectively.
(step1) When $a = 0$, the function becomes $(0 - \frac{10}{3})^2 + (b - \frac{10}{3})^2 + ((10 - b) - \frac{10}{3}) ^2$, which easily gives the minimum value when $b = 5$.
(step2) When $a = 1$, using the same approach we find that the optimal value for $b$ occurs at $b = 4.5$, that is, choosing either $b = 4$ or $b = 5$ brings us close enough to the optimal solution.
(step final) Comparing the function values in the two cases, we find that the optimal solution occurs when $a = 1$, $b= 4$, and $c = 5$.
My question is, my approach was to exhaustively reduce the problem to one dimension and solve it.
I wonder if there is a better way to do this?
I have this doubt because in practice, the upper bound for $a$ is often more than just 1, it could be a larger number. I don't want to always resort to the brute-force method when I come across such problems. I hope someone kind could tell me some methods or keywords.
update_1
I apologize for not being clear before. In practical situations, the upper bounds for $a$, $b$, and $c$ vary depending on the circumstances, while the lower bounds are always $0$.
After several calculations, I found that due to the nature of the function, without boundaries, the minimum value in real numbers would be $(a, b, c) = (\frac{10}{3}, \frac{10}{3}, \frac{10}{3})$.
When boundaries are added, for example, in the previous case, I simply choose the value as close as possible to the solution (among the choices of $0$ or $1$ for $a$, $1$ is closer to $\frac{10}{3}$), and this will yield the optimal solution.
In other situations, for example,
$0 \leq a \leq 2$,
$0 \leq b \leq 3$,
$0 \leq c \leq 60$,
the optimal solution should occur at $(a, b, c) = (2, 3, 5)$, because $a$ and $b$ should be as close to $\frac{10}{3}$ as possible, just like choosing the optimal point in linear programming.
Is my observation correct? And why does this happen?
... for a = 0 to 1 do {for b=0 to 10-a do {c=10-a-b; ... }}– Ivan Kaznacheyeu Jun 08 '23 at 07:33Also, I apologize for the incorrect general form earlier.
My general case should be $f = (a - \frac{U}{3})^2 + (b - \frac{U}{3})^2 + (c - \frac{U}{3})^2$. The goal is to find non-negative integers $a$, $b$, and $c$ such that $a+b+c=U$, where $U$ is a positive integer, and $0 \leq a \leq a_2$, $0 \leq b \leq b_2$, $0 \leq c \leq c_2$. The aim is to determine $a$, $b$, and $c$ that would minimize the value of $f$.
– yamiew Jun 08 '23 at 09:48