2. An Analytical Framework for Integrated Maritime Terminal Scheduling Problems with Time Windows
2.5. Solution Method
2.5.1. Chromosome Coding and Decoding
In GA, a proposed solution is defined as a set of values represented as a simple string called a chromosome (or genome). Given the nature of TMSTW, we determine the length of the chromosome by the number of jobs and use a non-binary encoding scheme. For example, consider the illustrative case in Section 2.3, Figure 2-3 shows a sample chromosome.
Please note that, by our definition, we do not require the first-stage jobs to be listed before those in the second stage. In fact, when a second-stage job shows beforehand, the chromosome is repaired and thus its validity is maintained. Consider an initial chromosome of {10, 4, 9, 1, 3, 2, 8, 7, 5, 6} and assume that jobs 1 to 4 and jobs 5 to 10
4 1 3 2 10 9 8 7 6 5
26
belong to the first and second stages respectively. Since jobs belonging to the second stage precede those in the first stage (for example job 10 precedes job 4 in the chromosome), the chromosome needs to be repaired. Through a repair mechanism, jobs {4, 1, 3, 2} are brought prior to {10, 9, 8, 7, 5, 6}. The repaired chromosome would be {4, 1, 3, 2, 10, 9, 8, 7, 5, 6}. It should also be emphasized that the repair mechanism preserves the order of the jobs within each stage, and only shifts those belonging to the first stage to the left. The repair is performed at the beginning of a decoding procedure that is presented next.
To decode the chromosome, we propose a unique decoding procedure, which derives the individual completion time for each job as well as the total completion time. The developed decoding procedure converts each chromosome to a full schedule by iteratively assigning the jobs to the cranes in their order in the chromosome. It is important to note that, the feasibility of a solution is preserved during the process. More specifically to conserve the precedence constraint (constraint 2-5), the procedure first assigns the jobs in the first stage and computes their completion times. For a job in the second stage, the procedure considers the completion time of its predecessors in the first stage (assumption 5 in Section 2.4). In other words, the starting time of a job in the second stage cannot be less than the maximum completion times of its predecessors in the first stage. To preserve the resource availability constraint (constraints 2-2, 2-6 and 2-7) when assigning a job, the procedure checks if an adequate number of cranes is available to serve. Figure 2-4 presents the decoding flowchart. To have a better understanding of how this procedure works, we outline it for the given chromosome.
27
Start
Determine the sequence of the jobs using GA Repair the chromosome if
needed
i = 1
tnow = 0
Current job belongs to the 1st stage
End
tnow = 0
Calculate the number of cranes available (a) at tnow
tnow = max (tnow ,
min(completion time of precedent jobs in the 1st stage
if greater than tnow))
tnow = max (tnow , min(begin
of time windows of available cranes if greater than tnow))
Assign the resources to the current job
Update time windows Evaluate the completion time No
No Current job is the first
job of the 2nd stage
Yes No Yes i <= number of jobs Yes a < required number of cranes Yes No
Figure 2-4: Decoding flowchart
In the 1st stage, the current time (i.e., tnow is set to 0, and the number of available resources are determined. Recall from Section 3 (Table 2-2) that 3 quay cranes are available for the first 5 hours, and hence all of them could be assigned to vessel 4 that needs 3 cranes for 2 hours. Since vessel 4 would be completely unloaded at the end of hour 2, the availability
28
of each crane is updated accordingly. For example, QC1 will now be available at the beginning of hour 2 and until the end of hour 5 (i.e., [2-5]). The next vessel is 1, which also requires 3 quay cranes for 2 hours. Note that the number of quay cranes at tnow = 0 is not enough to service 1, and hence the procedure updates tnow to the maximum of current tnow and the minimum of the beginning of the earliest time window for all quay cranes if greater than tnow. More explicitly, the updated tnow = max {0, min (2, 2, 2, 5)} = 2, where the four elements inside the inner parenthesis represent the availabilities of the four quay cranes after completing unloading vessel 4 and are all greater than tnow. Note that QC4 is never used to service 4; it is unavailable until the end of hour 5. Since there are adequate numbers of cranes available at the end of hour 2, vessel 1 could be serviced in hours 3 and 4.
Now consider a different case: vessel 1 requires 4 quay cranes instead of 3, and QC1 is always available. The steps will be as follows: after updating tnow to 2, since there are only 3 quay canes available, vessel 1 cannot be served. Thus tnow is updated again: tnow = max {2, min (24, 15, 24, 5)} = 5, where 24, 15 24, 5 are respectively the beginnings of the next time windows of all the cranes. Because quay crane 1 and 3 have only one time window, the beginning of their next time window is set to 24 (the maximum value possible). This procedure continues until all the jobs have been scheduled.
Scheduling in the 2nd stage is similar to what discussed above, except that precedence constraints need to be incorporated when tnow is initialized. More explicitly, after tnow is reset by the first job in the 2nd stage, it is updated to the maximum of the current tnow and the maximum completion time of precedent jobs in the 1st stage. For example, the first job
29
in the 2nd stage is destination 10 whose predecessor is vessel 4 in the 1st stage, which requires 2 hours to compete; hence tnow = max(0,2) = 2. It is important to notice that more than one chromosome sequence may result in the same objective function value, although each would be decoded into a distinct sequence of jobs.