LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2009)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 15 Sep 2009 05:51:47 -0400
Reply-To:   Clive Downs <clive.downs@READING.GOV.UK>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Clive Downs <clive.downs@READING.GOV.UK>
Subject:   Combinations
Content-Type:   text/plain; charset=ISO-8859-1

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


Back to: Top of message | Previous page | Main SPSSX-L page