in reply to Re: "Divide" challenge
in thread "Divide" challenge

Well, it scales like N! which is exponential. Which doesn't scale well at all. It basically means that if your CPU speed doubles, you can increase your problem space by 1 to get an answer in the same time.

And I don't think you can avoid a brute force approach. This sounds very much like an NP complete problem.

Replies are listed 'Best First'.
Re^3: "Divide" challenge
by ELISHEVA (Prior) on Mar 11, 2009 at 10:41 UTC
    I don't think you can avoid a brute force approach

    Although I agree that the general problem is likely NP complete, there are probably at least some things one might do,singly or in combination, to pick out more or less likely solutions (and hence improve the likelihood that the first of N solutions contains something close to the optimal solution - i.e. we limit he number of solutions tried to N since we don't have infinite computing resources). I don't have the time to really think these through (or relearn my linear algebra), but someone else might like to pick up the ball on these ideas:

    • There are probably some special groups of data-flow matrices that could be quickly solved analytically by simplifying the dataflow matrix using using eigenvectors and other linear algebra techniques.
    • It might help to calculate the distribution of data flow values and use the distribution to prioritize which combinations of rows and columns should be tried first.

    Best, beth

    Update: in response to JavaFan's "I don't see how that could help" note below, added clarification of reason for picking more or less likely solutions.

      It might help to calculate the distribution of data flow values and use the distribution to prioritize which combinations of rows and columns should be tried first.

      I don't see how that can help. It may help if you can eliminate large groups of possibilities, but as long as you have to try them all, it doesn't matter is which order you do them.

        If a problem is NP complete, it is unlikely you are ever going to try all possible solutions (at least for large values of N). Instead your only option is to improve the probability that a correct answer will fall within the first X solutions tried. In that respect, order matters a great deal.

        Best, beth

Re^3: "Divide" challenge
by JavaFan (Canon) on Mar 11, 2009 at 10:56 UTC
    Here's how it "scales". First column is the number of machines. Second column is the number of times you can divide that number of machines in two equally sized groups:
    use Math::BigInt; use 5.010; my $line = "+----+------------------------+"; say $line; printf "| %2d | %22s |\n", 2 * $_, Math::BigInt->new(2 * $_)->bfac / (2 * Math::BigInt->new($_)->bfac +) for 1 .. 16; say $line; __END__ +----+------------------------+ | 2 | 1 | | 4 | 6 | | 6 | 60 | | 8 | 840 | | 10 | 15120 | | 12 | 332640 | | 14 | 8648640 | | 16 | 259459200 | | 18 | 8821612800 | | 20 | 335221286400 | | 22 | 14079294028800 | | 24 | 647647525324800 | | 26 | 32382376266240000 | | 28 | 1748648318376960000 | | 30 | 101421602465863680000 | | 32 | 6288139352883548160000 | +----+------------------------+