On Fri, Jan 27, 2012 at 09:22:26PM -0500, Andrei Alexandrescu wrote: [...] > I wasn't thinking necessarily of the standard library, but it is > something that is often needed even if not perceived as such. For > example, the stock screeners offered by financial sites are crappy - > they allow you to specify a range of e.g. P/E, P/book value, dividends > etc. etc. and sort by one of those. This is crappy - generally what > one wants is a selection of "best of breed" stocks that are among the > top ones in a variety of categories. (Relative importance could be > assigned to each category.) [...]
If I understand the problem correctly, isn't this a kind of optimization problem? I.e., given a set A of k objects with n attributes, find the object(s) that maximizes a given measure function f over its attributes, where f is a weighted sum of n attributes. If you treat the attributes as components of an n-dimensional vector, then you could recast the problem as the convex hull of k hypercuboids, where each hypercuboid lies between (0,0,0,...) and (x1,x2,x3,...). The points on the convex hull then are the high-ranking points (points inside the hull are obviously suboptimal). Furthermore, the closest points to the line spanned by the vector (1,1,1,...) are the points that maximize the most number of attributes. If you "peel away" the points on the convex hull, then the convex hull generated by the remaining points gives you the "second class" points. Peel away those, and the convex hull gives you the "third class" points, etc.. Granted, this isn't exactly the original problem as stated, but it seems to be closer to what you intend to achieve with your stocks example. T -- If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher