2

I have a problem that I am currently solving via brute force, but am looking for a more elegant solution. I have a system that runs various functions across multiple nodes. Each function is defined by a 'role'. Each 'role' can be defined to be allowed to one or more clients to hold it. Additionally, preference may be given to a particular client (or clients) over other clients.

The complexity comes in that it is also possible for 'roles' to be related to each other. For example, a client may only be able to hold 'RoleA' if they don't hold 'RoleB', or a client may only be able to hold 'RoleC' if they hold 'RoleD'. Additionally, roles can be related preferentially (i.e. it is preferred that a client holding 'RoleE' holds 'RoleF', but that this is not mandatory).

A client may advertise its willingness to hold any number of roles, but is not required to do so. i.e 'client1' may advertise for roles 'A', 'B', and 'C', while 'client2' may only advertise for roles 'A' and 'B'.

I have solved this problem in a brute force fashion, but obviously, as the number of related roles increases, solving it takes exponentially longer.

Currently, my algorithm is: Work out all of the possible combinations for clients advertising a given role, and then asses that role in isolation to generate an list of legal combinations, ordered by preference.

Generate all possible combinations for the lists generated in the previous step, and iterate over these, deciding which is the 'most optimal' based on heuristics around mandatory, illegal, favoured, and unfavoured relationships of the group of roles. This is the part that explodes exponentially as the number of related roles increases.

I have tried some 'early out' approaches whereby a theoretical maximum possible 'score' is determined based on the role relationships, and that as soon as we encounter a combination that has a 'score' >= this that we just stop processing, but I'm wondering if there's a more mathematical solution. Any solution is presumably going to be an approximation of the optimal combination, but that is fine.

Ideally I need something that can run sub second.

Hopefully my explanation is not too vague and someone can point me in the right direction! Thanks in advance. Cam

1 Answers1

0

Sounds like the Boolean satisfiability problem with some extra complication. BSP is an NP-complete problem, therefore there is no algorithm that can solve it in less than exponential time, however there are some algorithms (mentioned in the link) that can do it better than brute force.

Vitruvie
  • 2,327
  • 18
  • 25
  • Thanks Saposhiente, I've had a look at the BSP stuff but I don't think that it quite fits in this case. Correct me if I'm wrong, but with the BSP problems, you have an 'equation' that you need to determine if there's a solution to. In my case, I have many solutions and need to find an optimal (or close to optimal one). So, I don't think that BSP will work in this case. Interesting reading though! – user3051437 Dec 01 '13 at 20:51
  • Except for the "preference" part, your problem simplifies to BSP. The thing with NP-complete problems is that while they are hard to solve, their solutions are easy to verify; in this case, the solution to BSP is to return one of the possible solutions to the equation. Running one of the available algorithms would be guaranteed to give you a solution if one exists, but not necessarily the most optimal one in terms of preference. – Vitruvie Dec 01 '13 at 21:56
  • Yes I agree that it can give a solution, but no guarantees about the optimal solution. This is unfortunately not a lot of use for my application, as I need something approximating an optimal solution. Thanks for your suggestions though, much appreciated. – user3051437 Dec 01 '13 at 22:42
  • Looks like Weighted Max-SAT may be a possibility – user3051437 Dec 01 '13 at 22:56