26

In this earlier question the OP asked the following problem:

Given a rectangular grid where some squares are empty and some are filled, what is the largest number of 2x1 dominoes that can be placed into the world such that no two dominos overlap and no domino is atop a filled square?

The (quite beautiful!) answer to this problem recognized that this is equivalent to finding a maximum bipartite matching in a specially-constructed graph. In this graph, each empty square has a node that is linked to each of its neighbors by an edge. Each domino then corresponds to an edge in the graph such that its endpoints are not covered by any other edge. Consequently, any set of edges that don't share a vertex (a matching) corresponds to an arrangement of dominoes, and vice-versa.

My question is a generalization of this earlier one:

Given a rectangular grid where some squares are empty and some are filled, what is the largest number of M x N dominoes (for a given M and N) that can be placed into the world such that no two dominos overlap and no domino is atop a filled square?

I cannot see how to convert this into a matching problem as was done in the previous case. However, I also don't see any particular reason why this problem would immediately be NP-hard, so there may be a polynomial time solution to the problem.

Is there an efficient algorithm for solving this problem? Or does anyone have a reduction that would show that this problem is NP-hard?

Thanks so much!

Community
  • 1
  • 1
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065

5 Answers5

19

This problem is definitely NP-hard and I can prove it. There is a reduction from 3-SAT to this problem. Specifically, it's a reduction from 3-SAT to the subproblem of this problem in which the dominoes are 1x3. There may also be other reductions for other specific sizes, but this one definitely works.

Essentially, in this reduction, we're going to use domino positions to encode either true or false. In specific, I'm going to adopt the same notation as the other solution, which is to say that I'll use asterisks to indicate open spaces on the grid. I'll also use sets of three capital letters to represent dominoes and lower case letters to represent "signals" which are spaces which may or may not be filled depending on the state of the system.

To embed a 3-SAT problem into this space, we're going to need a set of what I'll call gadgets which allow only certain states to be possible. Most of these gadgets will have a fixed number of dominoes in them. The exception will be the gadgets which represent the clauses which will have one extra domino if the clause is true (satisfied) but not when it is false (unsatisfied). We can interconnect these gadgets using paths. Together this will allow us to build a 3-SAT circuit. We will have a base number of dominoes since each path and gadget will take a standard amount of dominoes, we can add those up to get a base number k and then each clause gadget can have one extra domino if it is true, so if all clauses can be made true (and hence the expression satisfied) and there are n clauses, then the maximum number of dominoes will be n+k. If not, then the maximum number will be less than n+k. This is the basic form of the reduction. Next I will describe the gadgets and give examples.

Similar to the other answer, we're going to have two positions which encode true and false for a given variable. So, I'll start with a single tile which can be in two possible places.

****

This can either be covered with one domino like

AAA* or *AAA

Obviously, this cannot be covered with 2 dominoes and covering it with 0 dominoes would never be maximal. For my purposes, we're going to consider a protrusion to represent the value "false" and a lack of protrusion to represent "true". So we can view this part as having carrying two signals:

x**y

And in this case, only one of x or y will be covered, so we can consider the signals to be x and the logical not of x. For our purposes, whichever is covered is false, whichever is not covered is true. Next, we can transmit signals simply through straight can curved paths. If we have

x*****y

We will again have exactly two dominoes and result in either x or y being covered, but not both.

***y
*
*
x

Will have exactly the same behavior. So we can use this to create long and curving paths in lengths which are increments of 3. However, not all lengths we might want to use are increments of 3, so we need an additional gadget to move a different distance. I call this the fiddler gadget and it's only purpose is to move the signal slightly uneven distances to make things connect successfully. Its input comes from x and output goes to y and it merely transmits the same signal along. It looks like this:

 ***y
 *
**x

It always contains exactly two dominoes and is filled in one of the following two ways:

 BBB*     ABBB
 *        A   
AAA      *AX  

