|
Hi
I would like to work out that combination of a set of specified items
whose total weight will be closest to 16.50 kg. (from the example data
set, syntax below, weight is in kg).
Any number of combinations can be used. I think the hard part is working
out all possible combinations, and collating them into a data set; once
that bit is done it is easy to clean out duplicates, and figure out the
total weight for each combination, and then get the closest ones.
Clearly this is a combinatorial problem and I have looked at Raynald
Levesque’s macro * !combine* from Aug 30, 2001 -
http://pages.infinit.net/rlevesqu/Syntax/Combinations/FindAllCombinationsOf
NitemsOutOfMitems.txt
- that macro is I think mainly designed to work our combinations of
strings. I can see how in principle it might be adapted, but I wondered if
anyone can think of a better solution?
Thanks
Clive.
* syntax to create sample data.
* ----------------------------.
DATA LIST FREE/ item(A15) weight.
BEGIN DATA
shoes 3.00
watch 0.25
book 1.00
fridge 15.00
toaster 4.50
END DATA.
DATASET NAME picklist.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|