For pallet stability you would like to have a convex perimeter so the stretch wrapping maintains the boxes effectively. And also criss-crossing boxes for shear resistance.
But you need to align as much boxes corners as possible to get vertical stiffness.
A solver proposing stacking patterns with these constraints would be outstanding.