Expert Systems With Applications: M. Rodriguez-Molins, M.A. Salido, F. Barber
Expert Systems With Applications: M. Rodriguez-Molins, M.A. Salido, F. Barber
a r t i c l e i n f o a b s t r a c t
Keywords: Maritime container terminals are facilities where cargo containers are transshipped between ships or
Planning between ships and land vehicles (tucks or trains). These terminals involve a large number of complex
Heuristics and combinatorial problems. One of them is related to the Container Stacking Problem. A container yard
Optimizing is a type of temporary store where containers await further transport by truck, train or vessel. The main
Container Stacking Problem
efficiency problem for an individual stack is to ensure easy access to containers at the expected time of
transfer.
Stacks are ‘last-in, first-out’ storage structures where containers are stocked in the order they arrive.
But they should be retrieved from the stack in the order (usually different) they should be shipped. This
retrieval operation should be efficiently performed, since berthing time of vessels and the terminal oper-
ations should be optimized. To do this, cranes can relocate containers in the stacks to minimize the rear-
rangements required to meet the expected order of demand for containers.
In this paper, we present a domain-dependent heuristically guided planner for obtaining the optimized
reshuffling plan, given a stacking state and a container demand. The planner can also be used for finding
the best allocation of containers in a yard-bay in order to minimize the number of reshuffles as well as to
be used for simulation tasks and obtaining conclusions about possible yard configurations.
2011 Elsevier Ltd. All rights reserved.
0957-4174/$ - see front matter 2011 Elsevier Ltd. All rights reserved.
doi:10.1016/j.eswa.2011.07.098
M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989 979
Fig. 2. A container yard (left) and gantry cranes (right) (Photos by Stephen Berend).
980 M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989
The main difference is in the problem goal specification. In the goal container ?x-container and
Blocks World domain the goal is to get the blocks arranged in a ready ?x-container:
certain layout, specifying the final position of each block. In the
Container Stacking Problem the goal state is not defined as – Numerical predicates. The first one stores the number of
accurately, so many different layouts can be a solution for a containers stacked on a given row and the second one counts
problem. The goal is that the most immediate containers to load the number of container movements carried out in the plan.
are in the top of the towers, without indicating which contain-
height ?s-row and num moves:
ers must be in each tower.
Actions:
We can model our problem by using the standard encoding – The crane picks the container ?x which is in the floor of row
language for classical planning tasks called PDDL (Planning ?r.
Domain Definition Language) (Ghallab et al., 1998) whose pur-
pose is to express the physical properties of the domain under pick ð?x-container ?r-rowÞ:
consideration and it can be graphically represented by means of – The crane puts the container ?x, which is holding, in the
tools as (Hatzi, Vrakas, Bassiliades, Anagnostopoulos, & Vlahavas, floor of row ?r.
2010). A classical AI planning problem can be defined by a tuple
hA, I, Gi, where A is a set of actions with preconditions and effects, put ð?x-container ?r-rowÞ:
I is the set of propositions in the initial state, and G is a set of – The crane unstacks the container ?x, which is in row ?r,
propositions that hold true in any goal state. A solution plan to from the container ?y.
a problem in this form is a sequence of actions chosen from A
that when applied transform the initial state I into a state of unstack ð?x-container ?y-container ?r-rowÞ:
which G is a subset.
– The crane stacks the container ?x, which is currently hold-
Following the PDDL standard, a planning task is defined by
ing, on container ?y in the row ?r.
means of two text files. The domain file, which contains the
common features for problems of this domain and the problem stack ð?x-container ?y-container ?r-rowÞ:
file, which describes the particular characteristics of each
problem. These two files will be described in the following – Finally, we have defined two additional actions that allow to
subsections. check whether a given (goal) container is ready, that is, it is
in a valid position. When a container is clear:
2.1. Domain specification fict check1 ð?x-containerÞ:
In this file, we will specify the objects which may appear in the The container is under another (goal) container which is in a valid
domain as well as the relations among them (propositions). More- position.
over, in order to make changes to the world state, actions must
fict check2 ð?x-container ?y-containerÞ:
be defined.
Object types: containers and rows, where the rows represent the As an example of PDDL format, we show in Fig. 3 the specifica-
areas in a yard-bay in which a tower or stack of containers can tion of the stack operator. Preconditions describe the conditions
be built. that must hold to apply the action: crane must be holding con-
Types of propositions: tainer ?x, container ?y must be clear and at row ?r, and the num-
– Predicate for indicating that the container ?x is on ?y, which ber of containers in that row must be less than 4. With this
can be another container or, directly, the floor of a row constraint we limit the height of the piles. The effects describe
(stack). the changes in the world after the execution of the action: con-
on ?x-container ?y-ðeither row containerÞ: tainer ?x becomes clear and stacked on ?y at row ?r, and the crane
is not holding any container. Container ?y becomes not clear and
– Predicate for indicating that the container ?x is in the tower the number of movements and the containers in ?r is increased
built on the row ?r. in one unit.
at ?x-container ?r-row:
– Predicate for stating that ?x, which can be a row or a con-
tainer, is clear, that is, there are no containers stacked on it.
clear ?x-ðeither row containerÞ:
– Predicate for indicating that the crane used to move the con-
tainers is not holding any container.
crane empty:
– Predicate for stating that te crane is holding the container
?x.
holding ?x-container:
– Predicates used to describe the problem goal. The first one
specifies the most immediate containers to load, which must
be located on the top of the towers to facilitate the ship load-
ing operation. The second one becomes true when this goal
is achieved for the given container. Fig. 3. Formalization of the stack operator in PDDL.
M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989 981
2. Increasing the range of the move actions set for the cranes how many tiers cranes work. This topic has been considered in
allowing to move a container to 5th tier (OC1t). Salido, Sapena, and Barber (2009). But, another approach is to
3. Applying different ways of balancing within the same bay in reach the fifth tier only during the remarshalling process. Thereby,
order to avoid sinks (OC1b). there would be 4 tiers at the beginning and the end keeping the
first requirements.
These criteria have been easily incorporated in our planner by Following this concept, we will use instances of problems hn, 4i
defining a heuristic function as a linear combination of two with a domain whose move actions allow 5 tiers at the stacks. This
functions: function is showed in Algorithm 3 and it follows the same steps
than the original but increasing the value of h when the height of
hðsÞ ¼ a h1 ðsÞ þ b h2 ðsÞ ð1Þ
one of the stacks is higher than 4. Thereby, we assure that the final
being this secondary function a combination of these three criteria layout will always have 4 tiers.
described:
h2 ðsÞ ¼ OC 1d þ OC 1t þ OC 1b ð2Þ Algorithm 3. Pseudo-code of the domain-dependent heuristic
function to allow 5 tiers
Note that although we want to guarantee balancing with this last
Data: s: state to evaluate
optimization criterion, unbalanced states (states with sinks) are al-
Result: h: heuristic value of s
lowed during this process of remarshalling in order to get better
h 0;
solutions according to the number of reshuffles done.
if $x-container/Holding(x) 2 s then
if GoalContainer(x) then
4.1. OC1d: placing goal containers close to cargo side
h 0.1;
else
Given an initial state, several different layouts can be usually
h 0.5;
achieved making the same number of reshuffles and some of them
end
can be more interesting than the rest according to other important
end
questions. In this case, since the transfer crane is located at the
for r 1 to numRows(s) do
right side of the yard-bay, we want to obtain a layout where it is
Dh 0;
minimized the distance of the goal containers to this side of the
if Height[r, s]> 4 then
yard-bay. Achieving this we can spend considerably less time dur-
if x-container/Clear(x, r) 2 s ^ GoalContainer(x) then
ing the truck loading operations.
Dh 0.5;
Following the heuristic function presented in Eq. (1):
else
Dh 1;
h1(s) is the main heuristic function, which estimates the num-
end
ber of movements required to reach the goal layout (outlined
end
in Algorithm 1). Since this is the main optimization function,
for x-container/At(x, r) 2 s ^ GoalContainer(x) do
a value should be significantly higher than b.
if 9
= y-container/GoalContainer (y)^ On(y, x) 2 s then
h2(s) is the secondary function we want to optimize. In this case,
Dh max (Dh, NumContainersOn(x));
it is just OC1d. This means the sum of the distances of the
end
selected containers to the right side of the yard-bay, which
end
can be computed as Algorithm 2 shows.
h h + Dh;
end
Algorithm 2. Pseudo-code to calculate the distance
Data: s: state to evaluate 4.3. OC1b: balancing one yard-bay
Result: d: distance value of s
d 0; In this section we present an extension for the heuristic h1
for r 1 to numRows(s) do (Algorithm 1) to include the balancing of the stacks within one
for x-container/At(x, r) 2 s ^ GoalContainer(x) do yard-bay as a requirement. It is considered that there is a sink
d d + (NumRows(s) r); when the height difference between two adjacent stacks in the
end same yard-bay is greater than a maximum number of containers,
end in our case two containers.
Considering the time when the goal containers are removed
from the yard, we can distinguish three ways to get balanced one
The benefits of using this combined heuristic function can be yard-bay presented in the next subsections. The last mode is the
observed in Figs. 5 and 6. In the first one we want only to minimize consequence of applying the first two ones.
the number of reshuffles, i.e. h(s) = h1(s). In the second one, we also
want to minimize the distance of the selected containers to the 1. Balanced before loading operation: In this case, we consider
forklift truck, so we have set h(s) = 9 ⁄h1(s) + h2(s). As a result, none that the layout must be balanced before the goal containers are
of the selected containers (the red ones) are placed in the most left removed from that yard-bay. This function is showed in Algo-
rows, reducing the required time to load the truck. rithm 4, it compares the height of each row of the yard-bay with
the next one, and if the difference is higher than 2, the value
4.2. OC1t: allowing the 5th tier during the remarshalling process heuristic h is increased. As it appears in Fig. 7, this criterion
avoids the sinks in the final layout while all the containers are
In this optimization criterion as well as the next ones, we will still in the yard-bay.
include the new given heuristic value with the same factor as the
initial one. One of the decisions that must be done in Container However, when these containers are removed, it might cause
Terminals is about which cranes have to be bought depending on that the new layout is unbalanced as it happens in Fig. 7(c).
M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989 983
3 Balanced before and after loading operation: Finally, we must be lower than a maximum (in our case lower than 3).
present an optimization criterion which obtains a layout Fig. 10 shows which rows must be get balanced when we con-
where is balanced both before and after the goal containers are sider one yard-bay and Fig. 11 left shows an example of non-
removed from this yard-bay. With this function we want to balanced yard-bays (rows in dotted points).
solve the problems seen in the last subsections as we can see Dangerous containers: two dangerous containers must main-
it in Fig. 9. tain a minimum security distance. Fig. 11 right shows an exam-
ple of two dangerous containers that does not satisfy the
security distance constraint.
This function (Algorithm 7) is a mixture of the last two ones.
First, we increase h when there are goal containers on the floor.
These constraints interrelate the yard-bays so the problem must
When this is achieved, we increase h when the difference between
be solved as a complete problem. However, it is a combinatorial
the heights values obtained by the function HeightsWithoutGoals
problem and it is not possible to find an optimal or sub-optimal
(Algorithm 5) are higher than 2 for two contiguous rows. And final-
solution in a reasonable time. Following the previous philosophy
ly, if h value is low enough (in our case lower than 1), we increase h
of solving each subproblem independently (each yard-bay sepa-
again if the difference between the actual heights of two contigu-
rately), we can distribute the problem into subproblems and solve
ous rows is higher than 2.
them sequentially taken into account related yard-bays. Thus a
solution to the first yard-bay is taken into account to solve the sec-
Algorithm 7. Pseudo-code to balance the yard-bay before and
ond yard-bay. A solution to the second yard-bay is taken into ac-
after the goal containers are removed
count to solve the third yard-bay. Furthermore, if there exist a
Data: s: state to evaluate; h: Initial heuristic; dangerous container in a first bay, its location is taken into account
Result: h: heuristic value of s; to solve a dangerous container located in the third yard-bay (if it
HeightsWithoutGoals(s); exists); and so on. Taken into account this distributed and synchro-
Dh 0; nous model, we present two different optimization criteria to man-
// Not allow containers on the floor age these types of constraints.
for r 1 to numRows(s) do These two criteria are added to the heuristic function seen in Eq.
if $x container/On(x, r) ^ GoalContainer(x) then (1) as h3 (Eq. (3)); and Eq. (4) shows the exact combination of them.
if MinHeight[r, s] > 0 then This makes possible to follow a criterion with major priority than
Dh Dh + NumContainersOn(x); the other one.
end
end h ¼ a h1 þ b h2 þ c h3 ð3Þ
end h3 ¼ d1 OC nB þ d2 OC nD ð4Þ
h h + Dh;
if h < 2 then As a consequence of the solving mode followed, depending on the
Dh 0; order the yard-bays are resolved may not be possible to achieve a
// Balancing with containers which are not solution. Moreover, as mentioned in Section 4, although we want
objective to guarantee balancing and/or minimum distance between danger-
for r 1 to numRows(s) 1 do ous containers, during relocation of container process we will allow
Dh Abs(MinHeight[r, s] MinHeight[r + 1,s]); the presence of non-desirable sates, e.g. with some sinks between
if Dh >2 then two contiguous rows or bays. These intermediate states are allowed
h h + 0.6 (Dh 2); because through them we will be able to get better solutions taking
end into account as metric function the number of reshuffles done.
end
if h < 2 then 5.1. OCnB: balancing contiguous yard-bays
// Balancing with containers which are objective
for r 1 to numRows(s) 1 do In this section we present an extension for the heuristic h1
Dh Abs(Height[r, s] Height[r + 1,s]); (Algorithm 1) to include the balancing of continuous yard-bays
if Dh >2 then as a requirement. It is considered that there is a sink when a differ-
h h + 0.4 (Dh 2); ence higher than two containers exists between two adjacent rows
end in contiguous yard-bays. This criterion is an extension of the bal-
end anced heuristic presented in Algorithm 7, which avoids sinks in
end the same yard-bay (horizontal balance) both before and after the
end outbound containers have been removed from the yard. However,
in this case a sink represents a constraint between two subprob-
lems. Thus, we also consider that there is a sink when a difference
5. Optimization criteria for one block of two exits between the same row r in two contiguous yard-bays
(vertical balance).
This initial heuristic (h1) was unable to solve a complete yard or This process is showed in Algorithm 8. This also uses the Func-
block (in our case, one block consists of 20 yard-bays) due to the tion HeightsWithoutGoals (Algorithm 5) in order to calculate for the
fact that they only solve individual yard-bays. In this paper, we yard-bay b the height for each stack where the first no-goal con-
also have developed two optimization criteria that include new tainer is. Heights of each row are stored as soon as the planner gets
constraints that involve several yard-bays. These constraints are: the final solution plan for one yard-bay.
First, we apply the criterion seen in Algorithm 7 on the yard-bay
Balancing contiguous yard-bays: rows of adjacent yard-bays b. Through heights’ calculated by Algorithm 5 and the real
must be balanced, that is, the difference between the number heights of the actual yard-bay we obtain the differences between
of containers of row j in yard-bay i and row j in yard-bay i 1 the row r and r 1 to calculate the value of h. When this value is
M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989 985
zero (the yard-bay b is horizontally balanced), then we introduce ences are higher than 2, we increase h proportionally. After that
our function to balance it with respect to the last yard-bay bl. To process, b will be balanced horizontally with respect to their rows,
do so, we must also calculate the heights’ through the Algorithm and vertically with respect to the last yard-bay. Repeating this pro-
5 over bl and use the real heights of it in order to obtain the differ- cess for each yard-bay in the block, this will be completely
ences between the row r situated in b and bl. When these differ- balanced.
986 M. Rodriguez-Molins et al. / Expert Systems with Applications 39 (2012) 978–989
Fig. 11. (Left) non-balanced yard-bays. (Right) proximity of two dangerous containers.