^[      $A B consists of the remaining capacity together with a list of items  already placed. Given a  for bs and a list of items [b], an  returns ( a re-ordered version of the item list. Given a  , an item b, a list of capacities [a], and a list of  bins [ b] , a placement heuristic returns Just an updated lists of 6 capacities and bins if the item could be placed, and Nothing otherwise. A function that maps an item b to its size a. The constraint (  a,  a)@ has been omitted from the type, but is required by the exposed  functions. How to pre-process the input. Sort from smallest to largest. Sort from largest to smallest. Don't modify item order. !KReorder items prior to processing. Items are placed into bins in the order  from largest to smallest. "KReorder items prior to processing. Items are placed into bins in the order  from smallest to largest. Create an empty bin. The initial capacity. The empty bin. 2Create multiple empty bins with uniform capacity. The initial capacity. Number of bins. Try placing an item inside a . The item's size.  The item.  The bin. #' the updated bin with the item inside,  $ if it does not fit. Place an item inside a +. Fails if there is insufficient capacity. The item's size.  The item.  The bin. #' the updated bin with the item inside,  $ if it does not fit. :Add a list of items to an existing bin. Fails if there is  insufficient capacity. "The bin that should be augmented. !A function to determine each item's size.  The items that are to be added. The resulting bin. ,Turn a list of items into a pre-filled bin. % Get the items in a bin. %Get the remaining capacity of a bin. &'()*+,-./012344! traverses the list of items and 0 tries to place each in a bin. If an item doesn't fit anymore, then a new : empty bin is created and the item is placed in that bin. 5?Actual binpacking function. Tries to place each item in order.  Function to  place on item.  The bins. Items yet to be placed. Items that didn't fit anywhere (accumulator). $ !" % &'()*+,-./012345$ !" % &'()*+,-./012345678ISplit items into the A,B,C,D groups of the MFF algorithm. Only A, C, and  | the rest are returned. 967896789:GSum of squares metric. The sum of the square of the counts of each gap 4 size, ignoring empty and completely-packed bins.  The bins. Sum of the squared gapCounts. ;8Pick a bin that minimizes the sum-of-squares heuristic. <<sosfit, but without the option of adding an additional bin. =Fsofit, which may add a bin if it lowers the sum-of-squares heuristic. :;<=:;<=)What placement heuristic should be used? $Choose bin such that sum-of-squares  heuristic is minimized.  Choose the 2nd to worst-fitting  bin. Place item in the bin with the " least (but sufficient) capacity. Place item in the bin with the  most capacity. Traverse bin list from > to  ? and place item in the first # bin that has sufficient capacity.  See above. Traverse bin list from ? to  > and place item in the first # bin that has sufficient capacity. The list of all possible  choices. The list of all possible  choices. -All supported ordering and placment choices. @JBin-packing without a limit on the number of bins (minimization problem). NAssumption: The maximum item size is at most the size of one bin (this is not  checked).  Examples:  Pack the words of the sentence *"Bin packing heuristics are a lot of fun!" H into bins of size 11, assuming the size of a word is its length. The  A ordering yields a sub-optimal result that leaves a lot of empty  space in the bins.  _ minimizeBins FirstFit Increasing length 11 (words "Bin packing heuristics are a lot of fun!") X ~~> [(2,["are","Bin","of","a"]),(4,["fun!","lot"]),(4,["packing"]),(1,["heuristics"])]  Similarly, for A. Note that we use B as a  of the size of an A. ; minimizeBins FirstFit Decreasing id 11 [3,7,10,3,1,3,2,4] * ~~> [(0,[1,10]),(0,[4,7]),(0,[2,3,3,3])] )How to order the items before placement. "The bin-packing heuristic to use. How to size the items. The size of one bin.  The items. The result: a list of Bins. Wrapper around (; useful if only the number of required bins is of interest. See % for a description of the arguments.  Examples: W How many bins of size 11 characters each do we need to pack the words of the sentence *"Bin packing heuristics are a lot of fun!"?  \ countBins FirstFit Increasing length 11 (words "Bin packing heuristics are a lot of fun!")  ~~> 4  Similarly, for A. As before, we use B as a  for the size of an A. 8 countBins FirstFit Decreasing id 11 [3,7,10,3,1,3,2,4]  ~~> 3 IBin-pack a list of items into a list of (possibly non-uniform) bins. If L an item cannot be placed, instead of creating a new bin, this version will ; return a list of items that could not be packed (if any). DExample: We have two empty bins, one of size 10 and one of size 12. * Which words can we fit in there?  s binpack WorstFit Decreasing length [emptyBin 10, emptyBin 12] (words "Bin packing heuristics are a lot of fun!") P ~~> ([(0,["Bin","packing"]),(0,["of","heuristics"])],["a","lot","are","fun!"]) 0Both bins were filled completely, and the words "are a lot fun!" coult not be  packed. "The bin packing heuristic to use. )How to order the items before placement. How to size the items. -The bins; may be non-uniform and pre-filled.  The items. The result; a list of bins $ and a list of items that could not  be placed.    C      !"#$%#&'()*#+,#+-./0123456789:;<=>?@ABCDEF#GH#GIJKLM#NOP Binpack-0.4 Data.BinPackData.BinPack.InternalsData.BinPack.Internals.MFF#Data.BinPack.Internals.SumOfSquaresBinMeasure OrderPolicy Increasing DecreasingAsGivenemptyBin emptyBins tryAddItemaddItemaddItemsasBinitemsgapPlacementPolicySumOfSquaresFitAlmostWorstFitWorstFitBestFitLastFitModifiedFirstFitFirstFit allPlacements allOrders allHeuristics minimizeBins countBinsbinpackOrder PlacementbaseGHC.NumNum GHC.ClassesOrdorder decreasing increasing Data.MaybeJustNothingmakeBinupdateinsertAtremoveIfxfitbestfitworstfitfirstfitlastfitalmostWorstfit chooseBest chooseWorstchooseAlmostWorstwithTieBreakOnwithReverseTieBreakOnminimizebinpack' minimizeMFF binpackMFFsplitMFFpackCs sumOfSquaressosfit' sosfitAnyFitsosfitGHC.Listlasthead placementghc-prim GHC.TypesIntGHC.Baseid