Forum Discussion
Find Biggest, Middle and Smallest Value
- 5 years ago
This seems overly complicated to me. There are only six possible ways to orient a 3D rectangular item relative to a 3D rectangular box (assuming we ignore shifts and diagonal arrangments). Hence, we can have the computer try all of them "brute force" rather than worrying about matching small/medium/large (especially since that may not be the optimal packing anyway).
MaxFit = VAR BoxH = SELECTEDVALUE ( Boxes[BOX_HEIGHT] ) VAR BoxW = SELECTEDVALUE ( Boxes[BOX_WIDTH] ) VAR BoxD = SELECTEDVALUE ( Boxes[BOX_DEPTH] ) VAR ItemH = SELECTEDVALUE ( Items[M1HEIGHT] ) VAR ItemW = SELECTEDVALUE ( Items[M1WIDTH] ) VAR ItemL = SELECTEDVALUE ( Items[M1LENGTH] ) VAR Case1 = INT ( BoxH / ItemH ) * INT ( BoxW / ItemW ) * INT ( BoxD / ItemL ) VAR Case2 = INT ( BoxH / ItemH ) * INT ( BoxW / ItemL ) * INT ( BoxD / ItemW ) VAR Case3 = INT ( BoxH / ItemW ) * INT ( BoxW / ItemH ) * INT ( BoxD / ItemL ) VAR Case4 = INT ( BoxH / ItemW ) * INT ( BoxW / ItemL ) * INT ( BoxD / ItemH ) VAR Case5 = INT ( BoxH / ItemL ) * INT ( BoxW / ItemH ) * INT ( BoxD / ItemW ) VAR Case6 = INT ( BoxH / ItemL ) * INT ( BoxW / ItemW ) * INT ( BoxD / ItemH ) RETURN MAXX ( { Case1, Case2, Case3, Case4, Case5, Case6 }, [Value] )In N dimensions, there are N! case permutations and it would be better to generate them more programmatically, but with 3! = 6, it's not worth the bother.
With the data from b2wise, only item 3D-AWPTC-250 fits in any of the given boxes (with V07 able to fit the most).
If we assume items are listed in centimeters and boxes in inches, then things aren't quite so bad (only 3D-HVE can't fit in any box).
This seems overly complicated to me. There are only six possible ways to orient a 3D rectangular item relative to a 3D rectangular box (assuming we ignore shifts and diagonal arrangments). Hence, we can have the computer try all of them "brute force" rather than worrying about matching small/medium/large (especially since that may not be the optimal packing anyway).
MaxFit =
VAR BoxH = SELECTEDVALUE ( Boxes[BOX_HEIGHT] )
VAR BoxW = SELECTEDVALUE ( Boxes[BOX_WIDTH] )
VAR BoxD = SELECTEDVALUE ( Boxes[BOX_DEPTH] )
VAR ItemH = SELECTEDVALUE ( Items[M1HEIGHT] )
VAR ItemW = SELECTEDVALUE ( Items[M1WIDTH] )
VAR ItemL = SELECTEDVALUE ( Items[M1LENGTH] )
VAR Case1 = INT ( BoxH / ItemH ) * INT ( BoxW / ItemW ) * INT ( BoxD / ItemL )
VAR Case2 = INT ( BoxH / ItemH ) * INT ( BoxW / ItemL ) * INT ( BoxD / ItemW )
VAR Case3 = INT ( BoxH / ItemW ) * INT ( BoxW / ItemH ) * INT ( BoxD / ItemL )
VAR Case4 = INT ( BoxH / ItemW ) * INT ( BoxW / ItemL ) * INT ( BoxD / ItemH )
VAR Case5 = INT ( BoxH / ItemL ) * INT ( BoxW / ItemH ) * INT ( BoxD / ItemW )
VAR Case6 = INT ( BoxH / ItemL ) * INT ( BoxW / ItemW ) * INT ( BoxD / ItemH )
RETURN
MAXX ( { Case1, Case2, Case3, Case4, Case5, Case6 }, [Value] )
In N dimensions, there are N! case permutations and it would be better to generate them more programmatically, but with 3! = 6, it's not worth the bother.
With the data from b2wise, only item 3D-AWPTC-250 fits in any of the given boxes (with V07 able to fit the most).
If we assume items are listed in centimeters and boxes in inches, then things aren't quite so bad (only 3D-HVE can't fit in any box).
AlexisOlson Could be, but it would be interesting to know if 10 slightly more complicated calculations runs faster or slower than 10! slightly simpler calculations. Also depends on if you want a matrix of options or just the answer.
- AlexisOlson5 years ago
Super User
The factorial corresponds to the number of dimensions, not the number of boxes or items. As long as we're talking about normal 3D boxes, it's never more than six orientation possibilities per box and item and is super cheap computationally.
It's also easy to adapt what I've proposed to return a yes/no fit check ( if [MaxFit] > 0 ) or find the minimum volume box that fits a particular item ( take the min volume over boxes with [MaxFit] > 0 ).