A Constraint Programming Approach to Solving a Ship Loading Problem Andreas Jordan Professor Markus Stumptner Background • Currently, load plans for amphibious ships are • created by ‘dragging and dropping’ representative size boxes into a trim and stability software program. • There is a requirement for some automated support • when planning loads for both the amphibious ‘mother ships’ and associated watercraft conducting landings / withdrawals. 2 Objectives • The primary objective • minimise the space used by the loads => minimising the number of amphibious ships and watercraft to conduct operations. • Near-optimal solutions preferred within the order of seconds • The load must also produce a stable load plan 3 Problem Description • Belongs to the general class of “Bin Packing Problems” • Description: • The packing of a finite number of rectangles into a number of larger sized bins where: • No items are allowed to extend past the edges of the bin nor any overlap permitted. • The challenge is to assign all the items, with no overlap, to the minimum number of bins with their edges parallel to those of the bins. • Problem is NP-Hard (ie. cannot be solved in polynomial time) • Exhaustive search impractical. Therefore, heuristical methods are required for most practical problems. 4 Sourcing Software • Description of problem readily lends itself to modelling as a Constraint Optimisation Problem (COP) • Possible choices:• • • • • Matlab Eclipse Prolog ILOG CPLEX® Comet • Selection criteria • • • • Acquisition costs Optimised libraries with pre-built constraint-reasoning functionality Availability of Global Constraints (eg. selectMin) => Comet 5 Modelling as a Constraint Optimisation Problem • Determine the finite domain decision variables • • • • Packing – establishes a relationship between an item and a bin. eg. Load – tracks the current load of each bin X – represents x-positions within each bin Y – represents y-positions within each bin • Domains • Items – represents the number of items to be packed • Bins – total number of bins • Constraints • Constrain load of bin • Constrain placement of items within bin • Minimise the number bins used to pack items 6 Packing Heuristic Selection • Several packing algorithms exist, including:• Finite-First-Fit • Bottom-Left-Fill • …and many more • Most not suitable for this application:• they typically require items to be sorted in non-decreasing order • no advantage taken of additional attributes (eg. weight) • Key requirements, including:• Prioritisation of items – Strict, Flexible and None • Stability of packing (lateral and longitudinal) • Can make no assumptions about the distribution of item sizes 7 Packing Barrier (Heidelberg et al,1998) • Nine barrier types • • • • C, RL, LR, LCR, CLR, LRC, RCL, RLC, CRL Barrier composed of (up to) 5 segments Pack item into lowest barrier LX, LY, CX, RX, RY represent cartesian barrier coordinates LX C RL LR LCR CLR LRC RCL RLC CRL LY RY CX RX Packed items 8 Representing Variables in Comet • Example • var<CP>{int} packing[Items](cp, Bins); • Explanation • Var<CP> - declaration for a finite domain decision variable • {int} – declares that the domain comprises discrete integers • packing[Items] – name of variable where “Items” represent the range of variables associated with ‘packing’ • (cp, Bins) - range of valid integer values that each variable can take. • This representation allows the constraint solver to reason • packing[1] = 1..12 •… • packing[100] = 1..12 9 Representing Constraints in Comet Solver<CP> cp(); //declare the variables Solve<cp>{ //post the constraints //Constraint which ensures that the load of any bin is less than or equal to a bins capacity forall(b in Bins) cp.post((load[b] == sum(i in Items) (packing[i]==b)*itemWeight[i]) && load[b] <= binCapacity_) ; } using{ //non deterministic search } 10 Preliminary Results • 4 items ==== Post-processing Results ==== Solution found with: 2 bins load[43800,42000,0,0,0,0,0,0,0,0] packing[1,2,1,1] x[0,0,34,44] y[0,0,0,0] #Choices = 8 #fail = 0 Time: 0 seconds ==== End ==== • 8 items ==== Post-processing Results ==== Solution found with: 2 bins load[45400,44000,0,0,0,0,0,0,0,0] packing[1,2,1,1,1,2,2] x[0,0,34,0,18,0,15] y[0,0,0,96,96,96,96] #Choices = 39728 #fail = 158149 Time: 4 seconds ==== End ==== • >8 items (using Windows machine with 2GB RAM) • runs out of virtual ram after approximately 3 hours 11 Further Work • Implement item placement based on multi-tiered priorities • Incorporate centre-of-gravity calculations to build solutions already favouring a stable load • Automatic barrier adjustment after failing to insert any items • Adjust upper bound on item length to be uppermost adjacent level plus/minus a tolerance, t. • Incorporate No-Go zones 12 Thankyou • Questions? Source: Wikipedia …different watercraft and ship types should be considered Source: http://www.tomw.net.au/technology/transport/amphibious.shtml 13 References • Dyckhoff, H 1990, 'A typology of cutting and packing problems', European Journal of Operational Research, vol. 44, no. 2, pp. 145-159. • Sexton, J, et al. 2004, Efficient Solutions in Load Planning, DEFENCE SCIENCE AND TECHNOLOGY ORGANISATION SALISBURY (AUSTRALIA) SYSTEMS SCIENCES LAB. 14