Returns optimal fill mass for a resource to be packaged, and number of packages that can be crated at that fill mass (note that up to one additional package may be possible to create with a lower fill mass, which much be checked separately).
Can be used to determine how to respond to requests for material, and to actually package and send off trades. Packaging strategy "first" simply fills the packages one by one to the maximum fill. Therefore, it should always try to max fill. Packaging strategy "equal" tries to fill all packages to the same mass. This tries to find the optimal number and fill mass of packages given the packaging limitations. It does this by calculating bounding fills, floor(quantity/fill_min) and ceiling(quantity/fill_max). Packaging strategy "uniform" fills packages with a random mass between fill_min and fill_max, if at least fill_max is available. If less than fill_max is available, a partial package is filled with the total mass. Packaging strategy "normal" fills packages with a random mass between fill_min and fill_max, with a normal distribution. Mean is the middle of fill_min and fill_max, standard deviation is 1/6 of the range such that 3 sigma is the range. If less than fill_max is available, a partial package is filled with the total mass (no dist sampling). There might be a scenario where there is no solution, i.e. an integer number of packages cannot be filled with no remainder. In this case, the most effective fill strategy is to fill to the max. Numeric example: quantity = 5, fill_min = 3, fill_max = 4. num_min_fill = floor(5/3) = 1, num_max_fill = ceil(5/4) = 2. num_min_fill < num_max_fill, so fill to the max.
Definition at line 45 of file package.cc.