Thanks. I actually prototyped in Perl the SA method intuitively (though I do not know its name). But it is way slow. So I want to improve the speed by means of both algorithm and language.<br><br>Hong<br><br><div class="gmail_quote">
On Wed, Nov 11, 2009 at 9:36 AM, Tillmann Vogt <span dir="ltr">&lt;<a href="mailto:Tillmann.Vogt@rwth-aachen.de">Tillmann.Vogt@rwth-aachen.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hong Yang schrieb:<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The question is more about algorithm than Haskell. But I am going to code in<br>
Haskell which I am still learning.<br>
<br>
Suppose I have a large table, with hundreds of columns and thousands of<br>
rows. But not every cell has a value (of String, or Int, or Double type).<br>
<br>
I want to shuffle the rows to maximize the number of columns whose first 100<br>
rows have at least one number, given a list of preferred column names since<br>
there is no guarantee that every number column will have at least one number<br>
in its first 100 rows after shuffling.<br>
<br>
Can someone provide a good algorithm for this problem? (I do not have any<br>
background in algorithms.) You can assume I already know which columns are<br>
of Int or Double type.<br>
</blockquote>
<br></div>
I would say it depends on the distribution of values in the table. If there are rows with a lot of values and rows with few values, then I would first sort the rows after the number of cells with values. If you look at all the columns and the number of values for each row is unique then it would be perfectly solved. With a list of preferred columns and also a uniform distribution the problem might be hard (NP-complete?), but these hard problems can often be approximated, i.e with simulated annealing, which in short is switching two rows repeatedly as long as the result improves.<div>
<div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
This is not a homework.<br>
Thanks,<br>
<br>
Hong<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br>