Un algoritmo codicioso o dinámico para la selección de subconjuntos

I have a simple algorithmic question. I would be grateful if you could help me.

We have some 2 dimensional points. A positive weight is associated to them (a sample problem is attached). We want to select a subset of them which maximizes the weights and neither of two selected points overlap each other (for example, in the attached file, we cannot select both A and C because they are in the same row, and in the same way we cannot select both A and B, because they are in the same column.) If there is any greedy (or dynamic) approach I can use. I'm aware of non-overlapping interval selection algorithm, but I cannot use it here, because my problem is 2 dimensional.

Any reference or note is appreciated.


Attachment: A simple sample of the problem:

   A (30$) --------  B (10$)
   C (8$)

preguntado el 04 de julio de 12 a las 05:07

The maximum connected component in the forest may not have the maximal combined weight. The solution should work if you find the connected component with the maximal combined cost. -

5 Respuestas

If you are OK with a good solution, and do not demand the best solution - you can use heuristical algorithms para solucionar esto.

Asegúrate de que S be the set of points, and w(s) - the weightening function.

Create a weight function W:2^S->R (from the subsets of S to real numbers):

W(U) =    - INFINITY                         is the solution is not feasible
          Sigma(w(u)) for each u in U        otherwise

Also create a function next:2^S -> 2^2^S (a function that gets a subset of S, and returns a set of subsets of S)

next(U) = V   you can get V from U by adding/removing one element to/from U

Now, given that data - you can invoke any optimization algorithm in the Artificial Intelligence book, such as Algoritmo genético or Montañismo.

Por ejemplo, los servicios administrativos de Hill Climbing with random restarts, will be something like that:

1. best<- -INFINITY
2. while there is more time
3. choose a random subset s
4. NEXT <- next(s)
5. if max{ W(v) | for each v in NEXT} < W(s): //s is a local maximum
   5.1. if W(s) > best: best <- W(s) //if s is better then the previous result - store it.
   5.2. go to 2. //restart the hill climbing from a different random point.
6. else:
   6.1. s <- max { NEXT }
   6.2. goto 4.
7. return best //when out of time, return the best solution found so far.

El algoritmo anterior es cualquier lugar - meaning it will produce better results if given more time.

Respondido 04 Jul 12, 10:07

This can be treated as a linear assignment problem, which can be solved using an algorithm like the Hungarian algorithm. The algorithm tries to minimize the sum of costs, so just negate your weights, and use them as the costs. The assignment of rows to columns will give you the subset of points that you need. There are sparse variants for cases where not every (row,column) pair has an associated point, but you can also just use a large positive cost for these.

Respondido 04 Jul 12, 06:07

Well you can think of this as a binary constraint optimization problem, and there are various algorithms. The easiest algorithm for this problem is backtracking and arc propogation. However, it takes exponential time in the worst case. I am not sure if there are any specific algorithms to take advantage of the geometrical nature of the problem.

Respondido 04 Jul 12, 05:07

This can be solved by a pretty straight forward dynamic programming approach with a exponential time complexity

s = {A, B, C ...}

getMaxSum(s) = max( A.value + getMaxSum(compatibleSubSet(s, A)),
                    B.value + getMaxSum(compatibleSubSet(s, B)),

sin que importe compatibleSubSet(s, A) gets the subset of s that does not overlap with A

To optimize it, you can memorize the result for each subset

Respondido 04 Jul 12, 07:07

Some way to do it:

  • Write a function that generates subsets ordered from the subset off maximum weight to the subset off minimum weight while ignoring the constraints.

  • Then call this function repeatedly until a subset that honors the constraints pops up.

In order to improve the performance, you can write a not so dumb generator function that for instance honors the not-on-the-same-row constraint but that ignores the not-on-the-same-column one.

Respondido 04 Jul 12, 07:07

Please see my EDIT in the original post. I think the problem can be solved in polynomial time. - remo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.