0

I have the following problem: I need to find the optimal Bluetooth frequency configuration for a set of positions, where each position must have a different sender frequency and the minimum threshold for detecting all signals shall be as large as possible.

Or, to transfer it to a strictly mathematical description:

Let $x = 1\dots M$ be $M$ different positions and $y = 1\dots N$, $N\geq M$, be $N$ different frequency channels. For each position and each channel, the signal strength is $S_{xy}$.

Now, for each position, a channel shall be selected, so that no channel shall be used on more than one position. Let us call this set $S = \{S_{1y_1}, S_{2y_2}, \dots S_{My_M}\}$, where all the $S_{1y_1}, \dots S_{My_M}$ shall be different.

Let $S_{\min} = \min(S)$ be the lower bound of the set $S$. I want to find the set that maximizes $S_{\min}$.

Example: For three positions and four channels, assume the matrix $S_{xy}$ to be: $$\begin{array}{cccc} 8 &9 &7 &6\\ 5 &6 &9 &4\\ 8 &2 &3 &7\\ \end{array} $$ A possible set would be $\{S_{11}= 8, S_{22} = 6, S_{34} = 7\}$, where $S_{\min} = 6$. This is, however, not the optimal set, which would be $\{S_{12}= 9, S_{23} = 9, S_{31} = 8\}$, where $S_{\min} = 8$.

I know there is a solution to a similar problem, where the sum of all elements of S shall be maximized (or minimized), known as the Hungarian algorithm, but I am not aware of a solution for this problem. A brute force attempt, being $\mathcal{O}(n!)$, is forbiddingly costly, so my question is if there is a known (polynomial) solution to this problem.

caduk
  • 4,665
Thern
  • 901

2 Answers2

0

I'm unsure if the method provided below is a known solution or algorithm. My main motivation for it came from observing Kruskal's algorithm for minimum spanning trees, and the reasoning for greedily selecting the smallest next edge. My final time complexity is $O(MN^4)$.

Update: The time complexity can be reduced to $O(MN^3)$ (scroll to bottom)

Method 1: Add all positions (x,y) to a priority queue, giving highest priority to those with minimized $S_{xy}$. On every iteration, get the smallest value from the queue and delete it from the grid (by setting it to null). If no valid selection can be made from the grid without selecting null, add the value back and return with any valid selection on this grid.

Visualization:

8 9 7 6
5 6 9 4
8 2 3 7
8 9 7 6
5 6 9 4
8 null 3 7
8 9 7 6
5 6 9 4
8 null null 7
8 9 7 6
5 6 9 null
8 null null 7
8 9 7 6
null 6 9 null
8 null null 7
8 9 7 null
null null 9 null
8 null null 7
8 9 null null
null null 9 null
8 null null null
null 9 null null
null null 9 null
null null null null

We see that, after removing 8, there are no valid selections, so we end with $\{S_{12},S_{23},S_{31}\}$

Proof: we can prove this by induction.

Let us consider method 1 first. At any given iteration, consider the smallest value in the grid. If this is a part of our optimal choice $S$, then $S_{min}$ takes on this value. In order to maximize our minimum, we mustn't include this value, so let us delete it. However, if we decide to regret our decision, realizing there is no solution in the resulting grid, then we must necessarily include this value, forcing it to become $S_{min}$. We end with this answer.

In method 2, we instead add values until we find a valid selection. The mechanics are similar.

Test for valid selection: In order for us to keep the time complexity small, we must be able to test a given grid for valid solutions quickly. For this, we can apply the Hungarian Algorithm. First, we transpose the matrix, replace all nulls with 1, and all other values with 0, but this is achievable in $O(1)$ per iteration by continuously updating a single matrix. Now, the rows are the workers and the columns are the tasks. We can calculate the minimum sum of times to complete the tasks in $O(N^3)$. If this minimum sum is positive, we know that at least one null is selected in the sum, so we have no valid selections.

Overall time complexity: First, we create a priority queue. This is $O(MNlog(MN))$. Next, we iterate over every item using the queue. In each iteration, we perform the Hungarian Algorithm check, which takes $O(N^3)$. With $MN$ iterations, this yields $O(MN^4)$. Our overall complexity is just $O(MN^4 + MNlog(MN)) = O(MN^4)$, which is polynomial.

Update: In method 1, we can consider updating a given solution to the Hungarian Algorithm. Since we are only editing a single value each iteration, in the worst case we remove an option that was selected in our prior optimal case. This would need a single addition of a job after removal, or $O(N^2)$. This yields $O(MN^3)$ when using a variation of the Hungarian Algorithm optimized to this problem specifically.

Abc Bcd
  • 59
  • An interesting solution. I think you can optimize your testing procedure by not iterating over each item in the queue (thereby creating an additional order of $\mathcal{O}(N)$), but apply a similar nested interval approach as in my solution, e.g. check the situation when half the values are null, afterwards if 1/4 (or 3/4) of the values are null etc. This would reduce the additional complexity to $\mathcal{O}(\log N)$, arriving at the same complexity as my solution. – Thern Dec 08 '23 at 18:06
0

Meanwhile, I have found a solution to the problem myself. It is somewhat similar to the solution of @AbcBcd, but has a better complexity (although I think his solution can be slightly improved to yield the same complexity).

For ease of explanation, I assume $N$ = $M$, since missing rows in the matrix $S_{ij}$ can be filled up with zeroes.

Let us define an arbitrary threshold $t$. We can use the Hungarian algorithm to answer the question if there is a distribution $S$ that satisfies the condition that for every $S_{ij} \in S$, it holds $S_{ij} \geq t$. For this, we have to create a new matrix $\bar{S}$ where $\bar{S}_{ij} = 1$ if $S_{ij} < t$ and $\bar{S}_{ij} = 0$ if $S_{ij} \geq t$.

It can be immediately seen that the sum of all elements of $S$ will be $0$ iff all elements of $S$ lie at or above the threshold $t$. So, applying the Hungarian algorithm to $\bar{S}$ yields $0$ iff there is a valid channel distribution where all elements are at least $t$.

The complexity for generating $\bar{S}$ is $\mathcal{O}(N^2)$, the complexity of the Hungarian Algorithm is $\mathcal{O}(N^3)$ (using the optimal algorithm), so the operation to find a solution for $t$ is $\mathcal{O}(N^3+N^2)=\mathcal{O}(N^3)$.

We apply an ordering algorithm to $S_{ij}$, getting a sorted list from lowest to highest value. Let us call this list $L$. $L$ has $N^2$ elements, and it holds $L_i \leq L_j$ if $i<j$. Now we observe that there is only a limited amount of values for $t$ where it makes sense to check them, namely all values $L_i$. If we know that $L_i$ satisfies the condition and $L_{i+1}$ does not, we know that $L_i$ is the solution we are looking for, since chosing $t$ between $L_i$ and $L_{i+1}$ would not change anything.

The rest is a simple nested interval method on $L$. Start with $L_{n/2}$, then go to $L_{n/4}$ or $L_{3n/4}$ depending on the result (we use integer division here), and so on, until we arrive at a point where there exists a valid distribution for $L_i$ but not for $L_{i+1}$.

The nested interval method is of order $\mathcal{O}(\log N)$, so we approach at a final complexity of $\mathcal{O}(N^3\cdot \log N)$. Note that sorting the list $L$ once with $N^2$ elements is an operation of complexity $\mathcal{O}(N^2\cdot \log N)$ and thus does not change the overall complexity of the algorithm.

Thern
  • 901