If we're going to model 3-SAT, however, we need more than this. Specifically, we need some way to model the clauses. To do this, we have a gadget where one extra domino can be packed in if the clause is true. The clause will be true when one or more of its inputs is true. In this case, that means that we can pack one extra domino in when at least one of the inputs does not protrude. It will look like this:

*x*y*
  *
  z

If we add an extra path to each for clarity, then it looks like this:

 * *
 * *
 * *
*****
  *
  ****

If x,y, and z are all false, then they'll all have protrusions and it will be filled like this:

 A B
 C D
 C D
*C*D*
  *
  EEEF

Where the rest of dominoes A,B, and F continue on down a path somewhere. If at least one of inputs is true, then we can pack in one extra domino (G) like so:

 C B         A D         A B
 C D         C D         C D
 C D    or   C D    or   C D
GGGD*       *CGGG       *CGD*
  *           *           G
  EEEF        EEEF        GEEE

However, even if all inputs are true, then we cannot pack in more than one domino. That scenario would look like this:

 C D
 C D
 C D
*****
  *
  *EEE

And as you can see, we can only insert exactly one extra domino into the empty space, not two.

Now, if terms were never repeated, then we'd be done (or very nearly done). However, they can be repeated, so next, we need a signal splitter so that one variable can appear in multiple terms. To do this, we utilize the following gadget:

y*** ***z
   * *
   ***
   ***
    x

In this gadget x is the input and y and z are the outputs. In this gadget, we can always pack 5 dominoes. If x protrudes than packing 5 dominoes will always require covering y and z as well. If x does not protrude, then covering y and z is not required. The packing where x does not protrude looks like this:

yAAA BBBz
   C D  
   CED 
   CED  
    E 

When x does protrude (we use X to indicate the end of the domino protruding into space x), the maximal packing necessarily covers both y and z:

AAAC DBBB
   C D
   C*D
   EEE
    X

I will take a moment to note that it would be possible to pack this with five dominoes when x is not protruding in such a way that either y or z protrude. However, doing so would result in terms which could be true (not protruding) becoming false (protruding). Allowing some of the terms (not variables, but actual terms in the clauses) to differ in value only by becoming false unnecessarily will never result in being able to satisfy an otherwise unsatisfiable expression. If our 3-SAT expression was (x | y | z) & (!x | y | !z) then allowing both x and !x to be false would only make things harder. If we were to allow both ends of something to be true, this would result in incorrect solutions, but we do not do this in this scheme. To frame it in terms of our specific problem, protruding unnecessarily will never result in more dominoes being able to be packed in later down the line.

With paths and these three gadgets, we can now solve planar 3-SAT, which would be the sub-problem of 3-SAT where if we draw a graph where the terms and clauses are vertices and there is an edge between every term and every clause which contains that term, that the graph is planar. I believe that planar 3-SAT is probably NP-hard because planar 1-in-3-SAT is, but in case it's not, we can use gadgets to do a signal crossing. But it's really quite complex (if anyone sees a simpler way, please let me know) so first I'm going to do an example of solving planar 3-SAT with this system.

So, a simple planar 3-SAT problem would be (x | y | z) & (!x | y | !z). Obviously, this is satisfiable, using any assignment where y is true or several other assignments. We will build our dominoes problem thus:

    *******
    *     *
    *     *
 ****   ***
 *       *
***      ****
  *         *
  *         *        
  * ******* *
  * *     * *
  * *     * *
 *z*x*   *****
   *       *
   **** ****
      * *
      ***
      ***
       *
       *
       *           
       y

Notice that we had to use fiddlers at the top to get things to space correctly or else this would've been substantially less complex.

Adding up the total dominoes from gadgets and paths we have 1 splitter (5 dominoes), two fiddlers (2 dominoes each), and a total of 13 regular paths, for a grand total of 5 + 2*2 + 13 = 22 dominoes guaranteed, even if the clauses cannot be satisfied. If they can be, then we will have 2 more dominoes which can be filled in for a total of 24. One optimal packing with 24 dominoes is as follows:

    QRRRSSS
    Q     T
    Q     T
 OPPP   *UT
 O       U
