Let's start with a picture: <https://i.stack.imgur.com/mEFct.png>
What you see here are boxes and circles inside the boxes. Each circle is connected to zero or more boxes. One box is the primary box, it's the grey one. Here is another example (the top box is the primary box): <https://i.stack.imgur.com/V0mQS.png> (I apologize for the crappy drawings).


The goal is to select a subset of all circles such that:


1. If a circle is selected, then all the boxes it is connected to must be selected.
2. If a box is selected then *one of* the circles in it must be selected.
3. The primary box is selected.
4. The sum of the numbers in the selected circles is minimal.


In the top picture the optimal selection of circles has been colored blue. In the bottom picture there are two optimal solutions: select the 3 in the top box and the 1 in the right box. Other solution: select the 2 in the top box, the 1 in the left box and the 1 in the right box.


My question is: is this solvable in polynomial time, or if not is it possible to approximate it? If the graph is tree structured then dynamic programming can solve the problem, but diamond structures seem to complicate the problem.


I have asked this problem on stackoverflow.com, but that doesn't seem to get very far and I thought maybe this is a more appropriate place?



Is this problem solvable in polynomial time?
There is a straightforward encoding of 3-SAT into this problem, which means that unless P=NP, no, there cannot be a polynomial-time algorithm that solves it. The encoding can be constructed as follows. Given a formula $\phi=\psi\_1\wedge\dots\wedge\psi\_k$ in conjunctive normal form over propositional variables $v\_1,\dots,v\_n$, you have the following boxes:


1. For each $v\_i$, two boxes $A\_i, B\_i$ representing the literals $v\_i$ and $\neg v\_i$. Both contain a single unit-weight circle.
2. Also for each $v\_i$, a box $C\_i$ representing the law of the excluded middle: This box contains two circles with weight 0, one connected to $A\_i$, the other to $B\_i$.
3. For each clause $\psi\_j=l\_1\vee l\_2 \vee l\_3$, a box $D\_j$ containing three weight-0 circles connected to the corresponding $A\_i$ or $B\_i$.
4. The root box, containing a single weight-0 circle connected to all the $C\_i$ and $D\_j$.


This can be done in time linear in the size of $\phi$.


Then a set of circles satisfying your constraints must contain at least one of $A\_i,B\_i$ for all $i$, and has weight $n$ if and only if it corresponds to a valid valuation of the $v\_i$ which satisfies $\phi$. In particular, satisfiability of $\phi$ can be decided by checking if the minimum weight solution has weight $n$.


