MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: 0/1 knapsack-like minimalization problem and


Ok, I admit that I was only looking at the first part of the problem,
not the extension of the problem.  I am also assuming that you have
already used FileNames[] and FileByteCount[] to get the information in
a list {size -> filename, ...}

In[1]:=
list = {3.4 -> "File1", 2.1 -> "File2", 6.5 -> "File3", 4.2 ->
"File4"};

In[2]:=
dist[a_, b_] := If[a <= b, b - a, 10*^10]

In[3]:=
Nearest[list, 3.3, DistanceFunction -> (dist[#2, #1] & )]

Out[3]= {"File2"}

The dist[] function is to take care of the less than condition.  There
may be more elegant ways of doing this.

Daniel


  • Prev by Date: Re: Calling kernel.dll from Mathematica
  • Next by Date: Re: Resolution Time Study
  • Previous by thread: Re: Calling kernel.dll from Mathematica
  • Next by thread: Re: Resolution Time Study