# Optimizing an arbitrary function of 10 variables

Let us be given a function $$f(x_1,\dots,x_{10})$$ of multiple variables $$x_1,\dots,x_{10}$$ given that $$\sum_{i=1}^{10} x_i \leq 7$$. How do we solve the following problem?

\begin{aligned} \max_{\{x_i\}, i=1,\dots,10} \quad & f(x_1,\dots,x_{10})\\ \textrm{s.t.} \quad & \sum_{i=1}^{10} x_i \leq 7\\ & x_i \in X_i, X_i = [0,10] \\ \end{aligned}

I with my professor are trying to work on building a neural network in such a way that we have multiple output from each layer. For example there are $$n$$ neurons in the $$i^{th}$$ layer, there will be, let us say $$k$$ outputs of each size $$n$$. Similarly, the next layer will also have same number of output and we will look at all the possible ways to connect $$k$$ outputs of the $$i^{th}$$ layer and $$k$$ outputs of the $$(i+1)^{st}$$ layer. And we take the max of the output in each layer while updating the loss function. My professor told me that this boils down to finally become a DP problem.

• Any additional information, such as the contribution of each $x_i$ is independent of all $x_j, j\ne i$ or all $x_i$s are integral? May 10 at 18:42
• If the variables are integers, there are only 19448 options to try. May 10 at 18:52
• Please edit the question to indicate whether the variables must be integers, or if not, what domain they come from.
– D.W.
May 13 at 6:32
• "$k$ outputs of each size $n$": what ?? May 13 at 8:42
• If all $X_i$ are identical, why $i$ ? And due to the sum and positiveness constraints, $x_i\le 7$ must hold anyway. May 13 at 8:43

There are only 19448 combinations of $$x$$'s that meet the constraints. If $$f$$ is arbitrary, the best you can do is enumerate all 19448 combinations and see which leads to the largest value of $$f$$. There is no faster algorithm. Dynamic programming does not seem relevant.
If you know something about the structure of $$f$$ (e.g., it is a separable function), then it might be possible to do better.