*ON      UVVV
  N         W
  N         W        
  M IIIJJJK W
  M H     K X
  M H     K X
 *zGH*   LLLX*
   G       *
   GEEE FFF*
      B D
      BCD
      BCD
       C
       A
       A
       A

This tiling contains 24 dominoes, so we can know that the original expression is satisfiable. In this case, the tiling corresponds to make y and x true and z false. Notice that this is not the only tiling (and not the only satisfying assignment of boolean values), but that there is no other tiling which will increase the number of tiles beyond 24, so it is a maximum tiling. (If you don't want to count all the dominoes you can note that I used every letter except for Y and Z.)

If the maximal tiling had contained either 22 or 23 dominoes, then we would know that one of the clauses was not satisfied (GGG and/or LLL dominoes would not be able to be placed) and hence we would know that the original expression was not satisfiable.

In order to be certain that we can do this even if planar 3-SAT isn't NP-hard, we can build a gadget which allows paths to cross. This gadget is unfortunately kind of big and complex, but it's the smallest one I was able to figure out. I'll first describe the pieces and then the whole gadget.

Piece 1: Crossover point. x and y are the inputs. a,b,and c are the outputs. They will need to be combined using other gadgets to actually relay x and y to the opposite side of each other.

   ***c
   *
  ***
  * *
  * *
  * *
  ***
  ***
 ax*yb

This gadget will always fit exactly 7 dominoes. There are four possible input combinations. If neither input protrudes (both are true) than no output will protrude and it will be filled as in (tt1) or (tt2) below. If only input x protrudes then only c will protrude as in (ft) below. If only input y protrudes then either output a or c will protrude as in (tf) below. And if input x and y both protrude then output c protrudes as in (ff) below.

 (tt) AAAc         (ft) AAAc         (tf) AAAc         (ff) BAAA     
      *                 *                 *                 B        
     BBB               BBB               BBB               CBD       
     C D               C D               C D               C D       
     C D               C D               C D               C D       
     C D               C D               C D               E G       
     EEE               EEE               EEE               EFG       
     FFF               FFF               FFF               EFG       
    aGGGb             aXGGG             GGGYb             aXFYb      

I have not included the possibility that in the (ft) or (tf) scenarios that c could be covered instead of a or b. This is possible within the scope of this gadget but once combined with other gadgets to form the complete crossover, if it were to do so, it would never result in a larger number of clauses being satisfied so we can exclude it. With that in mind, we can then observe that in this case the value of the input x is equal to the value of b & c and the input y is equal to the value of a & c (note that this would be logical or rather than logical and if protrusion were considered true rather than false). So we just need to split c and then use a logical and gadget to connect connect the values of c with a and b respectively and we will then have successfully completed our cross over.

The logical and is our simplest gadget so far and it looks like this:

  ****
  *
 x*y

You might actually note that there's one embedded towards the top of the crossover point gadget. This gadget will always contain precisely 2 dominoes. One will be at the top to serve as the output. The other one serves as a switch which will be horizontally oriented only if both x and y are true (non-protruding) and vertically oriented otherwise as we can see in the following diagrams:

 BBB*     ABBB     ABBB     ABBB
 *        A        A        A   
AAA      XAy      xAY      XAY  

Thus we can complete the crossover by splitting c and then adding two of these gates, one for a & c and one for b & c. Putting it all together requires also adding some fiddler gadgets and looks like this:

             ******* ****
             *     * *  *
             *     ***  *
            ***    *** ***
              *     *  *
           ****     *  ****
           *        *     *
           *     ****     *
          ***    *       ***
            *   ***      *
         ****   * *      ****
    y    *      * *         *    x
    *    *      * *         *    *
    * ****      ***         **** *
    ***         ***            ***
      **********x*y*************

I'm not going to fill in example tilings for that. You'll have to do it yourself if you want to see it in action. So, hooray! We can now do arbitrary 3-SAT. I should take a moment to note that doing this will be a polynomial time transformation because even in the worst case, we can just make a big grid with all of the variables and their opposites along the top and all the terms on the side and do O(n^2) crossovers. So there is a simple, polynomial-time algorithm for laying this all out and the maximum size of the transformed problem is polynomial in the size of the input problem. QED.


Edit note: Following Tom Sirgedas's excellent work in finding a mistake in the splitter gadget, I've made some changes to the answer. Essentially, my old splitter looked like this and could be packed with 6 when x does not protrude (rather than the 5 I had intended) like this:

y*** ***z   AAAC DBBB
   * *         C D
   ***         C*D
   ***         EEE
   *x*         FFF

So I revised it by removing the two spaces on either side of x. This eliminates the six domino packing while still allowing a 5-domino packing in which y and z are uncovered when x is uncovered.

Keith Irwin
  • 5,628
  • 22
  • 31
  • Looks really nice (love the AND gate!) but the one thing I'm concerned about is that you're a bit fuzzy on the notion of a square being covered or not. Although you address this for some of the later gadgets, even in your most basic gadget `x*****y` there's no guarantee that a tiling leave exactly one of `x` and `y` uncovered: e.g. `XXX*YYY` is a valid maximal tiling. I think what you need is a lemma guaranteeing that, if several maximal tilings exist, and at least one of them leaves a given square `x` uncovered, then we may assume that `x` is uncovered when we bolt it to another gadget. – j_random_hacker Sep 10 '11 at 15:01
  • 1
    Also when you say "If the maximal tiling had contained either 24 or 25 dominoes", do you mean "If the maximal tiling had contained either 25 or 26 dominoes"? Just trying to make sure I understand correctly :) – j_random_hacker Sep 10 '11 at 15:12
  • 1
    @j_random_hacker: (Last things first) I actually meant "22 or 23". I had miscounted the dominoes by 2 the first time through and then when I fixed that, I missed one spot, so those two numbers were off by 2. Sorry. Good catch. It's fixed now. – Keith Irwin Sep 10 '11 at 15:51
  • @j_random_hacker: Addressing the first comment, I did actually talk about this sort of situation in the answer because it arises in essentially every gadget. The XXX*YYY tiling would be equivalent to both x and y (which is the logical not of x) being false. This can only cause either the same number of clauses to be satisfied as maximal tiling or fewer. Or alternately put, a greater than necessary number of protrusions from a path or gadget will never result in more tiles. As such, a tiling which does not minimize protrusions from any one gadget can never be better than a maximal tiling. – Keith Irwin Sep 10 '11 at 15:58
  • 1
    It can be the same as a maximal tiling in some case, but only when the variables involved aren't the ones satisfying clauses. For instance, in the planar example, we could make both z and !z protrude (making both values false). This would not change the total number of tiles or the number of clauses satisfied. If, in our system z and !z could both be true (not protruding), it would be broken because it would give incorrect results. But allowing both z and !z to be false can never cause that problem. It's one of the trickier ideas in the proof. I hope that this explanation makes sense to you. – Keith Irwin Sep 10 '11 at 16:03
  • Thanks Keith, I appreciate the explanation. You're right about meaning "22 or 23", I had it backwards. After much thought I think you're right about the rest too, and that the property you describe ("additional protrusions into a gadget can never increase the number of tiles") is (a) true and (b) equivalent to the lemma I'm looking for. On a different note it would be nice to construct a small unsat problem for testing but it seems there aren't any small enough to be convenient... – j_random_hacker Sep 10 '11 at 18:36
  • @Tom: It seems your excellent answer (I presume you're also "Tom Sirgedasx") was deleted by Jeff Atwood... for reasons I totally fail to understand! I have flagged it for moderator attention, but in the meantime perhaps you could post again as your "real self"? FTR Tom's counterexample, detailed here: http://pastebin.com/bABQmfyX, shows that Keith's splitter gadget is broken as it can actually fit 6 tiles. Hopefully this problem can be overcome -- all we need is a new splitter design. – j_random_hacker Sep 11 '11 at 10:05
  • 1
    FWIW, I found a simpler crossover gadget with my program: http://pastebin.com/EuctLXTU – Tom Sirgedas Sep 12 '11 at 04:45
  • Nifty. It's definitely smaller. It strikes me as a little harder to follow. Mine's large, but it can be broken down into fairly easy-to-explain pieces. I think that for this answer, I'm going to leave things as they are, but we should definitely continue this discussion elsewhere. Send me an email at KeithIrwin@yahoo.com, if you don't mind. I'm planning to put together a paper on this topic, and I'd love your input. – Keith Irwin Sep 12 '11 at 07:15
2

To Keith:

Great work and great explanations! Though, I wrote a program to find maximum tilings, and it uncovered a flaw. Hopefully this can be fixed! [Update: Keith did fix the problem!]

Please check out this link: http://pastebin.com/bABQmfyX (your gadgets analyzed, plus very handy c++ source code)

The problem is that the gadget below can be tiled with 6 dominoes:

y*** ***z
   * *
   ***
   ***
   *x*

-Tom Sirgedas

  • Program usage: copy a circuit (like one above) into a text file. Run the program with the first argument being the filename. – Tom Sirgedas Sep 11 '11 at 15:27
  • Ah, you're right. I see. I think I can fix this, though. The program is really nifty work thanks for doing it. – Keith Irwin Sep 11 '11 at 17:39
  • @Keith: I added a "search for gadget with a given truth table" ability and found some clever designs. Then, I wanted to simplify the design and found your AND gate (haha! It works as a splitter). Replacing the faulty splitter is simple, and fixes your 3SAT example. However, the crossover gadget still seems flawed, and I haven't found a fix yet. See diagrams: http://pastebin.com/pPYVc6RT – Tom Sirgedas Sep 11 '11 at 17:58
  • @Tom: That's definitely an even easier splitter. Neat. However, your method of replacing the splitter in the crossover has a mistake because you didn't adjust things to make the paths all have lengths which are multiples of 3. Specifically, your paths up from the splitter are your problem. If you use the crossover with my (more complex) splitter where the spacing does work out (see revised answer above), it works. And I'm sure that we could redo the crossover with your splitter, it would just require more space fiddling. – Keith Irwin Sep 11 '11 at 18:22
  • 1
    @Keith: Cool, I'll check that out later today. Also, here's my hacky truth table gadget searcher: http://pastebin.com/f9BDUjE6 . And... any thoughts on 2x2 dominoes? :) :) – Tom Sirgedas Sep 11 '11 at 18:45
  • I've been thinking about 2x2 dominoes, but I don't have any really solid ideas yet. Paths are pretty clear, straight-aways being plain, and curves being done by overlapping just a single corner square. I worked out a pretty simple splitter and I feel like the others should be plausible, but I haven't worked them out yet. – Keith Irwin Sep 12 '11 at 07:18
0

Really a good question. This problem is equivalent to finding the size maximum independent set (or maximal clique size) on a special graph - the vertices would be all possible positions of the MxN rectangle and edges would connect the two positions if they collide. Then finding the size of maximum independent set yields the result. Or vice versa, we could define the edge as connecting two positions which do not collide, then we would look for maximum clique size. Anyway, neither graph is neither claw-free nor perfect, so we cannot use polynomial solutions to find maximum independent set / clique.

So, we could try to convert the maximum independent set problem to this tiling problem, but I couldn't find a way how to convert the general graph to this, because you cannot convert e.g. induced K1,5 subgraph to the tiles.

Tomas
  • 57,621
  • 49
  • 238
  • 373
0

1x3 tiles are hard by reduction from cubic planar monotone One-in-three 3SAT. We have to build some "circuitry" to encode the formula.

"Gates":


X********Y

Forces exactly one of X and Y to be covered externally. Used to link a variable and its negation.


Y***
   *
   *
  ooo  ****
  * *  *  *
  * *  *  *
  X ****  Z

Forces none or all of X and Y and Z to be covered externally. Used to copy X or destroy three copies of the same thing. Wires can be shaped more or less arbitrarily using length-3 L pieces.


*******************
*        *        *
*        *        *
X        Y        Z

Forces exactly one of X and Y and Z to be covered externally. One for each clause.

doug
  • 36
  • 2
  • Looks like a promising approach but I'm having trouble following -- e.g. in your last example, I see optimal (5-tile) coverings that cover any 2 of X, Y and Z, or all 3, but not exactly 1 as you say. Also I'm not sure how "inputs" are routed to "outputs" in your scheme -- e.g. for your 3rd snippet, in isolation I can see that there is a single 9-tile optimal configuration that covers all of X, Y and Z, but e.g. if X is already covered by the "output" of another circuit, then among the set of 8-tile configurations that are now optimal, Y and Z may be either covered or uncovered. – j_random_hacker Sep 08 '11 at 17:25
  • @j_random_hacker _cover any 2 of X, Y and Z, or all 3_ I don't see all 3. The idea is that two interfaces are covered by the gadget, and one by the outside world. We put these gadgets together by superimposing their interfaces, and the value on the wire is specified by which side the interface is covered from. – doug Sep 08 '11 at 17:37
  • 1
    I think this is a promising approach! But, I'm not yet convinced. Could you show how the simple input {abc} is solved? Also, how {abc,a'bc} is solved? (explain how a tile-laying solution gives you clause-satisfying variable assignments) – Tom Sirgedas Sep 08 '11 at 17:39
  • What do you do in the case where the graph is planar but some nodes have degree greater than four? How would you map this planar graph into the grid world? – templatetypedef Sep 08 '11 at 18:15
  • @templatetypedef Basically, we ternerize before embedding. It turns out that it's already known that cubic planar monotone one-in-three 3SAT (max degree 3, no negative literals) is hard, so I'll just switch the source problem and at the same time avoid issues with the positive and negative wires crossing. – doug Sep 08 '11 at 19:38
  • I like this approach on the whole, it's much easier than the reduction from 3-SAT that I was going to post (which is equivalent, but way more complex since we don't have the planar assumption). However, your gadgets aren't correct. Namely the copying one doesn't work since in one state it only has 8 dominoes and in the other 9. As such, it doesn't force X, Y, and Z to the same values. If X is 0, then Y and Z being 0 would require 8 dominoes, but so would Y and Z being 1. And since we don't know how many tiles to expect for that part, we can't use the total dominoes to determine the result. – Keith Irwin Sep 09 '11 at 17:24
  • Actually, I should revise my previous comment by noting that it was the extension of your second gate I was commenting on. However, I don't think that your second gate works for roughly the reason that I outlined above. The difficulty is that it varies the number of dominoes used in the maximum tiling depending on which state it is in. Since the problem only answers what the maximum number of tiles in the tiling is, we won't know from that answer whether or not the maximum tiling successfully completed 1-in-3-SAT. (more next comment) – Keith Irwin Sep 10 '11 at 06:29
  • A variance of 1 in the number of maximum tiles could mean either that an XYZ gate had all gates covered externally or that a clause actually has two inputs covered externally and so has had to leave out an internal tile. As such, we can't answer the 1-in-3-SAT problem given only the maximum number of tiles. However, if you can find a way to fix the second gate, then you're solid. My splitter gadget can't be used for this purpose because it's only one-way (which I can get away with only because I'm doing 3-SAT, not 1-in-3-SAT) but if you can find one, your solution is the simpler one. – Keith Irwin Sep 10 '11 at 06:36
  • @Keith Irwin The second gate is fine. It doesn't matter that a particular instance uses n or n+1 tiles because the others will balance it out. – doug Sep 10 '11 at 15:06
  • @doug: Oh, I see what you're saying. You're designing your system such that in a maximal tiling, there will be no empty squares. In that case can you actually make everything match up properly? Your paths and clause gates all work on multiples of 3, but your XYZ gate doesn't. Can these be made to actually connect properly for arbitrary clauses? – Keith Irwin Sep 10 '11 at 15:46
  • @Keith Irwin The XYZ gate forces its three interfaces to be all covered or all uncovered, so it works on multiples of three as well. It can be chained to generate as many copies of a variable as needed, and it can be used to copy and then destroy the negative literal produced by the first gate. – doug Sep 10 '11 at 16:06
  • @doug: I'm sorry. I think I wasn't clear in my question. My question is about how far apart the inputs to the gates are. In the XYZ gate, the inputs are only one space apart. In the paths and the clause gate, they're all multiples of 3 spaces apart. I worry about laying them out so that they can be linked up. Also, on an unrelated note, doesn't your scheme also have a problem filing every square if x and !x aren't both used for some variables? – Keith Irwin Sep 10 '11 at 16:14
  • @Keith Irwin Easy enough to get more space in there (edited). We never use !x because the formula is monotone. We copy !x twice and then eat the three instances with a copy gate. – doug Sep 10 '11 at 17:07
  • @doug: Sure, you can easily add more space, but any added space comes in multiples of 3 and if you need to only be 1 square over, it doesn't matter how many Ls of size 3 you add, you'll never get there. The idea of disposing of !x makes sense, but the implementation you describe doesn't. When viewed from a signal perspective, your copy gate is actually a copy-and-negate gate. If you hook two of them together, you don't actually get three copies of the same thing. For example, let's say we have two copy gates, 1 and 2, and we hook Y1 to Y2 via L's or some other path. (cont.) – Keith Irwin Sep 10 '11 at 17:44
  • If Y1 is externally covered, it follows that Y2 won't be since the dominoes would be shifted towards Y1. As a result, X2 and Z2 also won't be externally covered. So X1=Y1=Z1, but Y2=!Y1=X2=Z2. (Obviously if Y1 is not externally covered the same applies.) So if we hook up an unneeded signal (!x from above) to X1, our output would be Z1 (same as X1), X2 (opposite of X1), and Z2 (opposite of X1). If we hooked these three together to a copy gate to sink them, it wouldn't work because they aren't the same. – Keith Irwin Sep 10 '11 at 17:49
  • @Keith Irwin We can shift inputs using the copy gate. You haven't found a real bug yet, and I'm tired of you not making an effort to repair the problems you find. This conversation is over. – doug Sep 10 '11 at 23:12
  • @doug: Look, I'm doing my best to understand your idea and figure out whether or not it's correct. It may be that it is correct, but thus far, not one person has been convinced that it is. Your answer has no up votes. This is because you haven't explained it clearly or given even one complete example of a 1-in-3-SAT problem reduced to this space. As far as fixing problems, I'm giving it my best shot, but thus far some what I thought were bugs were because I didn't properly understand what was going on. At this point, I feel like I have a complete handle on it, though. (cont.) – Keith Irwin Sep 11 '11 at 00:36
  • @doug: So I'll say this and if you don't want to argue with it, fine. This system, as described cannot work. It depends on the assumption (which you didn't bother to state) that in an optimal tiling, every non-blocked square is filled by a domino. Doing this monotone version, however, requires you to sink !x for any variable x. This is impossible without creating an empty square. Any combination of gates must have k squares and j dominoes in it. If one square is externally covered then k=3j+1. If one square is not externally covered then k=3j. This is impossible. So that's why I didn't fix it. – Keith Irwin Sep 11 '11 at 00:46
  • @doug: And for the record, I tried to fix it. I spent like a half hour this afternoon trying to figure out if there was an alternate way to sink !x. I posted my comment while I was trying to figure it out when I realized that just hooking up copy gates didn't work. Later I realized that it was impossible. It's unfair to say that I didn't try to help fix the problems just because I didn't have any success. – Keith Irwin Sep 11 '11 at 00:49
0

The first thing I would do is make a third state: "empty, but unreachable". You can easily prove each tile unreachable in l*w*m*n time (where l is length of the world, w is width of the world, and m and n are dimensions of the tile). This will reduce your space such that any empty tile is reachable. Note that you may have islands of reachable tiles. The simplest example of this is that the world is cut in half. This lends itself to a recursive effort where each island of reachability is treated as a world in and of itself.

Now that we're dealing with an island (which may or may not be square) you essentially have a special case of the 2D knapsack problem, which is known to be NP-hard (citation under Previous Work). Yours increases complexity of the problem by adding fixed positions in the knapsack that always filled, but reduces complexity (slightly) by making all packages the same size.

corsiKa
  • 81,495
  • 25
  • 153
  • 204
  • Edit: provided a better citation. – corsiKa Sep 08 '11 at 20:24
  • 1
    A special case of an NP-hard problem is not necessarily NP-hard. For example, "Hamiltonian path on acyclic graphs" is in P. – Tom Sirgedas Sep 09 '11 at 00:19
  • 1
    @Tom that is true. However, when you increase complexity of an NP-hard problem I cannot imagine it not remaining at least NP-hard. – corsiKa Sep 09 '11 at 00:25
  • For 1x3 dominoes, the 2D knapsack is in P, right? Adding fixed positions in the knapsack does make the problem harder, but not necessarily NP-hard. – Tom Sirgedas Sep 09 '11 at 14:58
  • @Tom for an MxN domino, which is already NP-hard, adding fixed positions only increases its complexity. – corsiKa Sep 09 '11 at 15:49
  • "for an MxN domino, which is already NP-hard" -- I don't think this is true. Think about the 2D knapsack problem with only 10x10 dominoes. It is solved by a simple formula (not NP-hard). Now, glowcoder's problem is in P for 1x2 dominoes. But, what about 1x3 dominoes? For what values of M and N do you claim that the problem is NP-complete? – Tom Sirgedas Sep 09 '11 at 17:01
  • @Tom please see the citation in my article (under Previous Work) where the 2D knapsack problem is NP-hard for any set of dominoes. The paper it cites is "A population heuristic for constrained two-dimensional non-guillotine cutting, European Journal of Operational Research, vol.156, 2004, pp601-627" if you would like to review it yourself. I personally do not have access to view the 2004 paper, so I can't verify it myself, but according to the citation in my post, the paper I describe in this comment claims the problem is NP-hard. I have no reason to doubt the claim. – corsiKa Sep 09 '11 at 17:17
  • @glowcoder There's a paper of that title from that journal from 2000 accessible here: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.35.7084 and then they apparently published another paper with the same title in the same journal four years later, which is odd, to say the least. However, neither version talks about whether or not the 2-D knapsack problem is NP hard at all. Neither version of the paper even contains the string "NP". So that citation is definitely an error. I'm not sure what paper the author meant to be citing. – Keith Irwin Sep 09 '11 at 21:53
  • Also, it's clearly not the case that it's NP hard for any set of dominoes. The algorithm from the previous question demonstrates that, it's not even NP-hard for 1x2 dominoes with constrained tiles. Likewise, we know that it's certainly not NP-hard given a set of equally-sized, equally-weighted square tiles since we know that if the square is SxS and the rectangular area is LxW the optimal packing would simply have floor(L/S)*floor(W/S) tiles in it (which is what Tom is pointing out with the 10x10 example above). So it's not clear that this problem is NP-hard using that reasoning. – Keith Irwin Sep 09 '11 at 22:03